Remote PowerShell Profiles
In the last article, I explained where PowerShell profile scripts come from and how to use them. There is, however, one area where you might make a wrong assumption about profiles. When you use PowerShell remoting to connect to a remote machine, you still connect to a PowerShell host. This host is called ServerRemoteHost
and runs in a wsmprovhost
process. For better or worse, this host is not configured to recognize or utilize profile scripts.
The $profile
variable has no value in a remoting session. You might think that because you use roaming user profiles, your PowerShell profile script will follow you. That is not true.
Note: This behavior is also true when using PowerShell remoting over ssh in PowerShell 7. The PowerShell host name is still
ServerRemoteHost,
even though the session is hosted in apwsh
process.