Quantcast
Channel: PowerShell General
Viewing all articles
Browse latest Browse all 10624

merge 2 variables as csv

$
0
0

hi powershell.com 

i trying to Consolidation of two separate line as parallel lines.... my English is no so grate 

Background story:

I use psgetsid on all computer i got from this software Ad tidy (with respond from ping)

then i got this text

\\xxxx-PC:

 

SID for \\xxxx-PC:

S-1-5-xx-00000000-000000000-0000000000

 

\\xxxx-xxxx:

\\xxxx:

\\xxx-PC7:

 

SID for \\xxxx-PC7:

S-1-5-21-00000000-000000000-0000000000

 

\\xxxx-xxxxx:

\\xxxxxx-xxxxxx:

\\xxxxxx:

 

SID for \\xxxxxx:

S-1-5-21-00000000-000000000-0000000000

 

now i use this powershell code to filter the data:

$allsid = Get-Content .\Desktop\allsid.txt

$a = $allsid | ? { $_.StartsWith("SID for \\")}

$a = $a -replace "SID for \\*" -replace ":" 

$b = $allsid | ? { $_.StartsWith("S-1-5-21")}

 

now i have $a and $b how can i place the in one file or array with 2 Column

 

it should look like this :

Computername,sid

PC-0001,S-1-5-21-00000000-000000000-0000000000

PC-0002,S-1-5-21-00000000-000000000-0000000000

 

you get were i'm going  with this, i all ready combine this 2 line using excel, but just for fun and learn new trikes at Power-Shell I like to have this automatically .... 

i try to do something form this nice person blog 

http://technet.microsoft.com/en-us/magazine/2008.06.windowspowershell.aspx

 

 

 


Viewing all articles
Browse latest Browse all 10624

Trending Articles