level 2
z516645807
楼主
$ComputerName |foreach {
gwmi -class win32_share -ComputerName $_ComputerName |foreach{
if(($_.name -eq "NETLOGON") -or ($_.name -eq "SYSVOL") -or ($_.name -eq "IPC$")){
Write-output $_.PSComputerName $_.name $_.status
}
}
}
以上write-output输出的如下:
AD1
NETLOGN
OK
AD1
SYSVOL
OK
如何使write-output输出为三列:
AD1 NETLOGON OK
AD1 SYSVOL OK
我知道 write-host可以 但是wirte-host只显示到控制台,不能使用管道和赋值给其它变量,求大神帮忙
2021年10月21日 09点10分
1
gwmi -class win32_share -ComputerName $_ComputerName |foreach{
if(($_.name -eq "NETLOGON") -or ($_.name -eq "SYSVOL") -or ($_.name -eq "IPC$")){
Write-output $_.PSComputerName $_.name $_.status
}
}
}
以上write-output输出的如下:
AD1
NETLOGN
OK
AD1
SYSVOL
OK
如何使write-output输出为三列:
AD1 NETLOGON OK
AD1 SYSVOL OK
我知道 write-host可以 但是wirte-host只显示到控制台,不能使用管道和赋值给其它变量,求大神帮忙