Skip to content

Instantly share code, notes, and snippets.

@kshire
kshire / Get-AzureADPSPermissions.ps1
Created June 14, 2022 12:59 — forked from psignoret/Get-AzureADPSPermissions.ps1
Script to list all delegated permissions and application permissions in Azure AD
<#
.SYNOPSIS
Lists delegated permissions (OAuth2PermissionGrants) and application permissions (AppRoleAssignments).
.PARAMETER DelegatedPermissions
If set, will return delegated permissions. If neither this switch nor the ApplicationPermissions switch is set,
both application and delegated permissions will be returned.
.PARAMETER ApplicationPermissions
If set, will return application permissions. If neither this switch nor the DelegatedPermissions switch is set,
Get-CimInstance -ClassName Win32_NetworkLoginProfile -ComputerName $env:COMPUTERNAME |
Where-Object { $_.UserType -match 'Normal Account' -and $_.Privileges -match '1' } |
Sort-Object -Property LastLogon -Descending |
Select-Object -Property Name, FullName, LastLogon, PSComputerName -First 1
@kshire
kshire / Rename-LocalAccount
Created June 21, 2018 19:58
Rename a local computer account
# https://stackoverflow.com/questions/5188917/powershells-script-to-re-name-local-guest-administrator-account
$user = Get-WMIObject Win32_UserAccount -Filter "Name='$oldName'"
$result = $user.Rename($newName)
if ($result.ReturnValue -eq 0) {
return $user
# you may just print a message here
}
@kshire
kshire / Reset-LocalAccountPassword.ps1
Created June 21, 2018 14:24 — forked from morisy/Reset-LocalAccountPassword.ps1
This article presents a new script, Reset-LocalAccountPassword.ps1, which makes it easier and more secure to reset local account passwords on computers.
# Reset-LocalAccountPassword.ps1
# Written by Bill Stewart (bstewart@iname.com)
#requires -version 2
<#
.SYNOPSIS
Resets the built-in Administrator account or a named local account password on one or more computers.
.DESCRIPTION
# Get-BitLockerRecovery.ps1
# Written by Bill Stewart (bstewart@iname.com)
<#
.SYNOPSIS
Gets BitLocker recovery information for one or more Active Directory computer objects.
.DESCRIPTION
Gets BitLocker recovery information for one or more Active Directory computer objects.
# Grant-ComputerJoinPermission.ps1
# Written by Bill Stewart (bstewart@iname.com)
#
# Grants an AD identity the ability to join one or more computers to the
# domain.
#requires -version 2
<#
.SYNOPSIS