I am trying to understand what is going on with my current script which is a simple one liner. My setup is relatively simple. An AD joined server that is going to be used as a certificate root in an internal PKI (The root server should be a workgroup only
system, but let us move on.) running Windows 2012 R2, and a Windows 8.1 workstation that I am using as a RSAT/CnC system. I am able to launch a powershell as the administrator on the local system as well as remote into the server and launch powershell as the
administrator.
If I run an invoke-command -Computer RemoteServer -ScriptBlock {Get-Culture} I get back the expected 4 columns of information. If I Enter-PSSession -Computer Remote Server and then issue Get-Culture, I get back the expected 3 columns of information (no remote
system name).
The Problem is if do an invoke-command -Computer RemoteServer -ScriptBlock {Backup-CARoleService c:\testdir -Password (ConvertTo-SecureString "SuperSecret" -AsPlainText -Force)} or I run the script block from a Enter-PSSession prompt, it appears
to execute properly (I get all of the proper files), but I get :
Backup-CARoleService : Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
At line:1 char:1
+ Backup-CARoleService c:\testdir -Password (ConvertTo-SecureString "SuperSecret ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Backup-CARoleService], UnauthorizedAccessException
+ FullyQualifiedErrorId : BackupDatabase,Microsoft.CertificateServices.Administration.Commands.CA.BackupCACommand
at the end of execution.
If I remote terminal into RemoteServer and execute the Backup-CARoleService command from a powershell, everything succeeds without error.
What is going on with the Access Denied message ?
Thank you for your help.
Edit2 : I am the same domain user on both the local workstation and the remote server.
Edit3 : On a lark I also tried using :
$s=New-PSSession -Computer RemoteServer -Credentials Domain\Admin
Invoke-Command -Session $s -ScriptBlock...
Same error message with these command.
Sean