Skip to content

Instantly share code, notes, and snippets.

$OS = (Get-WMIObject Win32_OperatingSystem).Caption
$DaysToDelete = 30
if(($OS -like "*2008*") -or ($OS -like "*2012*")){
$diskbefore = GWMI -Class win32_LogicalDisk -Filter "DeviceID = 'C:'" | Select-Object @{ n = "$OS"; e = {$_.PSComputerName}}, @{ n = "FreeSpace(GB) Before" ; e = {"{0:N1}" -f( $_.Freespace / 1gb ) } }, @{ n = "PercentFree Before" ; e = {"{0:P1}" -f( $_.FreeSpace / $_.Size ) } } | Out-String
Write-Output "$diskbefore"
}
else{
write-host @"
$adPath = 'LDAP://DC=contoso,DC=msft'
$objDomain = New-Object -TypeName System.DirectoryServices.DirectoryEntry -ArgumentList ($adPath)
$CSV = Import-Csv -Path file.csv
foreach($record in $CSV)
{
$employeeFromRecord = $($record.employee).trim()
$managerFromRecord = $($record.manager).trim()
employee manager
1101 jdirte
1102 jdirte
################################################################
# #
# This script works in conjunction with a XBOXAPI.COM account. #
# You must create a XBOXAPI.COM account in order to use it. #
# #
# You do not need the paid subscription unless you intend #
# to perform more than 120 API Requests an hour #
# #
# The information you need from the account is: #
# -XboxAPI API Key #
[Reflection.Assembly]::LoadWithPartialName("System.Web")
$Credentials=$(get-credentials)
$RandomPassword=[System.Web.Security.Membership]::GeneratePassword(10,0)
$domainLocal='ad.fattswindstormelec.com'
$domainPublic='fattswindstormelec.com'
$UserFirst='Poopy'
$UserLast='McButthole'
$Name="$UserFirst $UserLast"
$SamAccountName="$($UserFirst.substring(0,1))$($UserLast.substring(0,7))"
error_page 400 /error/400.html;
error_page 401 /error/401.html;
error_page 402 /error/402.html;
error_page 403 /error/403.html;
error_page 404 /error/404.html;
error_page 405 /error/405.html;
error_page 406 /error/406.html;
error_page 407 /error/407.html;
error_page 408 /error/408.html;
error_page 409 /error/409.html;
function ExcludeBasedOnMultipleIPs($ExcludedAddresses)
{
if($ExcludedAddresses == '')
return false;
$ipaddress = '';
if (isset($_SERVER['HTTP_CLIENT_IP']))
$ipaddress = $_SERVER['HTTP_CLIENT_IP'];
else if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
$ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
$UsersToReset=Import-Csv "C:\pwreset.csv"
foreach($User in $UsersToReset)
{
$Password=($User.Password | ConvertTo-SecureString -AsPlainText -Force)
Set-ADAccountPassword -Identity $user.User -NewPassword $Password -Reset
Enable-ADAccount -Identity $User.User
}
$DayDate=(get-date (get-date).AddDays(-1) -Format dddd)
$FileDate=(get-date (get-date).AddDays(-1) -format "MM-dd-yyyy")
$SubjectDate=(get-date (Get-Date).AddDays(-1) -format 'dddd MMMM dd, yyyy')
$DHCPLogLocation='C:\windows\system32\dhcp'
$Day=$DayDate[0..2] -join ''
$LogName="DhcpSrvLog-$Day"
$LogFile="$LogName.log"
$LogFullPath="$DHCPLogLocation\$LogFile"
## Event IDs: 1 - Source $EventLogSource created.
## Event IDs: 2 - Drive Config Written To Disk: $driveConfig
## Event IDs: 3 - Pre-Existing Drive Exists: $Drive
## Event IDs: 4 - Pre-Existing Drive does not Exist: $Drive
## Define variables
$EventLogSource = 'Drive Checker'
$DriveConfig = 'C:\Drive.Config'
$CurrentDrives = Get-WmiObject -Class Win32_LogicalDisk | Where-Object {$_.VolumeSerialNumber -ne $null} | Select-Object Name,Description,ProviderName,VolumeSerialNumber