Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get-DBAPowerPlan fails if PowerShell is not running as Admin #4777

Closed
2 of 4 tasks
sql-williamd opened this issue Dec 5, 2018 · 5 comments · Fixed by #4902
Closed
2 of 4 tasks

Get-DBAPowerPlan fails if PowerShell is not running as Admin #4777

sql-williamd opened this issue Dec 5, 2018 · 5 comments · Fixed by #4902

Comments

@sql-williamd
Copy link

Before submitting a bug report:

  • Ensure you are able to reproduce it on the latest released version (we release often)
  • Verified this bug is not already reported in an issue
  • Verified errors are not related to permissions
  • Can reproduce in a clean PowerShell session (clean = powershell -NoProfile)

Steps to Reproduce

Open PowerShell console in non-Admin mode and run the command

  Get-DBAPowerPlan -ComputerName $MyMachine 

Expected Behavior

Give me a warning that elevated permissions are needed

Actual Behavior

A "timeout" occurs when different protocols are attempted, then it fails with the following message

WARNING: [00:21:47][Get-DbaPowerPlan] Can't get Power Plan Info for $MyMachine. Check logs for more details. | Multiple 
protocol connections were attempted, but no successful connections could be established with the specified computer.

Environmental data

  • PowerShell:
Name                           Value                                                                                      
----                           -----                                                                                      
PSVersion                      5.1.17763.134                                                                              
PSEdition                      Desktop                                                                                    
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                    
BuildVersion                   10.0.17763.134                                                                             
CLRVersion                     4.0.30319.42000                                                                            
WSManStackVersion              3.0                                                                                        
PSRemotingProtocolVersion      2.3                                                                                        
SerializationVersion           1.1.0.1
@Adam-Wenger
Copy link
Contributor

I am unable to reproduce this, I tested with both admin, and regular PowerShell. I was able to get the plan information in both cases.

Were you able to test in admin mode and received the power plan information, just not without elevation? Do you have permissions to the machine you tried to test?

@sql-williamd
Copy link
Author

I can get it to run on my machine when running PowerShell as administrator, non-elevated sessions fail.

This is on my laptop, I have full permissions locally

@joeywas
Copy link
Contributor

joeywas commented Dec 6, 2018

I was able to reproduce this by running Get-DbaPowerPlan on a local non-admin powershell session, targetting my local computer. I'll test it against remote computers later today.

@joeywas
Copy link
Contributor

joeywas commented Dec 6, 2018

Running Get-DbaPowerPlan on a local non-admin PowerShell session against a remote computer works without any issues.

Running against localhost:

PS C:\windows\system32> Get-DbaPowerPlan localhost
WARNING: [12:09:14][Get-DbaPowerPlan] Can't get Power Plan Info for localhost. Check logs for more details. | Multiple
protocol connections were attempted, but no successful connections could be established with the specified computer.
PS C:\windows\system32>

DbaTools version 0.9.710

@joeywas
Copy link
Contributor

joeywas commented Dec 7, 2018

Something about permissions should probably be added to Get-DbaCmObject, which is called from Get-DbaPowerPlan. I started looking at it, but it's a bit over my head. The Get-DbaCmObject author @FriedrichWeinmann may have a suggestion on how to add permissions check that returns appropriate message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants