I can generally muddle my way through PowerShell but I've run up against a problem for which I can't seem to find an answer.
I have a PowerShell script that pulls a list of computers and the applications to which they are mapped. The script pulls the information in the following format
Computer1,App1,App2,App3,App4,App5 (can be over 100 applications)
Computer2,App2,App4
Computer3,App1,App3,App5
(can be over 800 computers)
Code: Select all
$dt = @()
$dt=(get-date -UFormat "%Y%m%d")
$computers = (Get-Content c:\inputfiles\ngmclist.txt)
foreach ($computer in $computers) {
$strCMP=GET-ADComputer $computer –Properties cn,MemberOf
$strGRP=($strCMP.MemberOf | Sort Name | foreach {($_.Split(','))[0].Substring(3)}) -Join ","
$strCMP=($strCMP.cn | foreach {($_.Split('='))[0]}) -Join ","
$strDone=$strCMP+","+$strGRP
Add-Content c:\outputfiles\$dt"ComputersandGroupsList.txt" -value $strdone
}
Computer1,App1
Computer1,App2
Computer1,App3
Computer1,App4
Computer1,App5
Computer2,App2
Computer2,App4
Computer3,App1
Computer3,App3
Computer3,App5
(can be over 4000 rows)
I can't seem to find info in any of my normal powershell forums that would allow me to format the data in this way.
Can I please get some help?