How to Run Elevated Commands in PSSession from Mac to Windows?

0
2
Asked By TechieNinja42 On

I've set up SSH key-based authentication between my M1 MacBook and a Windows machine for testing. I thought connecting with my elevated credentials would let me run elevated commands, like `New-PSDrive`, but it hasn't worked out.

Here's the context: my public key is in the `administrators_authorized_keys` file, and I'm logging in with a user account that has admin privileges, which typically allows elevated operations in an RDP session without needing to run PowerShell as an administrator.

However, when I try using the `-RunAsAdministrator` parameter with `Enter-PSSession`, I get an error message saying it can't resolve the parameter set. I've gone through the help files and consulted some colleagues who are experienced with PowerShell, but we're stumped.

Additionally, I need to use the ConfigurationManager module, which isn't available for macOS. Has anyone encountered a similar issue or have alternative solutions for this? I also figured out I need to specify the `-Credential` parameter for `New-PSDrive`. Thanks!

3 Answers

Answered By ITGnome77 On

It might not be purely an admin issue. Since you're using PS7, there could be a compatibility problem since most versions of Configuration Manager support Windows PowerShell 5.1. This might lead to a double-hop issue, which could affect your remote sessions when using SSH.

Answered By MacTechie25 On

Hey, I'm a bit confused about the connection direction. Are you connecting from the Windows machine to your Mac, or the other way around? If it’s from Windows to the Mac, remember that macOS is Unix-based, so the elevated access you mentioned might not apply in the same way. You would need to SSH into your user account and use `sudo` for commands that require elevation. Just checking, since it's been a while since I used a Mac!

Answered By CuriousCoder99 On

When you SSH into the Windows machine, you shouldn't need the `-RunAsAdministrator` switch. Your account should already be elevated when it connects to the device. Are you sure it's an elevation issue?

TechieNinja42 -

That's what I thought too! But unfortunately, that hasn’t been the case. Just to clarify, I’m using PowerShell 7 on both my macOS and the remote Windows.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.