This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add-Type -TypeDefinition @' | |
using System; | |
using System.Runtime.InteropServices; | |
using System.Security.Cryptography.X509Certificates; | |
public enum DSREG_JOIN_TYPE { | |
DSREG_UNKNOWN_JOIN = 0, | |
DSREG_DEVICE_JOIN = 1, | |
DSREG_WORKPLACE_JOIN = 2 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Get Installed Roles on each Domain Controller | |
$DCsInForest = (Get-ADForest).Domains | % {Get-ADDomainController -Filter * -Server $_} | |
$DCsRolesArray = @() | |
foreach ($DC in $DCsInForest) { | |
$DCRoles="" | |
$Roles = Get-WindowsFeature -ComputerName $DC.HostName | Where-Object {$_.Installed -like "True" -and $_.FeatureType -like "Role"} | Select DisplayName | |
foreach ($Role in $Roles) { | |
$DCRoles += $Role.DisplayName +"," | |
} | |
try {$DCRoles = $DCRoles.Substring(0,$DCRoles.Length-1)} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Get Domain Controllers for current domain | |
$DCs = Get-ADGroupMember "Domain Controllers" | |
#Initiate the clients array | |
$Clients = @() | |
Foreach ($DC in $DCs) { | |
#Define the netlogon.log path | |
$NetLogonFilePath = "\\" + $DC.Name + "\C$\Windows\debug\netlogon.log" | |
#Reading the content of the netlogon.log file | |
try {$NetLogonFile = Get-Content -Path $NetLogonFilePath -ErrorAction Stop} | |
catch {"Error reading $NetLogonFilePath"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Find Group Policies with Missing Permissions | |
Function Get-GPMissingPermissionsGPOs | |
{ | |
$MissingPermissionsGPOArray = New-Object System.Collections.ArrayList | |
$GPOs = Get-GPO -all | |
foreach ($GPO in $GPOs) { | |
If ($GPO.User.Enabled) { | |
$GPOPermissionForAuthUsers = Get-GPPermission -Guid $GPO.Id -All | select -ExpandProperty Trustee | ? {$_.Name -eq "Authenticated Users"} | |
$GPOPermissionForDomainComputers = Get-GPPermission -Guid $GPO.Id -All | select -ExpandProperty Trustee | ? {$_.Name -eq "Domain Computers"} | |
If (!$GPOPermissionForAuthUsers -and !$GPOPermissionForDomainComputers) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ErrorActionPreference = "Stop" | |
$apiLatestUrl = 'https://api.github.com/repos/microsoft/winget-cli/releases/latest' | |
$tempFolder = $env:TEMP | |
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 | |
$WebClient = New-Object System.Net.WebClient | |
function Update-EnvironmentVariables { | |
foreach($level in "Machine","User") { |