Skip to content

Instantly share code, notes, and snippets.

Avatar

Dev dpo007

  • Ontario, Canada
View GitHub Profile
@dpo007
dpo007 / UploadToS3Bucket.ps1
Created Oct 23, 2020
PowerShell :: Upload folder of files to S3 bucket
View UploadToS3Bucket.ps1
Install-Module -Name AWS.Tools.Installer
Install-AWSToolsModule AWS.Tools.S3 -CleanUp
$bucket = 'some-s3-bucket'
Set-AWSCredential `
-AccessKey '<Get Your Own>' `
-SecretKey '<Get Your Own>'
# Gather files to upload
@dpo007
dpo007 / GetPickListChoice.ps1
Created Sep 14, 2020
PowerShell :: Console input with search list by typed letters, tab cycling, etc.
View GetPickListChoice.ps1
function GetPickListChoice {
param (
[Parameter(Mandatory=$true)]
[string[]]$PickList,
[string]$Prompt = 'Type to search, Tab to cycle matches, Backspace to reset, ''?'' for a list: ',
[switch]$PromptNoNewLine
)
function ClearCurrentChoice {
for ($i = $origCursorPos.X; $i -lt $endPos; $i++) {
@dpo007
dpo007 / TriggerWindowsUpdate.ps1
Last active Aug 27, 2020
PowerShell :: Script to trigger a Windows update from WSUS (based on existing approvals) or optionally, everything from MS Update.
View TriggerWindowsUpdate.ps1
<#
- May 22, 2018 - V1.0 - DPO
+ Initial release.
- Note: If it installs updates, it's set to Automatically Reboot when done.
- May 23, 2018 - V1.1 - DPO
+ Added check for packages/modules before force-installing them.
+ Added some output text.
+ Added 'ListOnly' switch, which will cause it to only display approved updates (not download or install them).
- May 23, 2018 - V1.2 - DPO
+ Added 'MicrosoftUpdate' switch to force the check to go to Microsoft Update (circumventing WSUS/WSUS approvals).
@dpo007
dpo007 / Test-PasswordForDomain.ps1
Last active Aug 18, 2020
PowerShell :: Function to check password against Windows Domain rules.
View Test-PasswordForDomain.ps1
function Test-PasswordForDomain {
param (
[Parameter(Mandatory=$true)]
[string]$Password,
[Parameter(Mandatory=$false)]
[string]$AccountSamAccountName = "",
[Parameter(Mandatory=$false)]
[string]$AccountDisplayName,
[Microsoft.ActiveDirectory.Management.ADEntity]$PasswordPolicy = (Get-ADDefaultDomainPasswordPolicy -ErrorAction SilentlyContinue)
)
@dpo007
dpo007 / DiscoWrite.ps1
Last active Aug 27, 2020
PowerShell function :: A simple console Write-Host animation
View DiscoWrite.ps1
function DiscoWrite {
param (
[string]$str,
[int]$speed = 25,
[switch]$NoNewline
)
$anim = @('.', '-', '+', '*', '#')
[int]$CursorTop = [Console]::CursorTop
@dpo007
dpo007 / Set-LenovoVirtualization.ps1
Last active Jul 10, 2020
PowerShell :: Enables or disables Intel virtualization settings in various Lenovo BIOSs
View Set-LenovoVirtualization.ps1
param (
[string]$BiosPass = 'YerPassword',
[switch]$Disable
)
$vendor = (Get-WMIObject -Class Win32_ComputerSystemProduct).Vendor
if ($vendor.ToUpper() -ne 'LENOVO') {
Write-Host ('This is intended for use with Lenovo devices only. "Vendor" returned "{0}", exiting.' -f $vendor)
Exit 666
}
@dpo007
dpo007 / GetHostNameFromUNC.ps1
Created Apr 13, 2020
PowerShell Function :: Get HostName From UNC Path
View GetHostNameFromUNC.ps1
function GetHostNameFromUNC {
param (
[Parameter(Mandatory=$true)]
[string]$UNCPath
)
$UNCPath -match '\\\\(.*?)\\' | Out-Null
if ($Matches.Count -ge 2) {
return $Matches[1]
} else {
@dpo007
dpo007 / GetUnlinkedGPOs.ps1
Created Feb 3, 2020
PowerShell function :: Retrieve list of Group Policy Objects that are not linked to any OU.
View GetUnlinkedGPOs.ps1
function Get-UnlinkedGPOs {
[string[]]$results = @()
Get-GPO -All | ForEach-Object {
if ( $_ | Get-GPOReport -ReportType XML | Select-String -NotMatch "<LinksTo>" ) {
$results += $_.DisplayName
}
}
return $results
}
@dpo007
dpo007 / SetShareAcrossDevicesSettings.ps1
Last active Jan 16, 2020
PowerShell script :: Set "Share Across Devices" settings in Windows 10
View SetShareAcrossDevicesSettings.ps1
##########################
# Sets "Share Across Devices" settings in Windows 10 to On/My devices only.
# - DPO, Jan. 2020
##########################
$path1 = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\CDP'
$path2 = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\CDP\SettingsPage'
$regKeys = @{
CdpSessionUserAuthzPolicy = '1'
@dpo007
dpo007 / EdgeBetaUninstaller.ps1
Last active Jan 15, 2020
PowerShell script :: Uninstall "Mircosoft Edge Beta"
View EdgeBetaUninstaller.ps1
$installPath = Join-Path ${Env:ProgramFiles(x86)} '\Microsoft\Edge Beta\'
if (!(Test-Path $installPath)) {
Write-Host 'Edge Beta folder not found, exiting.'
Exit 0
}
Write-Host "Finding EXE..."
$pathToSetupExe = (Get-ChildItem $installPath -filter "setup.exe" -Recurse).FullName
You can’t perform that action at this time.