我有一个PowerShell脚本,该脚本可在除PC以外的所有尝试过的计算机上运行。我正在运行PowerShell版本4:
Major Minor Build Revision ----- ----- ----- -------- 4 0 -1 -1
为什么它不能在我的PC上运行? “ ???”是Splunk的分隔符。
$ErrorActionPreference = "SilentlyContinue"
$AllDrives = [System.IO.DriveInfo]::GetDrives() |
Where-Object {$_.DriveType -eq 'Fixed'}
foreach ($drive in $AllDrives) {
Get-ChildItem -Path $drive.RootDirectory -Recurse -Include "*.*" |
Select @{Name="Time";Expression={(Get-Date).ToString('MM/dd/yyyy HH:mm:ss.fff')}},
@{Name="Delim1";Expression={"???"}},
@{Name="ComputerName";Expression={$env:COMPUTERNAME}},
@{Name="Delim2";Expression={"???"}}, Name,
@{Name="Delim3";Expression={"???"}}, Directory,
@{Name="Delim4";Expression={"???"}}, CreationTime,
@{Name="Delim5";Expression={"???"}}, LastWriteTime,
@{Name="Delim6";Expression={"???"}}, LastAccessTime |
Format-Table * -AutoSize -HideTableHeaders |
Out-String -Width 4096
}