If you want to run a PowerShell CmdLet that requires elevation on Linux or OSx from a non elevated PowerShell session, you might need to use sudo.
The three lines below allows you to pass PowerShell’s Get-Credential to sudo, which will elevate the next PowerShell CmdLet you want to run.
$credential = Get-Credential -message 'Enter Credential' -username bentaylor
$credential.GetNetworkCredential().password | sudo -U $credential.username -l -S
sudo powershell Set-Date -date 2016-08-01
Note: You have to invoke a new PowerShell session to elevate the CmdLet as PowerShell is run in memory.
If you want to assign the results of a CmdLet that was elevated with sudo to a variable the results are returned as a string and not an object. The reason is not sudo but how PowerShell returns its results back (This will include data written to any stream like verbose etc).