Closed Ryssk closed 2 weeks ago
When you use Invoke-Command
with -ComputerName
it connects to a registered PSSessionConfiguration under a specific name. The default configuration is Microsoft.PowerShell
which is the PSSession registered for Windows PowerShell 5.1. You can see this by running Invoke-Command -ComputerName foo { $PSVersionTable.PSVersion }
and see it will be for 5.1 and not 7.4.1.
While Set-Service
on Windows PowerShell 5.1 did have a -StartupType
parameter the AutomaticDelayedStart
was added in version in PowerShell 7.x. To use this startup type you'll either have to
PowerShell.7
configuration with the -ConfigurationName
parameter on Invoke-Command
sc.exe
to set the startup type to automatic delayed startThe PowerShell.7
configuration will only exist on the remote host if you installed PowerShell 7 and registered the session configuration with Enable-PSRemoting
on PowerShell 7. You can see what configurations are available by running as admin Get-PSSessionConfiguration
in PowerShell 7 on the target host.
This issue has been marked as answered and has not had any activity for 1 day. It has been closed for housekeeping purposes.
📣 Hey @Ryssk, how did we do? We would love to hear your feedback with the link below! 🗣️
🔗 https://aka.ms/PSRepoFeedback
Prerequisites
Steps to reproduce
Hi, seems like an issue with using StartupType AutomaticDelayedStart on 7.4.1 while running Invoke-Command, checking the enum i only get the following options aswell. Is it due to running it inside a Scriptblock?
Boot System Automatic Manual Disabled
According to the FAQ it should be working: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/set-service?view=powershell-7.4#-startuptype
Expected behavior
Actual behavior
Error details
No response
Environment data
Visuals
No response