Skip to content

Instantly share code, notes, and snippets.

View andyzib's full-sized avatar

Andrew Zbikowski andyzib

View GitHub Profile
#Requires -Modules CredentialManager
#requires -version 5
<#
.SYNOPSIS
Checks to see if OneDrive credential is saved, if so starts OneDrive with /background switch.
.DESCRIPTION
Checks to see if OneDrive credential is saved, if so starts OneDrive with /background switch. Otherwise starts OneDrive normally. Intended to be used in a Citrix XenApp/Virtual Apps environment. Reccomented to run from Task Scheduler using the at logon trigger or using WEM.
.NOTES
Function Test-CaptivePortal {
<#
.SYNOPSIS
Tests internet connectivity using Microsoft's capitve portal test site. Returns $true if a captive portal is detected, otherwise false.
.DESCRIPTION
Tests internet connectivity using Microsoft's capitve portal test site. Returns $true if a captive portal is detected, otherwise false.
For more information on Windows Network Awareness, see
* https://docs.microsoft.com/en-us/windows-hardware/drivers/mobilebroadband/captive-portals
* https://blog.superuser.com/2011/05/16/windows-7-network-awareness/
@andyzib
andyzib / Get-XDayOfMonth.ps1
Last active March 20, 2024 20:31
PowerShell function for finding the date of the Second Tuesday of July 2017, or whatever date you may need.
Function Get-XDayOfMonth {
<#
.SYNOPSIS
Returns the date of the requested day of the month.
.DESCRIPTION
This function will return the date for searches such as the third Tuesday of July 2018 or the Second Friday in August 2002.
.PARAMETER Find
What day to find: First, Second, Third, Fourth, Last. (Numbers 1-5 are also valid, 1 being First 5 being last.)
@andyzib
andyzib / WSUS-Cleanup.ps1
Last active August 5, 2019 19:08
Scripted WSUS Cleanup and Maintenance tasks.
# Requires WSUS to be on Server 2012 R2 and the right version of PowerShell.
$WSUSServer = "wsusserver.example.com"
$WSUSPort = "8531"
$UseSsl = $true
$outfile = "E:\WSUS\Cleanup-Result.txt"
if ($UseSsl) {
$WSUSServer = Get-WsusServer -Name $WSUSServer -PortNumber $WSUSPort -UseSsl
}
else {
@andyzib
andyzib / 2Creds.ps1
Created March 21, 2017 16:32
PowerShell: Credential with two username formats
# I needed two credential objects, one with username, the other DOMAIN\username.
# Same account, just different formats for username required.
# Use Get-Credential unless you have a special case like this one.
$valid_user = $false
# Infinite loop until proper username is entered.
while (-Not $valid_user) {
Write-Host "Enter username in DOMAIN\username format." -ForegroundColor DarkCyan
Write-Host "Press Ctrl+C to exit script." -ForegroundColor DarkCyan
$username = Read-Host -Prompt "Username"
$username = $username.Trim()
@andyzib
andyzib / ChangeSplunkServerName.ps1
Last active September 19, 2016 16:35
Edits Splunk Universal Forwarder config files to change the log source name. Useful for Citrix MCS and PVS images.
<#
Edits the SplunkUniversalForwarder config files to put in the correct hostname, restarts the service.
Running as an Windows Startup Script is reccomended.
#>
# Target files and strings, thank you grep for windows.
# C:\Program Files\SplunkUniversalForwarder\etc\system/local/inputs.conf:host = servernamehere
# C:\Program Files\SplunkUniversalForwarder\etc\system/local/server.conf:serverName = servernamehere
# First, cehck that the Universal Forwarder is installed.
@andyzib
andyzib / ADInactiveComputers.vbs
Created December 5, 2012 18:35
Find and Disable Inactive Computers in Active Directory
' VBScript that searches an OU (and it's sub OUs) for inactive computer accounts.
' If it finds inactive computer accounts, they are disabled and a comment is added.
' Uses DSQuery.exe, which is part of Windows XP or Windows Server 2003
' Written by Andrew Zbikowski <andyzib@gmail.com>
Option Explicit
' Objects
Dim objShell, objScriptExec, objComputer