I am trying to call a powershell script using psexec which connects to remote system
So from "Computer A" I call the batch file Aot.bat which is on "Computer B"
Aot.bat has a line which calls the powershell
powershell.exe%SystemRoot%\system32\aot.ps1-ComputerName AotServ01 >>\Aot01\AOtShared\Yuma.txt;exit
I can see that the connection is made and powershell runs, but then it does not exit
So please advise what can be done or added
Aot.ps1 reads the Memory and CPU at the present Moment
So from "Computer A" I call the batch file Aot.bat which is on "Computer B"
Aot.bat has a line which calls the powershell
powershell.exe%SystemRoot%\system32\aot.ps1-ComputerName AotServ01 >>\Aot01\AOtShared\Yuma.txt;exit
I can see that the connection is made and powershell runs, but then it does not exit
So please advise what can be done or added
Aot.ps1 reads the Memory and CPU at the present Moment
[cmdletbinding()]
[cmdletbinding()]
param(
[parameter(ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)]
[string[]]$ComputerName = $env:computername)
begin {
Get-Module –ListAvailable | import-module
Add-PSSnapin Citrix*
Set-executionpolicy -scope currentuser -executionpolicy unrestricted
$date = Get-Date -Format yyyMMdd
$Zip = "\\na02\KCRC\IRD_KFLOWRPT\Citrix_" + $date + "\Citrix_" + $date + ".txt"
$time = Get-Date -format F
}
process
{
foreach($Computer in $Computername)
{
$free = ( Get-WMIObject Win32_OperatingSystem -ComputerName $computer ).FreePhysicalMemory
$phys = ( Get-WMIObject Win32_OperatingSystem -ComputerName $computer ).TotalVisibleMemorySize
$Percentage = (($phys-$free)/$Phys) * 100
#_____________________CPU Load_______________________________
$proc =get-counter -Counter "\Processor(_Total)\% Processor Time" -SampleInterval 2
$cpu=($proc.readings -split ":")[-1]
#"Percentage Used: " + $Percentage
#"Percentage Used: " + $cpu
""
<#
Add-Content ("\\na02\KCRC\IRD_KFLOWRPT\Citrix_" + $date + "\Citrix_" + $date + ".txt")
"*********************************************************************************"
Add-Content $zip "Computer: " $computer
Add-Content $zip "_________________________________________________________________________________"
Add-Content $zip "Percentage Memory user Used: " $Percentage
Add-Content $zip ""
Add-Content $zip "Percentage CPU Used: " $cpu
Add-Content $zip "_________________________________________________________________________________"
Add-Content $zip $time
Add-Content $zip "*********************************************************************************"
Add-content $zip $Load
#>
write-host "`r`n*********************************************************************************"
write-host "`r`nComputer: " $computer
write-host "`r`n_________________________________________________________________________________"
write-host "`r`nPercentage Memory user Used: " $Percentage
write-host "`r`n"
write-host "`r`nPercentage CPU Used: " $cpu
write-host "`r`n_________________________________________________________________________________"
write-host "`r`n"
write-host $time
}
}
end
{
write-host "`r`n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
write-host "`r`n END OF FILE "
write-host "`r`n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
}
[cmdletbinding()]
param(
[parameter(ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)]
[string[]]$ComputerName = $env:computername)
begin {
Get-Module –ListAvailable | import-module
Add-PSSnapin Citrix*
Set-executionpolicy -scope currentuser -executionpolicy unrestricted
$date = Get-Date -Format yyyMMdd
$Zip = "\\na02\KCRC\IRD_KFLOWRPT\Citrix_" + $date + "\Citrix_" + $date + ".txt"
$time = Get-Date -format F
}
process
{
foreach($Computer in $Computername)
{
$free = ( Get-WMIObject Win32_OperatingSystem -ComputerName $computer ).FreePhysicalMemory
$phys = ( Get-WMIObject Win32_OperatingSystem -ComputerName $computer ).TotalVisibleMemorySize
$Percentage = (($phys-$free)/$Phys) * 100
#_____________________CPU Load_______________________________
$proc =get-counter -Counter "\Processor(_Total)\% Processor Time" -SampleInterval 2
$cpu=($proc.readings -split ":")[-1]
#"Percentage Used: " + $Percentage
#"Percentage Used: " + $cpu
""
<#
Add-Content ("\\na02\KCRC\IRD_KFLOWRPT\Citrix_" + $date + "\Citrix_" + $date + ".txt")
"*********************************************************************************"
Add-Content $zip "Computer: " $computer
Add-Content $zip "_________________________________________________________________________________"
Add-Content $zip "Percentage Memory user Used: " $Percentage
Add-Content $zip ""
Add-Content $zip "Percentage CPU Used: " $cpu
Add-Content $zip "_________________________________________________________________________________"
Add-Content $zip $time
Add-Content $zip "*********************************************************************************"
Add-content $zip $Load
#>
write-host "`r`n*********************************************************************************"
write-host "`r`nComputer: " $computer
write-host "`r`n_________________________________________________________________________________"
write-host "`r`nPercentage Memory user Used: " $Percentage
write-host "`r`n"
write-host "`r`nPercentage CPU Used: " $cpu
write-host "`r`n_________________________________________________________________________________"
write-host "`r`n"
write-host $time
}
}
end
{
write-host "`r`n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
write-host "`r`n END OF FILE "
write-host "`r`n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
}