Running Invoke-Command scriptblock - strange results
hello.
i set bios ad computers. dell pcs there piece of software named cctk, , should when running on localhost, have strange problems running through invoke-command cmdlet. here's code:
function set-adcomputerbios { param ( [parameter( position=0, mandatory=$true, valuefrompipelinebypropertyname=$true ) ] [string]$name ) begin { # basic vars $currentdate = get-date $cd = get-date -date $currentdate -format yyyymmddhhmmss $logfile = "log_$cd.txt" new-item $logfile -type file | out-null # add date log add-content $logfile $currentdate; [scriptblock]$scriptblock = { set-location "c:\cctk" cmd.exe /c "cctk.exe -l c:\cctk.log -i v1.2.p.cctk" return $lastexitcode } } # iterate through records process { foreach($computer in $name) { $result = 1; try { write-debug "tworzenie katalogu na komputerze $computer" new-item -itemtype directory \\$computer\c$\cctk -force | out-null write-debug "kopiowanie danych na komputer $computer" copy-item "c:\users\pmn.smok\bios\cctk\*" -destination "\\$computer\c$\cctk" -recurse -force -erroraction stop write-debug "tworzenie sesji ps komputera $computer" $pssession = new-pssession -computername $computer write-debug "wywolywanie konfiguracji bios na komputerze $computer" $result = invoke-command -session $pssession -scriptblock $scriptblock -erroraction stop write-debug "usuwanie pozostalosci z komputera $computer" remove-item \\$computer\c$\cctk -recurse } catch { $result = 1; break } { $outstring = "{0} `t {1}" -f $computer, $result write-host $outstring add-content -path $logfile -value $outstring if ($pssession) {remove-pssession $pssession} } } } }
result not same. @ first run processing takes longer. process returns 0 expected log empty , bios not being set. when run script again, processing faster, process return object [?? why ??] , 1 of two: bios set correctly or being set partially (i.e. password being set nothing elese). in windows logs i've found cctk exec error 0xc00000005. there wrong script? or should search other reasons, av...
thank help
smok.
you have contact dell why utility behaves strangely. not part f powershell of windows vendor has expert.
\_(ツ)_/
Windows Server > Windows PowerShell
Comments
Post a Comment