Flow action - PowerShell - run cmdlets for DhcpServer as different user

Michal Fisera
Tera Expert

Hello everyone, 

I am facing a challenge to run few DHCPServer module (DhcpServer Module | Microsoft Learn)  cmdlets via PowerShell as a user, which has the necessary access to run them on target DHCP servers.

It is Get-DhcpServerv4FreeIPAddress and Add-DhcpServerv4Reservation 

 

I've validated, that if I will start PowerShell as that DHCP user, I am able to run it these cmdlets with success, but when I try to implement it to Flow action, it fails.

 

These cmdlets don't have -Credential option , so it needs to be triggered with a different way.

 

I've tried multiple combinations with MID Script files and inline script with hardcoded username and password, even to run it with credential alias with defined Host / Port and various Remoting Types. 

I've also tried to store the file on MID server and initiate the it from Flow action with Invoke-Command.

 

Another try was with Script-Job using script block. 

The most of the runs failed with "access denied" or errors within the run. 

 

If I want to "simulate" the run as different user, should I define it in the Connection details, or in the script directly?

Is there some universal block for that?

 

Thanks for any hint!

0 REPLIES 0