This file contains hidden or 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
# batch replace domain name portion of UPN in active directory | |
$SearchBase = "OU=Domain Users, DC=contoso, DC=com" | |
$OldDN = "contoso.com.local" | |
$NewDN = "contoso.com" | |
Import-Module ActiveDirectory | |
Get-ADUser -Filter { UserPrincipalName -like "*$OldDN" } -SearchBase $SearchBase | | |
ForEach-Object { | |
Write-Host $_.Name | |
$Upn = $_.UserPrincipalName.Replace( $OldDN, $NewDN ) |
This file contains hidden or 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
import getpass | |
import sys | |
import telnetlib | |
import os | |
# Variables | |
tacacs = '.tacacslogin' | |
commandsfile = 'commands.txt' | |
hostsfile = 'hosts.txt' | |
verbose = "yes" |
This file contains hidden or 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
$target = read-host "Target" | |
$group = read-host "Group" | |
$user = read-host "User" | |
Invoke-Command -ComputerName $target -ScriptBlock { | |
net localgroup $(args[0]) $(args[1]) /add | |
#With PS5 | |
#Add-LocalGroupMember -Group $(args[0]) -Member $(args[1]) | |
} -ArgumentList $group,$user |
This file contains hidden or 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
Get-ChildItem | Where-Object {$_.Name -like "* - *.wav"} | foreach { | |
Rename-Item $_ -NewName $_.Name.Substring(5) -whatif | |
} |
This file contains hidden or 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
$target = read-host -p "Target" | |
$key = read-host -p "Key" | |
slmgr $target -ipk $key |
This file contains hidden or 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
$ServerName = "CORP-DHCP01" | |
$ScopeId = "10.10.10.0" | |
$SubnetMask = "255.255.255.0" #This is the NEW mask that will be applied | |
$ServerFile = "c:\temp\dhcp_backup.xml" | |
$ServerFileBackup = "c:\temp\dhcp_backup2.xml" | |
$ScopeFile = "c:\temp\scope_$ScopeId.xml" | |
#backup entire server, just in case | |
Export-DhcpServer -ComputerName $ServerName -Leases -File $ServerFile | |
This file contains hidden or 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
function Test-UserCredential { | |
[CmdletBinding()] | |
[OutputType([bool])] | |
param ( | |
[pscredential]$Credential | |
) | |
begin { | |
if ($null -eq $Credential) { $Credential = Get-Credential } | |
$Domain = $Env:USERDOMAIN |
This file contains hidden or 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
[CmdletBinding()] | |
param ( | |
[Parameter(Mandatory = $true)][ValidateSet('Title', 'Department', 'Company')] | |
[string]$AttributeName = (Read-host -Prompt "Which attribute? [Title, Department, Company]"), | |
[Parameter(Mandatory = $true)][string]$AttributeValueOld = (Read-Host -Prompt "Old value"), | |
[Parameter(Mandatory = $true)][string]$AttributeValueNew = (Read-Host -Prompt "New value"), | |
[switch]$NoConfirm | |
) | |
begin {} |
This file contains hidden or 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
function IpToInt ([ipaddress]$IPAddress) { | |
$IpBytes = $IPAddress.GetAddressBytes() | |
if ([BitConverter]::IsLittleEndian) { | |
[Array]::Reverse($IpBytes) | |
} | |
return [BitConverter]::ToUInt32($IpBytes, 0) | |
} |