read xml file with powershell in windows server 2003 - sharepoint

can you please help me with this code below?
[System.Xml.XmlDocument]$xd = New-Object System.Xml.XmlDocument
$file = "C:\PS\SetUP.xml";
$xd.LoadXml($file);
#$root = $xd.DocumentElement
Write-Host $xd.SelectSingleNode("/Setup").Attributes.GetNamedItem("WebAppUrl").Value
This code works fine when I run it in windows server 2008, but it does not work in windows server 2003.
I tested it in C# in the same environment (win server 2003) and it works, but not in Powershell.
I think there could be some Powershell version issue.
Could you please help me?
Thank you
Xml file
<?xml version="1.0" encoding="utf-8"?>
<Setup WebAppUrl="http://sp2007">
<SiteCollection Name="Report" Url="Report Requests">
<Lists>
<List Name="Report Requests" Url="ReportRequests" />
<List Name="Report Request Tasks" Url="ReportRequestTasks" />
</Lists>
<Features>
<Feature>ContentTypeSyndication</Feature>
</Features>
<Site Name="Child 1" Url="child1" Template="STS#0"/>
<Site Name="Child 2" Url="child2" Template="STS#0"/>
<Site Name="Child 3" Url="child3" Template="STS#0"/>
</SiteCollection>
</Setup>

I don't have v1 but you can read xml files and navigate them the same way regardless of OS version. Can you share the xml file?
[xml]$xd = Get-Content C:\PS\SetUP.xml
$xd.SelectSingleNode("/Setup").WebAppUrl
http://sp2007
If there's only one Setup node then you can get the value with:
$xd.Setup.WebAppUrl

The Powershell version on Windows 2003 is 1.
The version on Windows 2008 is 2.
Link: http://en.wikipedia.org/wiki/Windows_PowerShell#Versions
Simple as that. You can try to upgrade it AFAIK.
Edit: Update procedure -> http://maxt2posh.wordpress.com/2009/12/23/update-powershell-v1-to-v2-windows-management-framework/

Related

Azure Role Service can`t deploy - WaHostBootstrapper.exe.config missing

I`m trying to deploy New Azure Service (using SDK 2.9) and encounter the following error:
The file provided is not a valid service package.
Invalid application runtime - a runtime component is missing:/base/x64/WaHostBootstrapper.exe.config.
Screenshot of the error
What did I try:
Tried to package the service and saw "base/x64/WaHostBootstrapper.exe.config" exists and not missing. Screenshot of the Package Folder
Tried to deploy other service from different workload (also SDK 2.9) it works.
Tried to compare the content of WaHostBootstrapper.exe.config between the to mentioned sevices and it was identical
Attaching the contents of the file:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" />
<supportedRuntime version="v2.0.50727" />
</startup>
<runtime>
<NetFx40_LegacySecurityPolicy enabled="false" />
</runtime>
</configuration>
Any ideas what else can I check or try to do?
Thanks a lot for you help

Enabing IIS using CAQuietExec64 in Wix installer does not work

I need to make a windows installer which enables (installs) IIS on windows.
When I run the .msi file, it runs without any give any however, IIS does not get enabled(installed) when I go to Program and Features/Turn Windows Feature on off, it does not get installed
Here is my wxs file:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="IISInstaller" Language="1033" Version="1.0.0.0" Manufacturer="Company" UpgradeCode="21ece05f-bf5c-4f97-850e-cb7cef2bf65e">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
<Property Id="QtExec64CmdLine" Value='"[WindowsFolder]Sysnative\dism.exe" /Online /Enable-Feature /FeatureName:IIS-ApplicationDevelopment /FeatureName:IIS-WebServer
/FeatureName:IIS-WebServerRole /FeatureName:IIS-RequestFiltering /FeatureName:IIS-Security
/FeatureName:IIS-NetFxExtensibility /FeatureName:IIS-ASPNET /FeatureName:IIS-ISAPIExtensions
/FeatureName:IIS-ISAPIFilter /FeatureName:IIS-DefaultDocument /FeatureName:IIS-HttpErrors /FeatureName:IIS-StaticContent
/FeatureName:IIS-HttpLogging /FeatureName:IIS-RequestMonitor /FeatureName:IIS-HttpCompressionStatic
/FeatureName:IIS-HttpCompressionDynamic /FeatureName:IIS-RequestFiltering /FeatureName:IIS-WindowsAuthentication'/>
<CustomAction Id="SilentLaunch" BinaryKey="WixCA" DllEntry="CAQuietExec64" Execute="immediate" Return="check" />
</Product>
</Wix>
even when I change the value in the property to run a simple command to make directory
mkdir test
it does not work either.
Could you please help me what is the problem?
Thanks
Two potential problems:
You have declared the custom action but you haven't put it in a sequence by declaring where it's going to run and what conditions apply. So it didn't run.
Step 2 is missing: http://wixtoolset.org/documentation/manual/v3/wixdev/extensions/authoring_custom_actions.html
After you've done that, the custom action is marked immediate which is usually an error because changes to the system should be done in deferred mode, and immediate custom actions don't run elevated.

How to share parameters configuration between VS publish profile and MSDeploy SetParameters.xml?

I have a web application in Visual Studio 2012. I publish this website to IIS using publish profiles (.pubxml).
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>MSDeploy</WebPublishMethod>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<ExcludeApp_Data>False</ExcludeApp_Data>
<MSDeployServiceURL>server</MSDeployServiceURL>
<DeployIisAppPath>site</DeployIisAppPath>
<RemoteSitePhysicalPath />
<SkipExtraFilesOnServer>False</SkipExtraFilesOnServer>
<MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
<EnableMSDeployBackup>True</EnableMSDeployBackup>
<UserName>domain\username</UserName>
</PropertyGroup>
<ItemGroup>
<MSDeployParameterValue Include="MyParam">
<ParameterValue>MyValue</ParameterValue>
</MSDeployParameterValue>
...
</ItemGroup>
</Project>
Beside I setup a CI to build a package with msbuild and then use it to publish to the different environnement using msdeploy. Both in 2 separates steps, so I can reuse the same package multiple times.
To do this I need to use a SetParameters.xml with a different syntax than the publish profil used by VS.
<?xml version="1.0" encoding="utf-8"?>
<parameters>
<setParameter name="IIS Web Application Name" value="site" />
<setParameter name="MyParam" value="MyValue" />
...
</parameters>
Is there a way to share the parameters configuration in a single file so I can maintain only one file ?
I see this answers from 2014 but I can't managed to make it works.
I've researched this and can't find a way to override the SetParameters file when publish via VisualStudio. It doesn't look like the MSBuild tasks support this.
The best alternative I can offer is to use the commandline instead of right click publish. You can create the MSDeploy package by calling the Package target:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild /t:Package /p:PublishProfile=<profile-name>
And then deploy using MSDeploy.exe:
"C:\Program Files (x86)\IIS\Microsoft Web Deploy V3\msdeploy.exe" -verb:sync -source:package=WebApplication7.zip -dest:manifest=WebApplication7.DestManifest.xml -setParamFile:SetParameters.custom.xml
The following blog posts has more details:
https://dotnetcatch.com/2016/02/25/the-anatomy-of-a-webdeploy-package/

Running JWS remotely on 64-bit machine

The problem is that my JNLP file works locally on my 64-bit machine (running on my own machine), and locally and remotely on my 32-bit machine - but not remotely on the 64-bit machine (you see the Java 6... message for a looong time, and then it just terminates!). Any suggestions about how to trouble-shoot this? Should I specify different libraries for 64-bit and 32-bit? FWIW the jnlp file looks like this (maybe quite wrong!):
<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+"
codebase="http://www.jpaulmorrison.com/graphicsstuff/">
<information>
<title>DrawFBP</title>
<vendor>J.P. Morrison Enterprises, Ltd.</vendor>
<description>FBP Diagramming Tool</description>
<icon href="DrawFBP-logo.jpg"/>
</information>
<security>
<all-permissions/>
</security>
<offline-allowed/>
<resources>
<j2se version="1.6+"/>
<j2se version="1.5"/>
<jar href="DrawFBP_signed-2.3.jar" main="true"/>
<extension name="javahelp" href="javahelp.jnlp">
</extension>
</resources>
<application-desc/>
</jnlp>
and javahelp.jnlp is as follows:
<!-- Java Network Launching Protocol file for JavaHelp
(requires Java Web Start http://www.java.com/) - thanks to www.koders.com -->
<jnlp codebase="https://jwindows.dev.java.net/" href="javahelp.jnlp" spec="1.0+">
<information>
<title>Java Help</title>
<vendor>Sun Microsystems</vendor>
<homepage href="http://java.sun.com/products/javahelp/"/>
<description>Java Help 2.0</description>
<offline-allowed/>
</information>
<security>
<all-permissions/>
</security>
<resources>
<j2se version="1.5+"/>
<jar href="lib/jhall.jar" part="javahelp"/>
<package name="javax.help" part="javahelp" recursive="true"/>
</resources>
<component-desc/>
</jnlp>
TIA
Turns out you have to install both the 32-bit version of Java and the 64-bit version. Very confusing, but apparently Java can figure out which to use! It would be nice (but not essential) if someone could tell me why this works...?
PS I posted this to the Oracle forum, and nobody answered it either :-) I will post this answer there too.

Is it possible to send parameters to InstallShield prerequisites?

I am evaluating InstallShield 2010, and am trying to set some command line parameters to the SQL Server 2008 prerequisite at user runtime. It appears that the prerequisite is defined entirely in the .prq files (xml-style).
Wise for Windows used WiseScript to call the prerequisite installations. InstallAware seems to have something similar, with their own scripting. Does something similar exist for InstallShield?
We use IS v12; I built a .prq file for the purpose (they don't supply a .prq for SQL 2008 for IS v12). First I went to http://msdn.microsoft.com/en-us/library/ms144259.aspx to get all possible cmd line args. Then I used the IS PRQ editor to create the basic .prq structure. Then I hand-edited the .prq (xml) file for (a) easy minor adjustments in the future and (b) to simplify version control diffs.
<?xml version="1.0" encoding="utf-8"?>
<SetupPrereq>
<conditions>
<condition Type="16" Comparison="2" Path="[ProgramFilesFolder]Microsoft SQL Server\100\COM" FileName="sqlresld.dll" ReturnValue="2007.100.1600.22"/>
</conditions>
<files>
<file LocalFile="<ISProductFolder>\SetupPrerequisites\Microsoft SQL Server 2008 Express with Tools\SQLEXPRWT_x86_ENU.exe" CheckSum="BCC335711D44BAFC420B5165D2F04647" FileSize="0,229169680"/>
</files>
<execute file="SQLEXPRWT_x86_ENU.exe" requiresmsiengine="1"
cmdline ="/INSTANCEID=AV /INSTANCENAME=AV /ACTION=Install /FEATURES=SQLENGINE,SSMS /HELP=0 /ERRORREPORTING=0 /SQMREPORTING=0 /INDICATEPROGRESS=0 /QUIETSIMPLE=1 /FILESTREAMLEVEL=0 /ENABLERANU=1 /TCPENABLED=1 /NPENABLED=0 /ADDCURRENTUSERASSQLADMIN=1 /AGTSVCACCOUNT="NT AUTHORITY\NETWORK SERVICE" /AGTSVCSTARTUPTYPE=Manual /BROWSERSVCSTARTUPTYPE=Automatic /SQLSVCSTARTUPTYPE=Automatic /SQLSVCACCOUNT="NT AUTHORITY\NETWORK SERVICE" /RSSVCSTARTUPTYPE=Automatic"
cmdlinesilent="/INSTANCEID=AV /INSTANCENAME=AV /ACTION=Install /FEATURES=SQLENGINE,SSMS /HELP=0 /ERRORREPORTING=0 /SQMREPORTING=0 /INDICATEPROGRESS=0 /QUIETSIMPLE=1 /FILESTREAMLEVEL=0 /ENABLERANU=1 /TCPENABLED=1 /NPENABLED=0 /ADDCURRENTUSERASSQLADMIN=1 /AGTSVCACCOUNT="NT AUTHORITY\NETWORK SERVICE" /AGTSVCSTARTUPTYPE=Manual /BROWSERSVCSTARTUPTYPE=Automatic /SQLSVCSTARTUPTYPE=Automatic /SQLSVCACCOUNT="NT AUTHORITY\NETWORK SERVICE" /RSSVCSTARTUPTYPE=Automatic"
/>
<dependencies>
<dependency File="<ISProductFolder>\SetupPrerequisites\Microsoft Installer 4.5 for XP.prq"/>
<dependency File="<ISProductFolder>\SetupPrerequisites\Microsoft Installer 4.5 for Windows Server 2003 or 64 bit XP.prq"/>
<dependency File="<ISProductFolder>\SetupPrerequisites\Power Shell 1.0 for Windows XP.prq"/>
<dependency File="<ISProductFolder>\SetupPrerequisites\Power Shell 1.0 for Windows Server 2003.prq"/>
</dependencies>
<properties Id="Microsoft SQL Server 2008 Express with Tools" Description="This installs Microsoft SQL Server 2008 Express Edition (SQL Server Express). The /qn switch suppresses all Setup dialog boxes and error messages. See http://msdn2.microsoft.com/en-us/library/ms144259.aspx for more information about the commad line options. The SQL setup logs to %programfiles%\Microsoft SQL Server\100\Setup Bootstrap\Log\"/>
</SetupPrereq>
Yes - by right clicking on the SQL Server prerequisite -> "Application to Run"' tab -> "Specify the command line for the application".
The only way I know how to do this is to write a Helper.EXE that the PRQ calls. The EXE would need to detect the windows settings and silently pass the correct arguments to the real Prereq EXE/MSI.

Resources