私の現在の Powershell スクリプトは、コンピューター名の .txt ドキュメントと、csv ファイルにインポートできるようにしたいソフトウェアを吐き出します。各コンピューター名は新しい列です。
現在、出力は次のようになります。
PC1=
商品名
ソフトウェアA
ソフトウェアB
PC2=
商品名
ソフトウェアA
ソフトウェアB
このデータを適切にソートするためにこれをスクリプト化するにはどうすればよいですか? csv に直接インポートすると、この情報がすべて 1 つの列に表示されます。次の列に書き込むために foreach ループにスローできるものはありますか? または、ループごとに独自の .txt に書き込み、各 .csv を取得して新しいシートにインポートすることはできますか
ソースコードは次のとおりです。
$ComputerNames = get-content ".\Computers.txt"
foreach ($Computer in $ComputerNames)
{$arryStandardSoftware = get-content -path ".\StandardSoftware.txt"| Foreach-Object{$_.trim()}
$AuditResult = (Get-WMIObject -namespace "root\cimv2\sms" -class sms_installedsoftware -computername "$computer"|
Select-Object productname|Where-Object{$arryStandardSoftware -notcontains "$($_.productname)"})
echo "$Computer ="$AuditResult | out-file ".\SoftwareAudit.txt" -append}