Skip to content

Instantly share code, notes, and snippets.

##########
# Win10 Initial Setup Script
# Author: Disassembler <[email protected]>
# Version: 1.4, 2016-01-16
# http://pastebin.com/gQxCUkLP
# Modified: Casey Gray, 2016-04-27
##########
# Script Execution must be enabled
# Ask for elevated permissions if required
<#
.SYNOPSIS
Resize photos to a specified size, 648 by default
Rename them and place them in a 'resized' folder
.EXAMPLE
Get-ChildItem -Path C:\Picures | Resize-ThumbnailPhoto
#>
Function Resize-ThumbnailPhoto
@mortenya
mortenya / Remove-GroupWiseClient.ps1
Created September 21, 2016 20:40
There was no universal uninstaller for the GroupWise client that functioned the way we needed, so this script will simply find the installation in the registry and run the uninstall via MSIEXEC.
if (Test-Path HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall) {
$gwreg = Get-ChildItem HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall | foreach {
Get-ItemProperty $_.pspath | where {
$_.DisplayName -like '*GroupWise*'
}
}
}
else {
$gwreg = Get-ChildItem HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall | foreach {
Get-ItemProperty $_.pspath | where {
@mortenya
mortenya / Parse-GWCheckLog.ps1
Last active September 15, 2016 20:37
These are some scripts I've used to parse unstructured output from GroupWise to get useful info. Parse-GWCheckLog.ps1 was the first one I wrote, and it might be a little fat. A good learning point though.
Set-Location C:\GWCheck
Get-ChildItem . | % {
Get-Content $_.FullName -PipelineVariable log | % {
if ($log -match "\S*Checking user =*\S.([^\s]+)|[\s]+(\d+).\S*kbytes*\S")
{
$matches[0] | Out-File -Append .\gwcheck.txt #"" | select @{n='User';e={$matches[1]}},@{n='Size';e={$matches[2]}}
}
}
}
@mortenya
mortenya / Set-ProxyAddresses.ps1
Created September 14, 2016 21:04
We didn't have an Exchange server on site with everyone's mailbox, and this was a requirement for migrating from GroupWise to Exchange Online.
$users = get-aduser -Filter * -Properties proxyAddresses,EmailAddress
foreach ($u in $users) {
if (!($u.proxyAddresses -contains "SMTP:$($u.EmailAddress)")) {
$u.proxyAddresses.Add("SMTP:$($u.EmailAddress)")
Set-ADUser -Identity $u.SamAccountName -Add @{ 'proxyAddresses' = $($u.proxyAddresses) }
}
else {
Write-Host "$($u.name) already had the correct proxyaddresses"
}
@mortenya
mortenya / Add-SystemToFolderACL.ps1
Created February 17, 2016 16:19
This is more of a POC on adding or editing ACLs via PowerShell. This will add the account 'NT AUTHORITY\System' to have FullControl access to the folder in question. This also is looking for a specific UNC, but that can easily be edited.
<#
.Synopsis
This Function will add "NT Authority\SYSTEM" to a folder ACL.
.DESCRIPTION
This Function will add "NT Authority\SYSTEM" to a folder ACL, specifically to \\folder\path\.
.EXAMPLE
Add-SystemToFolderACL \\folder\path\user1
.EXAMPLE
Add-SystemToFolderACL user1,user2
#>
@mortenya
mortenya / Get-GWArchive.ps1
Created November 17, 2015 00:57
This little script crawls a file share and adds the file size for GroupWise Archives. I split the name out from the path, but that's unique to my environment. The last bit converts the number to a readable format, and groups duplicate entries.
$tSize = 0
Get-ChildItem -Path \\personal\users\ -Directory -Filter "of*arc" -Exclude '* *' -Recurse | % {
$pSize = 0
Get-ChildItem $_.FullName -File -Recurse | % {
$pSize += $_.Length
$tSize += $_.Length
}
$pProps = New-Object psobject -Property @{
'user'=$(($_.FullName -split '\\')[4]);
'size'=$($pSize)
@mortenya
mortenya / Get-LocalAdministrators.ps1
Created June 29, 2015 17:48
This script will query the computers in (Get-ADComputer -Filter *) and then output the members of BUILTIN\Administrators to c:\psresults\ListOfLocalAdministratorsGroup.txt
#The Third section will query each computer in the ListOfComputers.txt to get the members of the local group Administrators
#$Servers = (Get-ADComputer -Filter *).name
$output = 'c:\psresults\ListOfLocalAdministratorsGroup.txt'
$results = New-Object System.Collections.ArrayList
$objSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-32-544")
$objgroup = $objSID.Translate([System.Security.Principal.NTAccount])
$objgroupname = ($objgroup.Value).Split("\")[1]
foreach($server in (Get-ADComputer -Filter *).name)
@mortenya
mortenya / Provision-TestLabDC.ps1
Last active February 12, 2024 14:50
A PowerShell script to provision a DC with DNS and DHCP from a Server Core install
<#
This is an attempt at a script to provision a DC VM in a disposable testlab
This will also set the DC as authoritative time source, DHCP, and DNS server
Windows Server® 2012 and 2012 R2 Core Network Guide
https://gallery.technet.microsoft.com/Windows-Server-2012-and-7c5fe8ea
#>
# rename the computer and reboot, this isn't needed if using Vagrant
#Rename-Computer -NewName newhost -Restart -Force
if ($host.UI.RawUI.WindowTitle -like "Administrator:*")
{
Write-Host -ForegroundColor Green "PowerShell is running as 'Administrator'..."
} else {
Write-Host -ForegroundColor Magenta "PowerShell is not running as 'Administrator'..."
}
# check if current user is in BUILTIN\Administrators (from https://github.com/tomasr/dotfiles/blob/master/.profile.ps1)
function Get-IsAdministrator
{