Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #https://www.reddit.com/r/PowerShell/comments/4fp0ut/what_are_you_using_in_your_powershell_profile/
- ## Create Credential Out-Files
- Function Set-CredentialFile {
- Param (
- [parameter(Position=0, ParameterSetName="PrivilegedAccount")]
- [switch]$PrivilegedAccount,
- [parameter(Position=0, ParameterSetName="CloudAccount")]
- [switch]$CloudAccount
- )
- If ($PrivilegedAccount) {Read-Host -Prompt "Enter your privileged account password" -AsSecureString | ConvertFrom-SecureString | Out-File "$($env:userprofile)\filename_priv.txt"}
- ElseIf ($CloudAccount) {Read-Host -Prompt "Enter your cloud admin account password" -AsSecureString | ConvertFrom-SecureString | Out-File "$($env:userprofile)\filename.txt"}
- If (!$PrivilegedAccount -and !$CloudAccount) {
- Write-Warning "You must use '-PrivilegedAccount' or '-CloudAccount' to update a credential file(s)."
- }
- }
- ## Start Explorer As Admin
- Function Start-ExplorerAsAdmin {
- $Credential = New-Object -TypeName System.Management.Automation.PsCredential -ArgumentList "domain\username",(Get-Content "$($env:userprofile)\filename_priv.txt" | ConvertTo-SecureString)
- Start-Process Explorer -LoadUserProfile -Credential $Credential
- }
- ## Start PowerShell As Admin
- Function Start-PowerShellAsAdmin {
- $Credential = New-Object -TypeName System.Management.Automation.PsCredential -ArgumentList "domain\username",(Get-Content "$($env:userprofile)\filename_priv.txt" | ConvertTo-SecureString)
- Start-Process PowerShell -LoadUserProfile -Credential $Credential
- }
- ## Start PowerShell As Admin
- Function Start-ADUC {
- Param (
- [parameter(Position=0, ParameterSetName="AsAdmin")]
- [switch]$AsAdmin
- )
- If ($AsAdmin) {
- $Credential = New-Object -TypeName System.Management.Automation.PsCredential -ArgumentList "domain\username",(Get-Content "$($env:userprofile)\filename_priv.txt" | ConvertTo-SecureString)
- Start-Process powershell -Credential $Credential -ArgumentList "Start-Process -FilePath $env:SystemRoot\System32\mmc.exe -ArgumentList $env:SystemRoot\System32\dsa.msc -Verb RunAs"
- }
- Else {Start-Process dsa.msc}
- }
Add Comment
Please, Sign In to add comment