0
我想刪除我的csv輸出文件中的引號,但代碼不起作用。我遵循了所提供的準則,但仍然不刪除引號。powershell腳本:刪除「」csv輸出文件周圍的引號
$OutFile = "C:\Users\munjanga\Documents\AoN Project\Execute\$([Environment]::MachineName).txt"
$Header = "Folder Path,IdentityReference,AccessControlType,IsInherited,InheritanceFlags,PropagationFlags"
Del $OutFile
Add-Content -Value $Header -Path $OutFile
$RootPath = "C:\Users\munjanga\Documents\Operations Orchestration"
$Folders = dir $RootPath -recurse | where {$_.psiscontainer -eq $true}
$isInherited = @{
$true = 'Inherited'
$false = 'Not Inherited'
}
$inheritance = @{
0 = 'files only'
1 = 'this folder and subfolders'
2 = 'this folder and files'
3 = 'subfolders and files'
}
$fldr = $Folder.FullName
$Folders | % {
$fldr = $_.FullName
Get-Acl $fldr | select -Expand Access |
select @{n='Account';e={$_.IdentityReference}},
@{n='Ace String';e={"{0} {1}, {2} ({3})" -f $_.AccessControlType,
$_.FileSystemRights, $inheritance[$_.InheritanceFlags],
$isInherited[$_.IsInherited]}},
@{n='Object Path';e={$fldr}} | ConvertTo-Csv -NoTypeInformation -Encoding ascii | % {$_ -replace '"', ""} | Out-File $OutFile -Force -Encoding ascii
我改成了這一點,但在「」痕跡仍然存在:{(獲取內容$ OutFile將)| %{$ _ -replace'「',」「} | out-file -FilePath $ OutFile -Force -Encoding ascii} – user3738022
更改了什麼?應該是您提供的行後面的另一行 –
對不起,我誤以爲你有說取代反正我已經添加它在我提供的線以下,但輸出仍然是相同的... – user3738022