Skip to content

Instantly share code, notes, and snippets.

View soulhakr's full-sized avatar

Dave soulhakr

View GitHub Profile
@soulhakr
soulhakr / Get-ADUserPasswordExpiration.ps1
Last active January 23, 2023 19:06
[Get Active Directory User Password Expiration] #powershell #windows #activedirectory #usermanagement
# Get the date and time of an Active Directory user account given the username
#
# If the password is going to expire in the next 30 days the script will exit with
# 1, otherwise it will exit with 0.
# If the password is set to never expire, the script will return "Never"
# If the user account is not found, the script will return "Not Found
# Usage: Get-ADUserPasswordExpiration.ps1 -Identity <username>
# Example: Get-ADUserPasswordExpiration.ps1 -Identity jsmith
[CmdletBinding()]
@soulhakr
soulhakr / check-ADUser-password-expiration.ps1
Last active December 16, 2022 17:48
[Get AD User Password Expiration Date (Powershell)] #Powershell #pwsh #windows
$ADUser = (Get-ADUser 'exampleuser' -Properties msDS-UserPasswordExpiryTimeComputed)
[DateTime]::FromFileTime($ADUser.'msDS-UserPasswordExpiryTimeComputed')
@soulhakr
soulhakr / connect-m365.template.ps1
Created November 21, 2022 16:27
[Template: Connect to M365 services (Powershell)] description #powershell #m365
$EXOSession = New-ExoPSSession
Import-PSSession $EXOSession | Out-Null
Write-Host 'Connecting to Microsoft 365...'
Connect-MsolService
<#
#Write-Host 'Connecting to ExchangeOnline...'
#Connect-ExchangeOnline
@soulhakr
soulhakr / Import-ExoPowershellModule.ps1
Last active January 23, 2023 17:39
[Import Exchange Online modules for ISE (Powershell)] description #powershell #windows
## Connect to Exchange Online with MFA in ISE
## documentation: https://docs.microsoft.com/en-us/powershell/exchange/v1-module-mfa-connect-to-exo-powershell?view=exchange-ps
## tutorial: https://www.youtube.com/watch?v=EnmwLqdtDCM
## Download and install cmdlets from - https://docs.microsoft.com/en-us/powershell/exchange/exchange-online-powershell?view=exchange-ps
## NOTE: this method will eventually be retired - the newer method is here: https://docs.microsoft.com/en-us/powershell/exchange/connect-to-exchange-online-powershell?view=exchange-ps
Import-Module $((Get-ChildItem -Path $($env:LOCALAPPDATA + '\Apps\2.0\') -Filter Microsoft.Exchange.Management.ExoPowershellModule.dll -Recurse ).FullName | Where-Object { $_ -notmatch '_none_' } | Select-Object -First 1)
$EXOSession = New-ExoPSSession
@soulhakr
soulhakr / Left.ps1
Last active August 3, 2022 20:20
[String Utilities (Powershell)] #powershell #utility
# https://ss64.com/ps/left.html
Function left {
[CmdletBinding()]
Param (
[Parameter(Position=0, Mandatory=$True,HelpMessage="Enter a string of text")]
[String]$text,
[Parameter(Mandatory=$True)]
[Int]$Length
@soulhakr
soulhakr / _Using-PowershellRemoting.ps1
Last active May 10, 2022 22:37
[Get Remote Hostname (Powershell)] #powershell #pwsh #utility
Invoke-Command -ComputerName (Read-Host -Prompt 'Enter the computer IP') -ScriptBlock { [System.Net.Dns]::GetHostName() } -Credential (Get-Credential)
@soulhakr
soulhakr / _Using-DotNetClass.ps1
Last active August 3, 2022 20:20
[Get Hostname (Powershell)] #powershell #pwsh
‎‎​
@soulhakr
soulhakr / SimpleXMLParser.js
Last active May 10, 2022 20:04 — forked from petersirka/JavaScript - Simple XML parser
[Simple XML Parser (JavaScript)] #JS #JavaScript #xml #EcmaScript
/**
* Simple XML parser
* @param {String} xml
* @return {Object}
*/
function parseXML(xml) {
var beg = -1;
var end = 0;
var tmp = 0;
@soulhakr
soulhakr / Get-MappedDrive.ps1
Last active May 10, 2022 19:10
[Get Mapped Drives (Powershell)] An easy way to determine a remote host's active user's current drive mappings. #windows #utility #powershellcore #powershell #pwsh
function Get-MappedDrive {
<#
.SYNOPSIS
Returns the active drive mappings of a hosts current user session
.DESCRIPTION
Get-MappedDrive is a function which (optionally) takes a remote host and returns the active drive mappings the current user session
.PARAMETER ComputerName
Specifies a remote host
@soulhakr
soulhakr / bootstrap210-initializr.html
Last active May 10, 2022 20:06
[Bootstrap/Initializr boilerplate full (HTML5)] Fully-loaded #Bootstrap #herounit demo in self-contained #Initializr #boilerplate.
<!DOCTYPE html>
<!--[if lt IE 7]><html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en-US"> <![endif]-->
<!--[if IE 7]><html class="no-js lt-ie9 lt-ie8" lang="en-US"> <![endif]-->
<!--[if IE 8]><html class="no-js lt-ie9" lang="en-US"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Hello World</title>
<meta name="description" content="">