🕵️♂️
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
#gets all files from specified path. scans each file and gets the BaseName of the file. | |
#script will create a directory for each BaseName and move the file to that new BaseName directory. | |
#this can be handy for things like sorting a digital movie collection. | |
#--------------------------------------------------------- | |
$path = "V:\Movies\Sci-FI Top 50 movies\" | |
#--------------------------------------------------------- | |
$files = Get-ChildItem -Path $path -Recurse -ErrorAction SilentlyContinue | ` | |
Where-Object {$_.BaseName -notlike "Thumbs" -and $_.PSIsContainer -eq $false} | |
#$files #uncomment if you would like to display a list of the files to be moved | |
foreach ($file in $files) { |
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
$certInfo = ls Cert:\LocalMachine\My | where { $_.Subject -eq $subject } | |
$expireDate = $certInfo.NotAfter | |
[int]$daysRemaining = New-TimeSpan -End $expireDate | Select-Object -ExpandProperty Days | |
$date = Get-Date | |
$1weekOut = $date.AddDays(7) |
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
Write-Progress -Activity "Test" -PercentComplete 25 | |
Start-Sleep(5) | |
Write-Progress -Activity "Test" -PercentComplete 50 | |
Start-Sleep(5) | |
Write-Progress -Activity "Test" -PercentComplete 75 | |
Start-Sleep(5) | |
Write-Progress -Activity "Test" -PercentComplete 100 | |
#secind example of progress bar | |
$seconds = 60 |
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 the domain | |
$domain = $env:USERDNSDOMAIN | |
#Get Operating System Info | |
$sOS = Get-CimInstance -ClassName Win32_OperatingSystem | Select-Object -ExpandProperty Caption | |
try { | |
$sOS = Get-WmiObject -class Win32_OperatingSystem | |
$Script:OS = $sOS.Caption | |
} |
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
#set suffixes | |
$suffixes = "suffix1.int,suffix2.int,suffix3.int" | |
$command = @" | |
cmd.exe /C "wmic nicconfig call SetDNSSuffixSearchOrder ($domain,$suffixes)" | |
"@ | |
Invoke-Expression -Command:$command -ErrorAction SilentlyContinue | |
#------------------------------------------------------------------------------ | |
#reverse suffixes change | |
#Append Primary and connection specific DNS suffixes | |
#Append parent suffixes of the primary DNS suffix |
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
<# | |
.Synopsis | |
Verifies if computername matches Windows machine naming requirements | |
.DESCRIPTION | |
This function accepts a computername string and regex verifies if that name meets Windows machine naming requirements | |
.PARAMETER ComputerName | |
String of computername to be tested | |
.EXAMPLE | |
Test-ComputerName -ComputerName PC-Num-43123 | |
This will verify if the computer name meets windows requirements |
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
#tests for file and if found removes the file. | |
#--------------------------------------------------------- | |
$path = 'C:\path\Test.txt' | |
#--------------------------------------------------------- | |
if (Test-Path $path) { | |
Write-OutPut "$path detected, removing file before starting..." | |
try { | |
Remove-Item -Path $path -Force -Confirm:$false -ErrorAction Stop | |
} | |
catch { |
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
$password = Read-Host "Enter your password" | |
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force |
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
$command = 'C:\somepath\someexe.exe somearg' | |
iex $command | |
#full working example | |
$command = 'cmd.exe /c "C:\Program Files (x86)\Bginfo\BgInfo.exe" "C:\Program Files (x86)\Bginfo\config_2016.bgi\" /silent /accepteula /timer:0' | |
iex "& $command" | |
#issue the command | |
cmd.exe /c dir /w |