Skip to content

vrimkus/Use-Impersonation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

PowerShell wrapper around C# SimpleImpersonation.

Designed to emulate C# using syntax with impersonation.

#### This option allows specifying a string to -Credential, which will display the credential prompt.
Use-Impersonation -Credential DOMAIN\user -LogonType Batch {     
    sqlps
    $as = New-Object Microsoft.AnalysisServices.Server  
    $as.connect("server-name\instance-name")  
    $as.serverproperties  
}

Or

#### this will display a Get-Credential prompt for interactive usage
Use-Impersonation ('DOMAIN\user', 'Interactive') { 
    "You are now impersonating user $([System.Security.Principal.WindowsIdentity]::GetCurrent().Name)"
}

#### OR for clear text Parameter Signature 
Use-Impersonation ('DOMAIN', 'user', 'password', 'Interactive') { 
    "You are now impersonating user $([System.Security.Principal.WindowsIdentity]::GetCurrent().Name)"
}

About

PowerShell SimpleImpersonation wrapper

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published