私たちの環境では、RMSを使ってファイルを保護しています。 PowerShellを使用する必要があります。base64 encoded powershell "null配列にインデックスできません。" ISEから実行します
使用しているpsxmlファイルが署名されていないため、MDTをドメインに参加させたWDSサーバーを使用することさえできません。
私は、単一の行がコマンドや$code = {}
に包まれた私のスクリプトで [convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($code))
ラインを使用してエンコードされたコマンドとしてとしてPSスクリプトを実行する必要があります。
このスクリプトは、PowerShell ISEから実行すると機能します。
$lines = Get-Content E:\folder\list.txt | Select-String -Pattern "Success Message" -AllMatches -Context 1,0 | % $_.Context.PreContext[0]
foreach ($line in $lines) {
$file = $line.ToString().TrimStart("chars. ")
Protect-RMSFile -File $file -InPlace -DoNotPersistEncryptionKey All -TemplateID "template-ID" -OwnerEmail "[email protected]" | Out-File -FilePath E:\folder\logs\results.log -Append
}
バッチスクリプト:
"e:\folder\command.exe -switches" > "E:\folder\list.txt"
powershell.exe -EncodedCommand encodedBlob
出力:私はいくつかの並べ替えの例外ログが助けになることがあり、別の質問で見た
Cannot index into a null array.
At line:3 char:1
+ $lines = Get-Content E:\folder\list.txt | Select-String -Pattern "S ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : NullArray
...
$Error.Exception | Where-Object -Property Message -Like "Cannot index into a null array." | Format-List -Force | Out-File -FilePath E:\folder\err.log
出力:
ErrorRecord : Cannot index into a null array.
StackTrace : at CallSite.Target(Closure , CallSite , Object , Int32)
at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
at System.Management.Automation.Interpreter.DynamicInstruction`3.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
WasThrownFromThrowStatement : False
Message : Cannot index into a null array.
Data : {System.Management.Automation.Interpreter.InterpretedFrameInfo}
InnerException :
TargetSite : System.Object CallSite.Target(System.Runtime.CompilerServices.Closure, System.Runtime.CompilerServices.CallSite, System.Object,
Int32)
HelpLink :
Source : Anonymously Hosted DynamicMethods Assembly
HResult : -2146233087
NTFSのアクセス許可と同じくらい簡単だと思って、私は所有者を取って、このフォルダ構造のすべてのアクセス許可をadminと私のフルコントロールに置き換えました。エラーに変更はありません。
ヒント?私は簡単なものを見落としていますか?
権限の問題だった場合は、 'Get-Content'呼び出しでエラーが発生しました。あなたのロジックはパターンマッチングに悪いので、 '$ Lines'は' $ Null'を終了します。 – TheIncorrigible1