Skip to content

Instantly share code, notes, and snippets.

@pstakuu
pstakuu / Parse-RADIUSLogs.ps1
Created August 12, 2022 14:09
used to parse RADIUS log files
$files= Get-childitem Y: | select -last 90
function Process-RADIUSLogs () {
[CmdletBinding()]
param(
$file,
[switch]$onlyAccepted
)
if ($onlyAccepted) {Write-Verbose "Processing only authenticated attempts"}
@pstakuu
pstakuu / Create-PerUserFirewallPolicy.ps1
Created August 12, 2022 14:10
Can create per-user firewall policies on windows - needed for adding firewall rules to profiles for apps, like Airtame
# Description: Installs Windows Firewall Exceptions for the portable airtame.exe application.
# Rules will be dynamically installed for each user that is currently logged into the machine.
#
$FWRuleDisplayName = "airtame portable exe"
$FWRuleDescription = "airtame.exe"
$ProgramPath = "appdata\local\temp\airtame-portable\airtame.exe"
Write-Verbose -Message "Getting all firewall rules that have exceptions for: $($ProgramPath)"
$CurrentRules = Get-NetFirewallApplicationFilter -Program "*$ProgramPath" -PolicyStore PersistentStore -ErrorAction Ignore | Get-NetFirewallRule -ErrorAction Ignore
@pstakuu
pstakuu / Resolve-IPs.ps1
Created August 12, 2022 14:12
resolve IP address list to hostnames
$IPs = import-csv C:\Scripts\Input\Dev_IPs_Final.csv
$zones = Get-DnsServerZone
#decided to use function instead of adding the results to an array
#when I did the array and tried to export to csv, it was all pissy because CSV needed objects and it kept outputting the line length
function Resolve-IPs{
param (
$IPs,
$zones
@pstakuu
pstakuu / Set-AutoAttendantAudioFile.ps1
Created August 12, 2022 14:14
allow you to record a message with sound recorder in windows, convert to mp3, upload to an auto-attendant in MSFT Teams; requires VLC
function Set-AutoAttendantAudioFile {
Param (
$originalAudioFile = "C:\Sound recordings\Recording (8).m4a",
$autoAttendantName = “Teams Testing”,
$VLCInstall = 'C:\Program Files\VideoLAN\VLC\vlc.exe'
)
if (!(Test-Path $VLCInstall)) {
"Need to install VLC or specify different install directory for VLC.exe"
}
#Function to Get Permissions on a particular on List, Folder or List Item
Function Get-PnPPermissions([Microsoft.SharePoint.Client.SecurableObject]$Object)
{
#Determine the type of the object
Switch($Object.TypedObject.ToString())
{
"Microsoft.SharePoint.Client.ListItem"
{
If($Object.FileSystemObjectType -eq "Folder")
{
@pstakuu
pstakuu / Change-HKCUasAdmin.ps1
Created November 1, 2022 15:02
HKCU changes as admin - specifically this one for hiding ads in Outlook
$loggedonUser = get-wmiobject -Class win32_computersystem |select username
$objuser = new-object System.Security.Principal.NTAccount($loggedonUser.username)
$userdata = $objuser.Translate([System.Security.Principal.SecurityIdentifier])
Set-ItemProperty "registry::hkey_users\$($userdata.value)\Software\Microsoft\Office\16.0\Common\TargetedMessagingService\MessageMetadata\*MsgId:BizBar" -Name AppIdOnAction -Value 6
Set-ItemProperty "registry::hkey_users\$($userdata.value)\Software\Microsoft\Office\16.0\Common\TargetedMessagingService\MessageMetadata\*MsgId:BizBar" -Name SetUserAction -Value 2
#current user changes as admin: https://stackoverflow.com/questions/66066661/how-to-edit-hkcu-values-with-powershell#:~:text=When%20running%20an%20elevated%20PowerShell%2C%20the%20user%20specific,SID%3E....%20For%20example%3A%20Get-ItemProperty%20-Path%20%22registry%3A%3Ahkey_users%24%20%28%24strSID.Value%29SoftwarePoliciesMicrosoftWindowsControl%20PanelDesktop%22
#reg settings: https://community.spiceworks.com/topic/2276
$servers = Get-Content C:\temp\serverlist.txt
function Report-Printer {
param ($server = $env:computername)
$printers = Get-Printer -ComputerName $server
$drivers = Get-PrinterDriver -ComputerName $server
foreach ($printer in $printers) {
$ver = $drivers | where {$_.name -eq $printer.drivername} | select -first 1 | select -expand DriverVersion
$rev = $ver -band 0xffff
$build = ($ver -shr 16) -band 0xffff