none
Invoke-command problem RRS feed

  • Frage

  • 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 Stop

    The 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


    Thanks Horst MOSS 2007 Farm; MOSS 2010 Farm; TFS 2010; IIS 7.5

    Freitag, 17. August 2012 06:01

Antworten

  • 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"))


    Thanks Horst MOSS 2007 Farm; MOSS 2010 Farm; TFS 2010; IIS 7.5

    • Als Antwort markiert wuwu Freitag, 17. August 2012 06:56
    Freitag, 17. August 2012 06:56