Skip to content

Instantly share code, notes, and snippets.

View Chirishman's full-sized avatar
⚔️
I guess statuses are a thing now

Chirishman

⚔️
I guess statuses are a thing now
View GitHub Profile
@Chirishman
Chirishman / Get-UserPasswordStatus.ps1
Created January 17, 2018 17:18
Check user password status against domain default an a close-to-expiry threshold
function Get-UserPasswordStatus {
Param(
[int]$ExpiryThreshold=10,
[switch]$ExpiringOnly
)
$Config = @{
ExpiringSoonThresholdDays = $ExpiryThreshold
PasswordExpiryAge = Get-ADDefaultDomainPasswordPolicy | select -ExpandProperty MaxPasswordAge
ResultFilter = $(
if ($ExpiringOnly){
function New-DynamicParams {
Param(
[Parameter(Mandatory=$true)]
[Int]
$count,
[Parameter(Mandatory=$true)]
[PSCustomObject[]]
$settings
)
function New-COMPANYUser {
[CmdletBinding(SupportsShouldProcess=$true)]
Param(
[Parameter(Mandatory=$True,Position=0)]
$FirstName,
[Parameter(Mandatory=$True,Position=1)]
$LastName,
[Parameter(Mandatory=$False,Position=2)]
$Nickname,
[Parameter(Mandatory=$False,Position=3)]
@Chirishman
Chirishman / Convert-HGSTSerial.ps1
Created January 24, 2018 20:43
Parse HGST drive serials and extract drive specifications
function Convert-HGSTSerial {
Param(
[Parameter(Mandatory = $True)]
[string]$Serial
)
$Serial = $Serial.ToUpper()
$ZeroIndexLength = ($Serial.Length - 1)
$TranslationTable = @(
@{
@Chirishman
Chirishman / Switch-RDPCert.ps1
Created January 26, 2018 00:23
Swap self signed RDP cert out for a signed cert from Cert:\LocalMachine\My
function Switch-RDPCert {
[cmdletbinding()]
Param(
[Parameter()]
$SourceStoreScope = 'LocalMachine',
[Parameter()]
$SourceStoreName = 'My',
[Parameter()]
$DestStoreScope = 'LocalMachine',
[Parameter()]
@Chirishman
Chirishman / userChrome.css
Created February 8, 2018 05:30
TreeView Customization
/* Hide main tabs toolbar */
#main-window[tabsintitlebar="true"]:not([extradragspace="true"]) #TabsToolbar {
opacity: 0;
pointer-events: none;
}
#main-window:not([tabsintitlebar="true"]) #TabsToolbar {
visibility: collapse !important;
}
/* Sidebar min and max width removal */
@Chirishman
Chirishman / DefineEventTable.sql
Last active February 8, 2018 19:58
Basic data collection and upsert tool
DROP TABLE IF EXISTS [DATABASENAMEHERE].[dbo].[WinEvent]
GO
CREATE TABLE [DATABASENAMEHERE].[dbo].[WinEvent] (
[id] int IDENTITY(1,1),
[TimeCreated] datetime NOT NULL,
[LogName] varchar(60) NOT NULL UNIQUE,
[ProviderName] varchar(100) NOT NULL,
[EventId] integer NOT NULL,
[LevelDisplayName] varchar(100),
@Chirishman
Chirishman / OneoffCode.ps1
Created February 9, 2018 18:05
Code examples for using ADAuth module to create Active Directory UD Login Pages
$FormLogin = New-UDAuthenticationMethod -Endpoint {
param([PSCredential]$Credentials)
Import-Module ADAuth
$AuthorizedGroup = 'Administrators'
if ($Credentials | ? {$_ | Test-ADCredential} | Test-ADGroupMembership -TargetGroup $AuthorizedGroup) {
New-UDAuthenticationResult -Success -UserName $Credentials.UserName
}
@Chirishman
Chirishman / DellSpecLookup.ps1
Created April 18, 2018 02:59
Really Really Rough Dell Spec Lookup
#REALLY rough, here be dragons. Still faster than doing it manually though.
$STList = @(
#Service Tags Go Here
'XXXXXXX',
'XXXXXXX'
)
$ResultTable = [System.Collections.ArrayList]::new()
$STList | %{
@Chirishman
Chirishman / CorrectHomeFolderPermissions.ps1
Created April 26, 2018 22:39
Script to correct home folder permissions
Param(
$HomeFoldersDirectoryPath = 'C:\Default\Path\Here\'
)
$HomeFolders = Get-ChildItem $HomeFoldersDirectoryPath -Directory
foreach ($HomeFolder in $HomeFolders) {
$Path = $HomeFolder.FullName
$Acl = (Get-Item $Path).GetAccessControl('Access')
$Username = $HomeFolder.Name
$Ar = New-Object System.Security.AccessControl.FileSystemAccessRule($Username, 'Modify', 'ContainerInherit,ObjectInherit', 'None', 'Allow')
$Acl.SetAccessRule($Ar)