I have tried several methods to start the service remotely but none of them work.
So, i try to start Windows Service (TeamViewer) from PC1 (192.168.1.10) on PC2 (192.168.1.20).
All PC are on Windows 10 Pro.
Ping 192.168.1.20 OK
RDP 192.168.1.20 OK
CMD in mode Administrator
C:\WINDOWS\system32>net use \\192.168.1.20 pass /USER:login
La commande s’est terminée correctement.
C:\WINDOWS\system32>net use
Les nouvelles connexions seront mémorisées.
État Local Distant Réseau
-------------------------------------------------------------------------------
OK \\192.168.1.20\IPC$ Microsoft Windows Network
La commande s’est terminée correctement.
C:\WINDOWS\system32>sc \\192.168.1.20 query TeamViewer
[SC] EnumQueryServicesStatus:OpenService échec(s) 5 :
Accès refusé.
C:\WINDOWS\system32>sc \\192.168.1.20 start TeamViewer
[SC] StartService: OpenService échec(s) 5 :
Accès refusé.
C:\WINDOWS\system32>psexec \\192.168.1.20 -u login -p pass start TeamViewer
PsExec v2.2 - Execute processes remotely
Copyright (C) 2001-2016 Mark Russinovich
Sysinternals - www.sysinternals.com
Couldn't access 192.168.1.20:
AccÞs refusÚ.
C:\WINDOWS\system32>psservice \\192.168.1.20 -u 192.168.1.20\login -p pass start TeamViewer
PsService v1.20 - Service information and configuration utility
Copyright (C) 2001-2010 Mark Russinovich
Sysinternals - www.sysinternals.com
Error querying services on \\192.168.1.20:
AccÞs refusÚ.
Error opening TeamViewer on \\192.168.1.20:
AccÞs refusÚ.
C:\WINDOWS\system32>psservice \\192.168.1.20 -u 192.168.1.20\login -p pass start TeamViewer
C:\WINDOWS\system32>
C:\WINDOWS\system32>
C:\WINDOWS\system32>wmic /node:'192.168.1.20' /user:'192.168.1.20\login' /password:'pass' SERVICE WHERE CAPTION='TeamViewer' CALL STARTSERVICE
ERREUR :
Description = Accès refusé.
C:\WINDOWS\system32>psservice \\192.168.1.20 -u 192.168.1.20\login -p pass start TeamViewer
PsService v1.20 - Service information and configuration utility
Copyright (C) 2001-2010 Mark Russinovich
Sysinternals - www.sysinternals.com
Error querying services on \\192.168.1.20:
AccÞs refusÚ.
Error opening TeamViewer on \\192.168.1.20:
AccÞs refusÚ.
Powershell in mode Administrator
PS C:\WINDOWS\system32> Get-Service -ComputerName 192.168.1.20 -Name Apache-ignite | Stop-Service -Force
>>
Get-Service : Impossible de trouver un service assorti du nom « Apache-ignite ».
Au caractère Ligne:1 : 1
+ Get-Service -ComputerName 192.168.1.20 -Name Apache-ignite | Stop-Ser ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Apache-ignite:String) [Get-Service], ServiceCommandException
+ FullyQualifiedErrorId : NoServiceFoundForGivenName,Microsoft.PowerShell.Commands.GetServiceCommand
Thanks for your help.
Add registry HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System
LocalAccountTokenFilterPolicy
DWORD Value 1
Related
I need to configure ssh on Windows for an Angular project that has dependencies that are being accessed with ssh. I have already generated the keys with ssh-keygen -t ed25519 but... when I go to enable the ssh-agent service in PowerShell by running:
Get-Service ssh-agent | Set-Service -StartupType Manual
I get the following error:
Set-Service : No se puede configurar el servicio 'OpenSSH Authentication Agent (ssh-agent)'
debido al error siguiente:
Acceso denegado
En línea: 1 Carácter: 25
+ Get-Service ssh-agent | Set-Service -StartupType Manual
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied:
(System.ServiceProcess.ServiceController:ServiceController) [Set-Servi
ce], ServiceCommandException
+ FullyQualifiedErrorId : CouldNotSetService,Microsoft.PowerShell.Commands.SetServiceCommand
How can i solve this?
I am trying to manage a Windows server 2012 R2 Standard server over winrm. On the server I would like to run dnscmd from the rsat package. You can see below if I just run the dnscmd in the power shell prompt it is successful. However when I invoke it remotely over winrm the command fails with ERROR_ACCESS_DENIED.
PS C:\Windows\system32> dnscmd adServer /RecordDelete mycompany.com newTestRecord A /f
Deleted A record(s) at mycompany.com
Command completed successfully.
PS C:\Windows\system32> Test-WsMan localhost
wsmid : http://schemas.dmtf.org/wbem/wsman/identity/1/wsmanidentity.xsd
ProtocolVersion : http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd
ProductVendor : Microsoft Corporation
ProductVersion : OS: 0.0.0 SP: 0.0 Stack: 3.0
PS C:\Windows\system32> Invoke-Command -ComputerName localhost -ScriptBlock {
>> dnscmd adServer /RecordDelete mycompany.com newTestRecord A /f
>> }
Command failed: ERROR_ACCESS_DENIED 5 0x5
PS C:\Windows\system32> Invoke-Command -ComputerName localhost -ScriptBlock {
>> hostname
>> }
myServerHostname
The issue was double-hop/multi-hop. When you login over winRM it doesn't want to allow you to use the same credential token to reach to a different machine. I got around this issue by connecting over winrm then opening up a nested Powershell session. It's essentially refreshes the tokens allowing the user to connect to the active directory server.
Please see the following for more information
https://blogs.technet.microsoft.com/ashleymcglone/2016/08/30/powershell-remoting-kerberos-double-hop-solved-securely/
https://blogs.msdn.microsoft.com/sergey_babkins_blog/2015/03/18/another-solution-to-multi-hop-powershell-remoting/
Make sure to install Remote Server Administration Tools (RSAT) for dnscmd.
$password = '{pass}' | ConvertTo-SecureString -AsPlainText -Force
$username = '{user}'
$cred = New-Object System.Management.Automation.PSCredential -ArgumentList $username,$password
Invoke-Command -ComputerName localhost -Credential $cred -ConfigurationName svc_dns_middleMan -ScriptBlock {
'{dnscmd_commands}'
}
I have an installed Windows Server 2016 Technical Preview 4 on VMware
Warkstation.
It has 2 GB RAM and 60 GB disk space.
I try to install Windows Server Host for Docker according to official Microsoft instruction.
Instruction in general in the picture
I don't need a Hyper-V Containers technology so for this guide i don't have to make steps marked with a one asterisk '*'
So we have six steps that we have to do for install Windows Server Host and Docker:
Install the Container Feature
Create Virtual Switch
Configure NAT
Configure MAC Address Spoofing
Install Container OS Images
Install Docker **
I have a problem in step two: Creat Virtual Switch while typing next cmdlet in PowerShell:
PS C:\> New-VMSwitch -Name "Virtual Switch" -SwitchType NAT -NATSubnetAddress 172.16.0.0/12
New-VMSwitch : Failed while adding virtual Ethernet switch connections.
Internal miniport create failed, name = '8A407781-1BF5-4BB0-8538-35CFF056C598', friendly name = 'vEthernet (Virtual Switch)', MAC = 'DYNAMIC': One or more arguments are invalid
(0x80070057).
At line:1 char:1
+ New-VMSwitch -Name "Virtual Switch" -SwitchType NAT -NATSubnetAddress ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [New-VMSwitch], VirtualizationException
+ FullyQualifiedErrorId : InvalidParameter,Microsoft.HyperV.PowerShell.Commands.NewVMSwitch
What should I do in this case?
I was able to install docker using Microsoft guide about auto-install instead of using manual guide:
# Auto-install instruction.
PS C:\> powershell.exe
PS C:\> start-process powershell -Verb runas
PS C:\> wget -uri https://aka.ms/tp4/Install-ContainerHost -OutFile C:\Install-ContainerHost.ps1
PS C:\> C:\Install-ContainerHost.ps1 -HyperV
# Wrong!
But there is an error in the last line in key -HyperV.
We need to ingore it, so the last line looks like:
PS C:\> powershell.exe
PS C:\> start-process powershell -Verb runas
PS C:\> wget -uri https://aka.ms/tp4/Install-ContainerHost -OutFile C:\Install-ContainerHost.ps1
PS C:\> C:\Install-ContainerHost.ps1
# Currect!
Using correct instruction i was able to install docker.
I had the same error on a Nano Server the first time I ran:
PS C:\> New-VMSwitch -Name "Virtual Switch" -SwitchType NAT -NATSubnetAddress 172.16.0.0/12
SwitchType NAT is definitely correct because the command doesn't accept the NATSubnetAddress parameter for anything other then a NAT switchtype.
Run it a second time and then it worked on my Nano Server.
I have written a powershell script which creates a powershell script or a batch script depending on the remote host on which this script should be started remotely (either via powershell invoke-command or psexec).
The script creates either a powershell or a batch script, because not all hosts on which these created scripts should be run support WinRM (Windows Remote Management).
The created scripts include some psexec lines which executes a command on another remote host. The created batch script works as expected, but from the created powershell script i get the following errors from the psexec calls.
NotSpecified: (:String) [], RemoteException
+ CategoryInfo : NotSpecified: (:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
+ PSComputerName : <HOSTNAME REPLACED>
PsExec v2.1 - Execute processes remotely
Copyright (C) 2001-2013 Mark Russinovich
Sysinternals - www.sysinternals.com
The handle is invalid.
Access is denied.
Connecting to 10.XXX.XXX.127...Couldn't access 10.XXX.XXX.127:
Starting PSEXESVC service on 10.XXX.XXX.127...Could not start PSEXESVC service on 10.XXX.XXX.127:
Connecting to 10.XXX.XXX.127...Starting PSEXESVC service on 10.XXX.XXX.127...
Here is a small overview of what is done:
Powershell script on deployment host creates the rollout script (ps1 or batch) depending on the destination host
Powershell script on deployment host starts the created rollout script on the destination host
Powershell will be started via Invoke-Command -ComputerName <destination host> -FilePath <path to created script> -Authentication default
Batch will be started via & psexec.exe \\<destination host> -n 60 -accepteula -c -f <path to created script>
Created rollout script on the destination host executes a psexec command to start a service on a third host (this fails only if the rollout script is powershell)
This is the psexec command which fails if executed via a remotely started powershell script.
& psexec.exe \\<destination host> -n 60 -accepteula -u <user> -p <password> net stop <servicename>
The same command psexec.exe \\<destination host> -n 60 -accepteula -u <user> -p <password> net stop <servicename> executed via a remotely started batch script works without problems.
Update #1
Also if i connect to the destination host with rdp and start a powershell shell and paste the command it works without issues. The problem only occurs if started remotely.
I already tried the following variants of starting psexec, all without luck!
& psexec.exe \\<destination host> -n 60 -accepteula -s -u <user> -p <password> net stop <servicename>
Start-Process cmd.exe -Credential "<domain>\<user>" -WorkingDirectory $env:systemdrive -ArgumentList "/C psexec.exe \\<destination host> -n 60 -accepteula -u <user> -p <password> net stop <servicename>"
Start-Process powershell.exe -WorkingDirectory $env:systemdrive -Verb Runas -ArgumentList "cmd.exe /C psexec.exe \\<destination host> -n 60 -accepteula -u <user> -p <password> net stop <servicename>"
can you try to replace your psexec command, and use cmd.exe like thisn also add -s to psexec so it will run as system user. My testing command :
icm -cn computer1 -ScriptBlock{ cmd.exe "/c psexec -s -u <login> -p <password> /accepteula /n 10 \\computer2 net start audiosrv"}
You are running into the Second Hop problem:
http://blogs.technet.com/b/heyscriptingguy/archive/2012/11/14/enable-powershell-quot-second-hop-quot-functionality-with-credssp.aspx
The answer is to enable the appropriate relationship between the two computers involved (see previous link or just search google for 'powershell' and 'second hop') and to add to Invoke-Command:
-Authentication Credssp -Credential
What worked for me was:
Start-Process -FilePath .\PsExec.exe -ArgumentList "/acceptEula /s \$Computer program.exe /arg"
I need execute some script in remote computer, I try to start notepad. I use psexec, this command
psexec -e -i 1 \\localhost -u domain\user -p password cmd /c notepad.exe
successfully opens notepad on my local machine, but doesn't do it on remote.
I can't see any error, output is the same as I see after executing on local machine:
PsExec v2.0 - Execute processes remotely
Copyright (C) 2001-2013 Mark Russinovich
Sysinternals - www.sysinternals.com
What could be a reason I can't execute notepad successfully on remote machine?
To start notepad on remote machine using psexec:
psexec \\RemoteserverHOSTNAMEorIPADDRESS -u domain\user -p password -d -i cmd /c notepad.exe
For more information.....PsExec