Avatar of fieldj
fieldj
Flag for United Kingdom of Great Britain and Northern Ireland asked on

powershell, which credentials should i use

I am new to power shell so this may be a simple question.  I have configured winRM in my domain and this is working.

My workstation is Win 7 Pro SP1 running PSversion 4.0.  I'm logged in as myself, a domain user who is a member of the administrators group (but not a Domain Admin).  My question is, what credentials should I run the ps console in?
 
If I just click on windows power shell, not much works [ eg. Get-Service -name B* -ComputerName is-tr-01 ] fails with a privilege error
If I right click and Run As Administrator the above still does not work.
If I shift click and Run as Another User, use a domain admin account, the above does work, however seems to create a problem, such as if I want to pipe to csv, [eg.  Get-Service -Name b* -ComputerName is-tr-01 | Export-Csv c:\services.csv ] fails with access to c: path is denied.
If I Run As Administrator [ Get-Service -Name b* | Export-Csv c:\services.csv  ] removing the remote computer, this does work.
Powershell

Avatar of undefined
Last Comment
David Johnson, CD

8/22/2022 - Mon
Som Tripathi

Please let us know what errors you get.
fieldj

ASKER
when doing Run As Administrator, error below:

PS C:\Windows\system32> Get-Service -Name BITS -ComputerName fs1
Get-Service : Cannot find any service with service name 'BITS'.
At line:1 char:1
+ Get-Service -Name BITS -ComputerName fs1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (BITS:String) [Get-Service], ServiceCommandException
    + FullyQualifiedErrorId : NoServiceFoundForGivenName,Microsoft.PowerShell.Commands.GetServiceCommand
fieldj

ASKER
when running as Another User (who is domain admin), no error:

PS C:\windows\system32> Get-Service -Name BITS -ComputerName fs1

Status   Name               DisplayName
------   ----               -----------
Stopped  BITS               Background Intelligent Transfer Ser...

but if i want to pipe to file, I get the error below:

PS C:\windows\system32> Get-Service -Name BITS -ComputerName fs1 | Export-Csv -Path c:\services.csv
Export-Csv : Access to the path 'C:\services.csv' is denied.
At line:1 char:44
+ Get-Service -Name BITS -ComputerName fs1 | Export-Csv -Path c:\services.csv
+                                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OpenError: (:) [Export-Csv], UnauthorizedAccessException
    + FullyQualifiedErrorId : FileOpenFailure,Microsoft.PowerShell.Commands.ExportCsvCommand
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
ASKER CERTIFIED SOLUTION
footech

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
David Johnson, CD

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.