Recently I need to run one powershell script which will bring all files in EPM project folder for project documentation audit. Since I worked as consultant and mostly working on my personal laptop at different client side. So I was struggling to run this powershell script
$folder = "\\SomePRojectserver\pwa\";
$toInclude =("Shared Documents");
$outputFolder="C:\TempOutput\output.csv";
gci -recurse -Path $folder | select parent,name,Directory |? { $_.Directory -match $toInclude }|
Export-Csv $outputFolder -Encoding UTF8
Reason is b/c powershell take my logged in user credentials either run powershell as administrator with elevated prvilages. So trick is to run following command either through cmd, powershell or through run command:
.\runas.exe /netonly /user:domain\username powershell.exe
$folder = "\\SomePRojectserver\pwa\";
$toInclude =("Shared Documents");
$outputFolder="C:\TempOutput\output.csv";
gci -recurse -Path $folder | select parent,name,Directory |? { $_.Directory -match $toInclude }|
Export-Csv $outputFolder -Encoding UTF8
Reason is b/c powershell take my logged in user credentials either run powershell as administrator with elevated prvilages. So trick is to run following command either through cmd, powershell or through run command:
.\runas.exe /netonly /user:domain\username powershell.exe
0 comments:
Post a Comment