Skip to content

[Suggestion] Accept ComputerName #2

@Beef84

Description

@Beef84

Hello,

You can accept -ComputerName in Invoke-GMSACommand and then do this so it works locally and remotely:

if("$ComputerName" -eq "$env:computername")
    {
        [SimpleImpersonation.Impersonation]::RunAsUser(
            $SCred,
            $LogonType, 
            [System.Action]{ $Script:CommandOutput = Invoke-Command -ScriptBlock $ScriptBlock -ArgumentList $ArgumentList }
        )
    }
    else
    {
        [SimpleImpersonation.Impersonation]::RunAsUser(
            $SCred,
            $LogonType, 
            [System.Action]{ $Script:CommandOutput = Invoke-Command -ComputerName $ComputerName -ScriptBlock $ScriptBlock -ArgumentList $ArgumentList }
        )
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions