Author Posts

January 1, 2012 at 12:00 am

by wuwu at 2012-08-16 22:52:08

Hello,

I have this script:

cls
$strSvr_Cluster = "ZServer4"
$script_ConfigurationEACluster =
{
Write-Host $InputFile
$InputFile1 = "c:\Temp\EAInstallerInput.xml"
# $InputFile1 = "\\zserver100\c$\Temp\EAInstallerInput.xml"

[xml]$xmlinput = (Get-Content $InputFile1)
If ($xmlinput.Configuration.EA_Adapters)
{
ForEach ($Adapter in $xmlinput.Configuration.EA_Adapters.EA_Adapter)
{
$Adaptername = $Adapter.Name
Write-Host $Adaptername
}
}
}

Invoke-Command -ComputerName $strSvr_Cluster `
-ScriptBlock $script_ConfigurationEACluster `
-ErrorAction StopThe problem:

When the variable $InputFile1 = "c:\Temp\EAInstallerInput.xml" then the script works fine and i get the right result:

Result:

Adaptername: MES_EA_EQ1

Adaptername: MES_EA_EQ2

When the variable $InputFile1 = "\\ZServer\100\c$\Temp\EAInstallerInput.xml" then the script doesn't work.

I get this error:

Cannot find path '\\zmucmossdev100\c$\Temp\EAInstallerInput.xml' because it does not exist.
At C:\Users\yadwutschehor\AppData\Local\Temp\2\7f5a5aa9-c177-464e-aacb-136f9f9185e3.ps1:line:20 char:1

+ I < <<< nvoke-Command -ComputerName $strSvr_Cluster ` The file exist at Server ZServer100\c$\Temp. I start this xml file over IE at server Zserver4, the invoke-command server I hope somebody can help me, Horst

by wuwu at 2012-08-16 23:56:51

This is the solution:

cls
$strSvr_Cluster = "ZServer4"
$InputFile = "\\zserver100\c$\Temp\EAInstallerInput.xml"

$script_ConfigurationEACluster =
{
param([xml]$xmlinput)
If ($xmlinput.Configuration.EA_Adapters)
{
ForEach ($Adapter in $xmlinput.Configuration.EA_Adapters.EA_Adapter)
{
$Adaptername = $Adapter.Name
Write-Host $Adaptername
}
}
}

Invoke-Command -ComputerName $strSvr_Cluster `
-ScriptBlock $script_ConfigurationEACluster `
-ErrorAction Stop `
-ArgumentList ([io.file]::ReadAllText("$InputFile"))

by jmiller76 at 2012-08-17 08:01:59

you could also put your
$InputFile = "\\zserver100\c$\Temp\EAInstallerInput.xml"
as
$InputFile = '\\zserver100\c$\Temp\EAInstallerInput.xml'
...with single quotes.
The "$" from the admin share is probably being interpreted.
If you get an error like that make sure that Test-path returns true so that you know there are no typos or escaped value issues.