如何退出从psexec调用的powershell

时间:2014-01-06 17:46:04

标签: batch-file powershell psexec

我正在尝试使用连接到远程系统的psexec来调用powershell脚本

所以从“计算机A”我调用“计算机B”上的批处理文件Aot.bat

Aot.bat有一行调用powershell

powershell.exe%SystemRoot%\ system32 \ aot.ps1 -ComputerName AotServ01>> \ Aot01 \ AOtShared \ Yuma.txt;退出

我可以看到连接已经建立并且powershell运行,但是它不会退出

所以请告知可以做什么或添加什么

Aot.ps1在当前时刻读取内存和CPU


[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

$proc =get-counter -Counter "\Processor(_Total)\% Processor Time" -SampleInterval 2

$cpu=($proc.readings -split ":")[-1]

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+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
}
===============================================================================

0 个答案:

没有答案
相关问题