Skip to content

Instantly share code, notes, and snippets.

Dev dpo007

  • Ontario, Canada
Block or report user

Report or block dpo007

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@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
@dpo007
dpo007 / ScanAllDrivesOnDisk.ps1
Last active Jan 14, 2020
PowerShell script :: Scan all drives with letters on given disk.
View ScanAllDrivesOnDisk.ps1
param (
[int]$DiskNumber = 0
)
Write-Host "Gathering SMART info for Disk $DiskNumber..."
$disk = Get-Disk $DiskNumber
$disk | Get-StorageReliabilityCounter | Select * | FL
$partitionsWithDriveLetters = $disk | Get-Partition | Where-Object { [bool]$_.DriveLetter }
@dpo007
dpo007 / CharIsEmpty.ps1
Last active Jan 14, 2020
Powershell function :: Tests to see if Char value is "empty".
View CharIsEmpty.ps1
# Tests to see if Char value is "empty".
# Ran into a need to test for "empty" [Char] DriveLetters when using Get-Partition,
# and the usual PS comparison techniques weren't working with Char (ie: Char is never Null).
# If you (re)cast it to a Boolean, it'll return expected $True\$False to test for "Empty".
# This Gist exists as a reminder of that.
function CharIsEmpty {
param (
[Parameter(Mandatory=$True)]
[char]$CharToTest
@dpo007
dpo007 / ComputerRenamer.ps1
Last active Jan 14, 2020
PowerShell script :: Wraps Rename-Computer, for use during scheduled/remote launches on Domain-Attached machines.
View ComputerRenamer.ps1
#################
# Wrapper for Rename-Computer
# - Intended to be used with an RMM/automated script launcher.
# - DPO, Jan. 2020
#################
param (
[Parameter(Mandatory=$True)]
[string]$NewName,
[Parameter(Mandatory=$True)]
[string]$DomainCreds,
@dpo007
dpo007 / RemoveProfile.ps1
Last active Jan 6, 2020
PowerShell function :: Delete matching user profile(s) from a Windows machine
View RemoveProfile.ps1
# Warning: This cleans all profiles STARTING WITH THE USERNAME GIVEN. So "jsmith" would remove "jsmith", "jsmith.domain1.local", "jsmithly" etc.
function KillUserProfile {
Param (
[Parameter(Mandatory=$True)]
[string]$UserName
)
$profiles = Get-CimInstance win32_userprofile
@dpo007
dpo007 / ComputerIsInGroup.ps1
Last active Jan 14, 2020
PowerShell function :: Check if domain-joined computer is a member of AD group, without AD module.
View ComputerIsInGroup.ps1
function ComputerIsInGroup {
param (
[Parameter(Mandatory=$True)]
[string]$GroupName
)
# Get computer's DN
$objSearcher = New-Object System.DirectoryServices.DirectorySearcher
$objSearcher.SearchRoot = New-Object System.DirectoryServices.DirectoryEntry
$objSearcher.Filter = "(&(objectCategory=Computer)(SamAccountname=$($env:COMPUTERNAME)`$))"
You can’t perform that action at this time.