Editing Registry key on remote computer using Powershell
I am trying to edit a registry key value on a remote VM running Windows 7.
I am using the following commands to do that:
$RegistryBase = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', "WIN-MONKU")
$RegKey= $RegistryBase.OpenSubKey("SOFTWARElalalandnode")
$RegistryValue = $RegKey.GetValue("HostAddress")
Write-Host "HostAddress: $RegistryValue"
But I am getting errors as:
Exception calling "OpenRemoteBaseKey" with "2" argument(s): "Attempted to perform an unauthorized operation."
At D:workspaceScriptsUpdate.ps1:35 char:1
+ $RegistryBase = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('Loc ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) , MethodInvocationException
+ FullyQualifiedErrorId : UnauthorizedAccessException
You cannot call a method on a null-valued expression.
At D:workspaceScriptsUpdate.ps1:36 char:1
+ $RegKey= $RegistryBase.OpenSubKey("SOFTWARElalalandnode")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) , RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At D:workspaceScriptsUpdate.ps1:37 char:1
+ $RegistryValue = $RegKey.GetValue("HostAddress")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) , RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
To me it looks like an issue with authorization. I am not sure where I should provide the credentials.
Any ideas ?
powershell
add a comment |
I am trying to edit a registry key value on a remote VM running Windows 7.
I am using the following commands to do that:
$RegistryBase = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', "WIN-MONKU")
$RegKey= $RegistryBase.OpenSubKey("SOFTWARElalalandnode")
$RegistryValue = $RegKey.GetValue("HostAddress")
Write-Host "HostAddress: $RegistryValue"
But I am getting errors as:
Exception calling "OpenRemoteBaseKey" with "2" argument(s): "Attempted to perform an unauthorized operation."
At D:workspaceScriptsUpdate.ps1:35 char:1
+ $RegistryBase = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('Loc ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) , MethodInvocationException
+ FullyQualifiedErrorId : UnauthorizedAccessException
You cannot call a method on a null-valued expression.
At D:workspaceScriptsUpdate.ps1:36 char:1
+ $RegKey= $RegistryBase.OpenSubKey("SOFTWARElalalandnode")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) , RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At D:workspaceScriptsUpdate.ps1:37 char:1
+ $RegistryValue = $RegKey.GetValue("HostAddress")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) , RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
To me it looks like an issue with authorization. I am not sure where I should provide the credentials.
Any ideas ?
powershell
add a comment |
I am trying to edit a registry key value on a remote VM running Windows 7.
I am using the following commands to do that:
$RegistryBase = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', "WIN-MONKU")
$RegKey= $RegistryBase.OpenSubKey("SOFTWARElalalandnode")
$RegistryValue = $RegKey.GetValue("HostAddress")
Write-Host "HostAddress: $RegistryValue"
But I am getting errors as:
Exception calling "OpenRemoteBaseKey" with "2" argument(s): "Attempted to perform an unauthorized operation."
At D:workspaceScriptsUpdate.ps1:35 char:1
+ $RegistryBase = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('Loc ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) , MethodInvocationException
+ FullyQualifiedErrorId : UnauthorizedAccessException
You cannot call a method on a null-valued expression.
At D:workspaceScriptsUpdate.ps1:36 char:1
+ $RegKey= $RegistryBase.OpenSubKey("SOFTWARElalalandnode")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) , RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At D:workspaceScriptsUpdate.ps1:37 char:1
+ $RegistryValue = $RegKey.GetValue("HostAddress")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) , RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
To me it looks like an issue with authorization. I am not sure where I should provide the credentials.
Any ideas ?
powershell
I am trying to edit a registry key value on a remote VM running Windows 7.
I am using the following commands to do that:
$RegistryBase = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', "WIN-MONKU")
$RegKey= $RegistryBase.OpenSubKey("SOFTWARElalalandnode")
$RegistryValue = $RegKey.GetValue("HostAddress")
Write-Host "HostAddress: $RegistryValue"
But I am getting errors as:
Exception calling "OpenRemoteBaseKey" with "2" argument(s): "Attempted to perform an unauthorized operation."
At D:workspaceScriptsUpdate.ps1:35 char:1
+ $RegistryBase = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('Loc ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) , MethodInvocationException
+ FullyQualifiedErrorId : UnauthorizedAccessException
You cannot call a method on a null-valued expression.
At D:workspaceScriptsUpdate.ps1:36 char:1
+ $RegKey= $RegistryBase.OpenSubKey("SOFTWARElalalandnode")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) , RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At D:workspaceScriptsUpdate.ps1:37 char:1
+ $RegistryValue = $RegKey.GetValue("HostAddress")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) , RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
To me it looks like an issue with authorization. I am not sure where I should provide the credentials.
Any ideas ?
powershell
powershell
asked Nov 20 '18 at 21:16
MonkuMonku
68011121
68011121
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
You try wrapping that into a function and calling it with Invoke-Command
which has a -Credential
parameter:
Function Get-RemoteRegistryKey()
{
$RegistryBase = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', "WIN-MONKU")
$RegKey= $RegistryBase.OpenSubKey("SOFTWARElalalandnode")
$RegistryValue = $RegKey.GetValue("HostAddress")
Write-Host "HostAddress: $RegistryValue"
}
Invoke-Command { Get-RemoteRegistryKey } -ComputerName 'WIN-MONKU' -Credential $(Get-Credential)
Let me know if you get auth errors still
It gives me the following error: [WIN-GGSET2OBNLH] Connecting to remote server WIN-GGSET2OBNLH failed with the following error message : The user name or password is incorrect. For more information, see the about_Remote_Troubleshooting Help topic. + CategoryInfo : OpenError: (WIN-GGSET2OBNLH:String) , PSRemotingTransportException + FullyQualifiedErrorId : LogonFailure,PSSessionStateBroken Even though the username and password for the credentials are correct.
– Monku
Nov 20 '18 at 21:30
Are you experiencing the double hop issue? -- docs.microsoft.com/en-us/powershell/scripting/setup/…
– trebleCode
Nov 20 '18 at 21:31
Or what if you invoke powershell as administrator on the remote machine instead? See here for a partial explanation of that broken session state message: techtips.tv/powershell/…
– trebleCode
Nov 20 '18 at 21:34
I can't invoke powershell on remote computer. I want to access registry from my desktop pc.
– Monku
Nov 20 '18 at 21:58
What I meant was I want to edit registry keys that exist on remote computer from my desktop pc by running some powershell script from my desktop pc
– Monku
Nov 20 '18 at 23:29
|
show 1 more comment
You say...
'can't invoke powershell on remote computer. I want to access
registry from my desktop pc.'
Yet, your post title says...
'Editing Registry key on remote computer using Powershell'.
So, on your local PC, you have Hyper-V enabled and you have a Win7 guest, thus, this is a remote host. Making this assumption, you are not using a domain deployment, you need to enable PSRemoting using workgroup between you PC and your VM.
PowerShell remoting between two workgroup machines
# configure the machine to allow access.
Enable-PSRemoting –force
If one of the network cards on your computer has the network connection type set to “Public” then the required port won’t be opened in your firewall settings. If you’d rather not change your network connection type, you’ll have to manually configure your firewall to allow traffic through. If you plan on connecting using a specific port, be sure to set your firewall rules appropriately. If you’re just using the default ports, see this recent blog post to figure out which ports to open.
# configure the client machine.
Start-Service WinRM
Set-ItemProperty –Path HKLM:SOFTWAREMicrosoftWindowsCurrentVersionPoliciesSystem –Name LocalAccountTokenFilterPolicy –Value 1 –Type DWord
# running on Windows XP
Set-ItemProperty –Path HKLM:SystemCurrentControlSetControlLsa –Name ForceGuest –Value 0
add the name of your server machine to the TrustedHosts setting in the WinRM configuration,
which enables your client machine to connect to your server machine using an authentication
mechanism that does not authenticate the server (like Kerberos does):
Set-Item WSMan:localhostClientTrustedHosts –Value <ServerMachineName> -Force
# If there is an existing list of servers
Set-Item WSMan:localhostClientTrustedHosts –Value <ServerMachineName> -Force -Concatenate
If you want to use your server machine’s IP address instead of its name, you must specify explicit credentials when you connect.
A word of caution: by adding a server to the TrustedHosts list, you are allowing your credential information to be sent to a server without verifying its identity. Only add a server to this list if you know that the network path from your client machine to the server machine is secure.
# check if the WinRM service is running:
Get-Service WinRM
Test-WSMan –Auth default
winrm enumerate winrm/config/listener
# check the remoting configuration
Get-PSSessionConfiguration
New-PSSession
# check if the local account token filter policy is enabled
Get-ItemProperty –Path HKLM:SOFTWAREMicrosoftWindowsCurrentVersionPoliciesSystem –Name LocalAccountTokenFilterPolicy*
# check if the network access policy
Get-ItemProperty –Path HKLM:SystemCurrentControlSetControlLsa –Name ForceGuest*
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53401650%2fediting-registry-key-on-remote-computer-using-powershell%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You try wrapping that into a function and calling it with Invoke-Command
which has a -Credential
parameter:
Function Get-RemoteRegistryKey()
{
$RegistryBase = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', "WIN-MONKU")
$RegKey= $RegistryBase.OpenSubKey("SOFTWARElalalandnode")
$RegistryValue = $RegKey.GetValue("HostAddress")
Write-Host "HostAddress: $RegistryValue"
}
Invoke-Command { Get-RemoteRegistryKey } -ComputerName 'WIN-MONKU' -Credential $(Get-Credential)
Let me know if you get auth errors still
It gives me the following error: [WIN-GGSET2OBNLH] Connecting to remote server WIN-GGSET2OBNLH failed with the following error message : The user name or password is incorrect. For more information, see the about_Remote_Troubleshooting Help topic. + CategoryInfo : OpenError: (WIN-GGSET2OBNLH:String) , PSRemotingTransportException + FullyQualifiedErrorId : LogonFailure,PSSessionStateBroken Even though the username and password for the credentials are correct.
– Monku
Nov 20 '18 at 21:30
Are you experiencing the double hop issue? -- docs.microsoft.com/en-us/powershell/scripting/setup/…
– trebleCode
Nov 20 '18 at 21:31
Or what if you invoke powershell as administrator on the remote machine instead? See here for a partial explanation of that broken session state message: techtips.tv/powershell/…
– trebleCode
Nov 20 '18 at 21:34
I can't invoke powershell on remote computer. I want to access registry from my desktop pc.
– Monku
Nov 20 '18 at 21:58
What I meant was I want to edit registry keys that exist on remote computer from my desktop pc by running some powershell script from my desktop pc
– Monku
Nov 20 '18 at 23:29
|
show 1 more comment
You try wrapping that into a function and calling it with Invoke-Command
which has a -Credential
parameter:
Function Get-RemoteRegistryKey()
{
$RegistryBase = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', "WIN-MONKU")
$RegKey= $RegistryBase.OpenSubKey("SOFTWARElalalandnode")
$RegistryValue = $RegKey.GetValue("HostAddress")
Write-Host "HostAddress: $RegistryValue"
}
Invoke-Command { Get-RemoteRegistryKey } -ComputerName 'WIN-MONKU' -Credential $(Get-Credential)
Let me know if you get auth errors still
It gives me the following error: [WIN-GGSET2OBNLH] Connecting to remote server WIN-GGSET2OBNLH failed with the following error message : The user name or password is incorrect. For more information, see the about_Remote_Troubleshooting Help topic. + CategoryInfo : OpenError: (WIN-GGSET2OBNLH:String) , PSRemotingTransportException + FullyQualifiedErrorId : LogonFailure,PSSessionStateBroken Even though the username and password for the credentials are correct.
– Monku
Nov 20 '18 at 21:30
Are you experiencing the double hop issue? -- docs.microsoft.com/en-us/powershell/scripting/setup/…
– trebleCode
Nov 20 '18 at 21:31
Or what if you invoke powershell as administrator on the remote machine instead? See here for a partial explanation of that broken session state message: techtips.tv/powershell/…
– trebleCode
Nov 20 '18 at 21:34
I can't invoke powershell on remote computer. I want to access registry from my desktop pc.
– Monku
Nov 20 '18 at 21:58
What I meant was I want to edit registry keys that exist on remote computer from my desktop pc by running some powershell script from my desktop pc
– Monku
Nov 20 '18 at 23:29
|
show 1 more comment
You try wrapping that into a function and calling it with Invoke-Command
which has a -Credential
parameter:
Function Get-RemoteRegistryKey()
{
$RegistryBase = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', "WIN-MONKU")
$RegKey= $RegistryBase.OpenSubKey("SOFTWARElalalandnode")
$RegistryValue = $RegKey.GetValue("HostAddress")
Write-Host "HostAddress: $RegistryValue"
}
Invoke-Command { Get-RemoteRegistryKey } -ComputerName 'WIN-MONKU' -Credential $(Get-Credential)
Let me know if you get auth errors still
You try wrapping that into a function and calling it with Invoke-Command
which has a -Credential
parameter:
Function Get-RemoteRegistryKey()
{
$RegistryBase = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', "WIN-MONKU")
$RegKey= $RegistryBase.OpenSubKey("SOFTWARElalalandnode")
$RegistryValue = $RegKey.GetValue("HostAddress")
Write-Host "HostAddress: $RegistryValue"
}
Invoke-Command { Get-RemoteRegistryKey } -ComputerName 'WIN-MONKU' -Credential $(Get-Credential)
Let me know if you get auth errors still
answered Nov 20 '18 at 21:26
trebleCodetrebleCode
689515
689515
It gives me the following error: [WIN-GGSET2OBNLH] Connecting to remote server WIN-GGSET2OBNLH failed with the following error message : The user name or password is incorrect. For more information, see the about_Remote_Troubleshooting Help topic. + CategoryInfo : OpenError: (WIN-GGSET2OBNLH:String) , PSRemotingTransportException + FullyQualifiedErrorId : LogonFailure,PSSessionStateBroken Even though the username and password for the credentials are correct.
– Monku
Nov 20 '18 at 21:30
Are you experiencing the double hop issue? -- docs.microsoft.com/en-us/powershell/scripting/setup/…
– trebleCode
Nov 20 '18 at 21:31
Or what if you invoke powershell as administrator on the remote machine instead? See here for a partial explanation of that broken session state message: techtips.tv/powershell/…
– trebleCode
Nov 20 '18 at 21:34
I can't invoke powershell on remote computer. I want to access registry from my desktop pc.
– Monku
Nov 20 '18 at 21:58
What I meant was I want to edit registry keys that exist on remote computer from my desktop pc by running some powershell script from my desktop pc
– Monku
Nov 20 '18 at 23:29
|
show 1 more comment
It gives me the following error: [WIN-GGSET2OBNLH] Connecting to remote server WIN-GGSET2OBNLH failed with the following error message : The user name or password is incorrect. For more information, see the about_Remote_Troubleshooting Help topic. + CategoryInfo : OpenError: (WIN-GGSET2OBNLH:String) , PSRemotingTransportException + FullyQualifiedErrorId : LogonFailure,PSSessionStateBroken Even though the username and password for the credentials are correct.
– Monku
Nov 20 '18 at 21:30
Are you experiencing the double hop issue? -- docs.microsoft.com/en-us/powershell/scripting/setup/…
– trebleCode
Nov 20 '18 at 21:31
Or what if you invoke powershell as administrator on the remote machine instead? See here for a partial explanation of that broken session state message: techtips.tv/powershell/…
– trebleCode
Nov 20 '18 at 21:34
I can't invoke powershell on remote computer. I want to access registry from my desktop pc.
– Monku
Nov 20 '18 at 21:58
What I meant was I want to edit registry keys that exist on remote computer from my desktop pc by running some powershell script from my desktop pc
– Monku
Nov 20 '18 at 23:29
It gives me the following error: [WIN-GGSET2OBNLH] Connecting to remote server WIN-GGSET2OBNLH failed with the following error message : The user name or password is incorrect. For more information, see the about_Remote_Troubleshooting Help topic. + CategoryInfo : OpenError: (WIN-GGSET2OBNLH:String) , PSRemotingTransportException + FullyQualifiedErrorId : LogonFailure,PSSessionStateBroken Even though the username and password for the credentials are correct.
– Monku
Nov 20 '18 at 21:30
It gives me the following error: [WIN-GGSET2OBNLH] Connecting to remote server WIN-GGSET2OBNLH failed with the following error message : The user name or password is incorrect. For more information, see the about_Remote_Troubleshooting Help topic. + CategoryInfo : OpenError: (WIN-GGSET2OBNLH:String) , PSRemotingTransportException + FullyQualifiedErrorId : LogonFailure,PSSessionStateBroken Even though the username and password for the credentials are correct.
– Monku
Nov 20 '18 at 21:30
Are you experiencing the double hop issue? -- docs.microsoft.com/en-us/powershell/scripting/setup/…
– trebleCode
Nov 20 '18 at 21:31
Are you experiencing the double hop issue? -- docs.microsoft.com/en-us/powershell/scripting/setup/…
– trebleCode
Nov 20 '18 at 21:31
Or what if you invoke powershell as administrator on the remote machine instead? See here for a partial explanation of that broken session state message: techtips.tv/powershell/…
– trebleCode
Nov 20 '18 at 21:34
Or what if you invoke powershell as administrator on the remote machine instead? See here for a partial explanation of that broken session state message: techtips.tv/powershell/…
– trebleCode
Nov 20 '18 at 21:34
I can't invoke powershell on remote computer. I want to access registry from my desktop pc.
– Monku
Nov 20 '18 at 21:58
I can't invoke powershell on remote computer. I want to access registry from my desktop pc.
– Monku
Nov 20 '18 at 21:58
What I meant was I want to edit registry keys that exist on remote computer from my desktop pc by running some powershell script from my desktop pc
– Monku
Nov 20 '18 at 23:29
What I meant was I want to edit registry keys that exist on remote computer from my desktop pc by running some powershell script from my desktop pc
– Monku
Nov 20 '18 at 23:29
|
show 1 more comment
You say...
'can't invoke powershell on remote computer. I want to access
registry from my desktop pc.'
Yet, your post title says...
'Editing Registry key on remote computer using Powershell'.
So, on your local PC, you have Hyper-V enabled and you have a Win7 guest, thus, this is a remote host. Making this assumption, you are not using a domain deployment, you need to enable PSRemoting using workgroup between you PC and your VM.
PowerShell remoting between two workgroup machines
# configure the machine to allow access.
Enable-PSRemoting –force
If one of the network cards on your computer has the network connection type set to “Public” then the required port won’t be opened in your firewall settings. If you’d rather not change your network connection type, you’ll have to manually configure your firewall to allow traffic through. If you plan on connecting using a specific port, be sure to set your firewall rules appropriately. If you’re just using the default ports, see this recent blog post to figure out which ports to open.
# configure the client machine.
Start-Service WinRM
Set-ItemProperty –Path HKLM:SOFTWAREMicrosoftWindowsCurrentVersionPoliciesSystem –Name LocalAccountTokenFilterPolicy –Value 1 –Type DWord
# running on Windows XP
Set-ItemProperty –Path HKLM:SystemCurrentControlSetControlLsa –Name ForceGuest –Value 0
add the name of your server machine to the TrustedHosts setting in the WinRM configuration,
which enables your client machine to connect to your server machine using an authentication
mechanism that does not authenticate the server (like Kerberos does):
Set-Item WSMan:localhostClientTrustedHosts –Value <ServerMachineName> -Force
# If there is an existing list of servers
Set-Item WSMan:localhostClientTrustedHosts –Value <ServerMachineName> -Force -Concatenate
If you want to use your server machine’s IP address instead of its name, you must specify explicit credentials when you connect.
A word of caution: by adding a server to the TrustedHosts list, you are allowing your credential information to be sent to a server without verifying its identity. Only add a server to this list if you know that the network path from your client machine to the server machine is secure.
# check if the WinRM service is running:
Get-Service WinRM
Test-WSMan –Auth default
winrm enumerate winrm/config/listener
# check the remoting configuration
Get-PSSessionConfiguration
New-PSSession
# check if the local account token filter policy is enabled
Get-ItemProperty –Path HKLM:SOFTWAREMicrosoftWindowsCurrentVersionPoliciesSystem –Name LocalAccountTokenFilterPolicy*
# check if the network access policy
Get-ItemProperty –Path HKLM:SystemCurrentControlSetControlLsa –Name ForceGuest*
add a comment |
You say...
'can't invoke powershell on remote computer. I want to access
registry from my desktop pc.'
Yet, your post title says...
'Editing Registry key on remote computer using Powershell'.
So, on your local PC, you have Hyper-V enabled and you have a Win7 guest, thus, this is a remote host. Making this assumption, you are not using a domain deployment, you need to enable PSRemoting using workgroup between you PC and your VM.
PowerShell remoting between two workgroup machines
# configure the machine to allow access.
Enable-PSRemoting –force
If one of the network cards on your computer has the network connection type set to “Public” then the required port won’t be opened in your firewall settings. If you’d rather not change your network connection type, you’ll have to manually configure your firewall to allow traffic through. If you plan on connecting using a specific port, be sure to set your firewall rules appropriately. If you’re just using the default ports, see this recent blog post to figure out which ports to open.
# configure the client machine.
Start-Service WinRM
Set-ItemProperty –Path HKLM:SOFTWAREMicrosoftWindowsCurrentVersionPoliciesSystem –Name LocalAccountTokenFilterPolicy –Value 1 –Type DWord
# running on Windows XP
Set-ItemProperty –Path HKLM:SystemCurrentControlSetControlLsa –Name ForceGuest –Value 0
add the name of your server machine to the TrustedHosts setting in the WinRM configuration,
which enables your client machine to connect to your server machine using an authentication
mechanism that does not authenticate the server (like Kerberos does):
Set-Item WSMan:localhostClientTrustedHosts –Value <ServerMachineName> -Force
# If there is an existing list of servers
Set-Item WSMan:localhostClientTrustedHosts –Value <ServerMachineName> -Force -Concatenate
If you want to use your server machine’s IP address instead of its name, you must specify explicit credentials when you connect.
A word of caution: by adding a server to the TrustedHosts list, you are allowing your credential information to be sent to a server without verifying its identity. Only add a server to this list if you know that the network path from your client machine to the server machine is secure.
# check if the WinRM service is running:
Get-Service WinRM
Test-WSMan –Auth default
winrm enumerate winrm/config/listener
# check the remoting configuration
Get-PSSessionConfiguration
New-PSSession
# check if the local account token filter policy is enabled
Get-ItemProperty –Path HKLM:SOFTWAREMicrosoftWindowsCurrentVersionPoliciesSystem –Name LocalAccountTokenFilterPolicy*
# check if the network access policy
Get-ItemProperty –Path HKLM:SystemCurrentControlSetControlLsa –Name ForceGuest*
add a comment |
You say...
'can't invoke powershell on remote computer. I want to access
registry from my desktop pc.'
Yet, your post title says...
'Editing Registry key on remote computer using Powershell'.
So, on your local PC, you have Hyper-V enabled and you have a Win7 guest, thus, this is a remote host. Making this assumption, you are not using a domain deployment, you need to enable PSRemoting using workgroup between you PC and your VM.
PowerShell remoting between two workgroup machines
# configure the machine to allow access.
Enable-PSRemoting –force
If one of the network cards on your computer has the network connection type set to “Public” then the required port won’t be opened in your firewall settings. If you’d rather not change your network connection type, you’ll have to manually configure your firewall to allow traffic through. If you plan on connecting using a specific port, be sure to set your firewall rules appropriately. If you’re just using the default ports, see this recent blog post to figure out which ports to open.
# configure the client machine.
Start-Service WinRM
Set-ItemProperty –Path HKLM:SOFTWAREMicrosoftWindowsCurrentVersionPoliciesSystem –Name LocalAccountTokenFilterPolicy –Value 1 –Type DWord
# running on Windows XP
Set-ItemProperty –Path HKLM:SystemCurrentControlSetControlLsa –Name ForceGuest –Value 0
add the name of your server machine to the TrustedHosts setting in the WinRM configuration,
which enables your client machine to connect to your server machine using an authentication
mechanism that does not authenticate the server (like Kerberos does):
Set-Item WSMan:localhostClientTrustedHosts –Value <ServerMachineName> -Force
# If there is an existing list of servers
Set-Item WSMan:localhostClientTrustedHosts –Value <ServerMachineName> -Force -Concatenate
If you want to use your server machine’s IP address instead of its name, you must specify explicit credentials when you connect.
A word of caution: by adding a server to the TrustedHosts list, you are allowing your credential information to be sent to a server without verifying its identity. Only add a server to this list if you know that the network path from your client machine to the server machine is secure.
# check if the WinRM service is running:
Get-Service WinRM
Test-WSMan –Auth default
winrm enumerate winrm/config/listener
# check the remoting configuration
Get-PSSessionConfiguration
New-PSSession
# check if the local account token filter policy is enabled
Get-ItemProperty –Path HKLM:SOFTWAREMicrosoftWindowsCurrentVersionPoliciesSystem –Name LocalAccountTokenFilterPolicy*
# check if the network access policy
Get-ItemProperty –Path HKLM:SystemCurrentControlSetControlLsa –Name ForceGuest*
You say...
'can't invoke powershell on remote computer. I want to access
registry from my desktop pc.'
Yet, your post title says...
'Editing Registry key on remote computer using Powershell'.
So, on your local PC, you have Hyper-V enabled and you have a Win7 guest, thus, this is a remote host. Making this assumption, you are not using a domain deployment, you need to enable PSRemoting using workgroup between you PC and your VM.
PowerShell remoting between two workgroup machines
# configure the machine to allow access.
Enable-PSRemoting –force
If one of the network cards on your computer has the network connection type set to “Public” then the required port won’t be opened in your firewall settings. If you’d rather not change your network connection type, you’ll have to manually configure your firewall to allow traffic through. If you plan on connecting using a specific port, be sure to set your firewall rules appropriately. If you’re just using the default ports, see this recent blog post to figure out which ports to open.
# configure the client machine.
Start-Service WinRM
Set-ItemProperty –Path HKLM:SOFTWAREMicrosoftWindowsCurrentVersionPoliciesSystem –Name LocalAccountTokenFilterPolicy –Value 1 –Type DWord
# running on Windows XP
Set-ItemProperty –Path HKLM:SystemCurrentControlSetControlLsa –Name ForceGuest –Value 0
add the name of your server machine to the TrustedHosts setting in the WinRM configuration,
which enables your client machine to connect to your server machine using an authentication
mechanism that does not authenticate the server (like Kerberos does):
Set-Item WSMan:localhostClientTrustedHosts –Value <ServerMachineName> -Force
# If there is an existing list of servers
Set-Item WSMan:localhostClientTrustedHosts –Value <ServerMachineName> -Force -Concatenate
If you want to use your server machine’s IP address instead of its name, you must specify explicit credentials when you connect.
A word of caution: by adding a server to the TrustedHosts list, you are allowing your credential information to be sent to a server without verifying its identity. Only add a server to this list if you know that the network path from your client machine to the server machine is secure.
# check if the WinRM service is running:
Get-Service WinRM
Test-WSMan –Auth default
winrm enumerate winrm/config/listener
# check the remoting configuration
Get-PSSessionConfiguration
New-PSSession
# check if the local account token filter policy is enabled
Get-ItemProperty –Path HKLM:SOFTWAREMicrosoftWindowsCurrentVersionPoliciesSystem –Name LocalAccountTokenFilterPolicy*
# check if the network access policy
Get-ItemProperty –Path HKLM:SystemCurrentControlSetControlLsa –Name ForceGuest*
answered Nov 20 '18 at 23:25
postanotepostanote
3,3532410
3,3532410
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53401650%2fediting-registry-key-on-remote-computer-using-powershell%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown