January 22, 2017 at 12:45 am
Hi All,
i find it hard to pick up powershell...need some help here.... .
i have some result as below:
PS C:\Users\xxx> $strReference = Get-Content "C:\temp\cep\book1.csv"
PS C:\Users\xxx> $strDifference = Get-Content "C:\temp\cep\book2.csv"
PS C:\Users\xx> Compare-Object $strReference $strDifference -PassThru
server1\instance1,LOGPp,Hegg_Role_USR,SQL_USER,SELECT,Tables,HR.departments
server1\instance1,LOGPp,Herr_Role_USR,SQL_USER,DELETE,Tables,HR.departments
Qns: i need to pipe the result into a csv or a txt files in the format as below:
severname dbname role type permission objectype tablename
server1\instance1 LOGPp Hegg_Role_USR SQL_USER SELECT Tables HR.departments
server1\instance1 LOGPp Herr_Role_USR SQL_USER DELETE Tables HR.departments
not too sure how to really pipe it using power shell .. . please advice.
January 23, 2017 at 4:56 am
To get a file of the differences then you can do the following:
PS C:\Users\xx> Compare-Object $strReference $strDifference -PassThru | Out-File "C:\temp\cep\result.txt"
Gaz
-- Stop your grinnin' and drop your linen...they're everywhere!!!
January 24, 2017 at 2:29 am
Gary Varga - Monday, January 23, 2017 4:56 AMTo get a file of the differences then you can do the following:
PS C:\Users\xx> Compare-Object $strReference $strDifference -PassThru | Out-File "C:\temp\cep\result.txt"
have decided to compare 2 txt files as the source
serverInstance databaseName loginName Prividges Object
---------------- ------------- ---------- ---------- --------
CHWDB01\FEGG FEGG FEGG_USER SELECT Buller.Trainer
CHWDB01\FEGG FEGG FEGG_USER DELECT Buller.Trainer
serverInstance databaseName loginName Prividges Object
---------------- ------------- ---------- ---------- --------
CHWDB01\FEGG FEGG FEGG_USER SELECT Buller.Trainer
CHWDB01\FEGG FEGG FEGG_USER DELECT Buller.Trainer
CHWDB01\FEGG FEGG FEGG_USER EXECUTE Buller.Trainer
clear-host
$strReference = Get-Content "C:\temp\cep\test1.rpt"
$strDifference = Get-Content "C:\temp\cep\test2.rpt"
Compare-Object $strReference $strDifference | Format-Table -AutoSize | out-file C:\temp\cep\yourfile.txt
but the output is missing the heading. Can someone advice?
result:
InputObject SideIndicator
----------- -------------
CHWDB01\FEGG FEGG FEGG_USER EXECUTE Buller.Trainer =>
January 24, 2017 at 2:42 am
John
January 24, 2017 at 2:54 am
Or just take the 1st (and optionally 2nd) line(s) from one source file.
Gaz
-- Stop your grinnin' and drop your linen...they're everywhere!!!
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply