This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string currentUserName = System.Security.Principal.WindowsIdentity.GetCurrent().Name; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param($AccountName) | |
# Reset a pwd, requires reset pwd rights on the obj: | |
Set-AdAccountPassword -Identity $AccountName -Reset -NewPassword (Read-Host -asSecureString "Enter the new password") | |
# Change a pwd, knowing the current password | |
Set-AdAccountPassword -Identity $AccountName -OldPassword (Read-Host -asSecureString "Enter the current password") -NewPassword (Read-Host -asSecureString "Enter the new password") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copy the current version of System.Management.Automation.dll to current directory | |
Copy ([PSObject].Assembly.Location) . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dsget user "CN=Mike Danseglio,CN=users,dc=ms,dc=tld" -memberof -expand |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Start powershell session as other user | |
Start-Process PowerShell -Credential "Domain\username" | |
# Start powershell session as local admin | |
Start-Process PowerShell -Verb RunAs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param($textImg, $destinationImg) | |
$base64 = Get-Content $textImg | |
$bytes = [Convert]::FromBase64String($base64) | |
[IO.File]::WriteAllBytes($destinationImg, $bytes) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Source: http://virot.eu/get-the-sid-of-all-domains-in-a-forest/ | |
Import-Module ActiveDirectory | |
(Get-ADForest).Domains| %{Get-ADDomain -Server $_}|select name, domainsid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Assembly: System.Web | |
using System.Web.Security; | |
Membership.GeneratePassword(30, 7); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param($AccountName) | |
Get-ADUser $AccountName -Properties displayname,msDS-UserPasswordExpiryTimeComputed | Select-Object -Property "Displayname",@{Name="ExpiryDate";Expression={[datetime]::FromFileTime($_."msDS-UserPasswordExpiryTimeComputed")}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param($dll, $namespace, $class, $method, $args) | |
Add-Type -Path $dll | |
[$namespace.$class]::$method($args) |
OlderNewer