For some actions to work in Windows
, your PowerShell session must be running elevated, so it has full administrative rights. If your PowerShell window is running elevated, the word "Administrator:" should be at the start of the title bar. You can also run the command below, which will return true if you are running elevated:
(whoami /all | select-string S-1-16-12288) -ne $null
For example, I entered it and received this response, showing my session is running elevated:
PS C:\Windows\system32> (whoami /all | select-string S-1-16-12288) -ne $null
To learn more, see "Top 10 PowerShell Annoyances." You might also be interested in "Top 10 Active Directory Tasks Solved with PowerShell."