diff --git a/scripts/Win_AD_Check_And_Enable_AD_Recycle_Bin.ps1 b/scripts/Win_AD_Check_And_Enable_AD_Recycle_Bin.ps1 index eef071ed..f0cf9e77 100644 --- a/scripts/Win_AD_Check_And_Enable_AD_Recycle_Bin.ps1 +++ b/scripts/Win_AD_Check_And_Enable_AD_Recycle_Bin.ps1 @@ -1,17 +1,48 @@ -#Please only run on a domain controller -#This script will first check if there are any AD Recycle Bin scopes set up - if there are no scopes it is assumed recycle bin feature is not enabled for the domain -#The script then pulls the domain that the machine running the script is on - queries the domain for the Infrastructure Master and then will attempt to enable the feature +<# + .SYNOPSIS + This script enables Active Directory Recycle Bin feature for the current domain. + + .DESCRIPTION + Only run on a domain controller. This script checks whether the Recycle Bin feature is enabled for the current domain in Active Directory. + + .PARAMETER adRecycleBinScope + The scope of the Recycle Bin feature to check. This parameter is obtained by running the Get-ADOptionalFeature cmdlet. + + .PARAMETER ADDomain + The name of the Active Directory domain to check. This parameter is obtained by running the Get-ADDomain cmdlet. + + .PARAMETER ADInfraMaster + The name of the infrastructure master for the domain. This parameter is obtained by running the Get-ADDomain cmdlet. + + .OUTPUTS + This script does not output any objects. + + .EXAMPLE + PS C:> .\Enable-ADRecycleBin.ps1 + + bash + Copy code + This example runs the script to enable the Recycle Bin feature for the current domain in Active Directory. + .EXAMPLE + PS C:> .\Enable-ADRecycleBin.ps1 -ADDomain "contoso.com" + + bash + Copy code + This example runs the script to enable the Recycle Bin feature for the "contoso.com" domain in Active Directory. + .NOTES + Version: 1.0 +#> $adRecycleBinScope = Get-ADOptionalFeature -Identity 'Recycle Bin Feature' | Select -ExpandProperty EnabledScopes $ADDomain = Get-ADDomain | Select -ExpandProperty Forest $ADInfraMaster = Get-ADDomain | Select-Object InfrastructureMaster -if ($adRecycleBinScope -eq $null){ +if ($adRecycleBinScope -eq $null) { Write-Host "Recycle Bin Disabled" Write-Host "Attempting to enable AD Recycle Bin" Enable-ADOptionalFeature -Identity 'Recycle Bin Feature' -Scope ForestOrConfigurationSet -Target $ADDomain -Server $ADInfraMaster.InfrastructureMaster -Confirm:$false Write-Host "AD Recycle Bin enabled for domain $($ADDomain)" } -else{ +else { Write-Host "Recycle Bin already Enabled For: $($ADDomain)`n Scope: $($adRecycleBinScope)" } \ No newline at end of file diff --git a/scripts/Win_AD_Hudu_ADDS_Documentation.ps1 b/scripts/Win_AD_Hudu_ADDS_Documentation.ps1 index 9283f0cf..a9beac09 100644 --- a/scripts/Win_AD_Hudu_ADDS_Documentation.ps1 +++ b/scripts/Win_AD_Hudu_ADDS_Documentation.ps1 @@ -1,27 +1,33 @@ <# -.Synopsis - Automatically document ADDS configuration -.DESCRIPTION - Automatically document ADDS configuration. Submits generated documentation to your Hudu instance and associates it with the Company provided by ClientName. Requires Global Keystore variables for HuduBaseDomain and HuduApiKey. -.INPUTS - -ClientName {{client.name}} - -HuduBaseDomain {{global.HuduBaseDomain}} - -HuduApiKey {{global.HuduApiKey}} -.NOTES - v1.0 - Based on https://github.com/lwhitelock/HuduAutomation/blob/main/CyberdrainRewrite/Hudu-ADDS-Documentation.ps1 -.COMPONENT - Hudu Documentation -.ROLE - Documentation + .SYNOPSIS + Collects information about Active Directory and uploads it to Hudu + .DESCRIPTION + It retrieves Forest information, Site information, FSMO roles, UPN Suffixes, Default Password Policies, Domain Admins, and User count. Submits generated documentation to your Hudu instance and associates it with the Company provided by ClientName. Requires Global Keystore variables for HuduBaseDomain and HuduApiKey. + .PARAMETER ClientName + The name of the client in Hudu + -ClientName {{client.name}} + .PARAMETER HuduBaseDomain + The base domain of your Hudu instance without a trailing slash + -HuduBaseDomain {{global.HuduBaseDomain}} + .PARAMETER HuduApiKey + A valid Hudu API Key from your Hudu instance + -HuduApiKey {{global.HuduApiKey}} + .COMPONENT + Hudu Documentation + .ROLE + Documentation + .NOTES + v1.0 6/13/2021 Zak + Based on https://github.com/lwhitelock/HuduAutomation/blob/main/CyberdrainRewrite/Hudu-ADDS-Documentation.ps1 #> param ( - [string] $ClientName, - [string] $HuduBaseDomain, - [string] $HuduApiKey + [Parameter(Mandatory = $true)][string] $ClientName, + [Parameter(Mandatory = $true)][string] $HuduBaseDomain, + [Parameter(Mandatory = $true)][string] $HuduApiKey ) + if (!$ClientName) { write-output "Must provide -ClientName with a valid value that is identical to the name of a Company that exists in your Hudu instance. This should be the {{client.name}} value. `n" $ErrorCount += 1 @@ -36,7 +42,7 @@ if (!$HuduApiKey) { } if (!$ErrorCount -eq 0) { -exit 1 + exit 1 } ##################################################################### # @@ -52,11 +58,12 @@ Write-Host "Connecting to $HuduBaseDomain" #Get the Hudu API Module if not installed if (Get-Module -ListAvailable -Name HuduAPI) { - Import-Module HuduAPI - } else { - Install-Module HuduAPI -Force - Import-Module HuduAPI - } + Import-Module HuduAPI +} +else { + Install-Module HuduAPI -Force + Import-Module HuduAPI +} #Set Hudu logon information New-HuduAPIKey $HuduAPIKey @@ -81,10 +88,10 @@ function Get-WinADForestInformation { } $Data.UPNSuffixes = Invoke-Command -ScriptBlock { - $UPNSuffixList = [PSCustomObject] @{ - "Primary UPN" = $ForestInformation.RootDomain - "UPN Suffixes" = $ForestInformation.UPNSuffixes -join "," - } + $UPNSuffixList = [PSCustomObject] @{ + "Primary UPN" = $ForestInformation.RootDomain + "UPN Suffixes" = $ForestInformation.UPNSuffixes -join "," + } return $UPNSuffixList } @@ -92,12 +99,12 @@ function Get-WinADForestInformation { $Data.SPNSuffixes = $ForestInformation.SPNSuffixes $Data.Sites = Invoke-Command -ScriptBlock { - $Sites = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest().Sites + $Sites = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest().Sites $SiteData = foreach ($Site in $Sites) { - [PSCustomObject] @{ + [PSCustomObject] @{ "Site Name" = $site.Name "Subnets" = ($site.Subnets) -join ", " - "Servers" = ($Site.Servers) -join ", " + "Servers" = ($Site.Servers) -join ", " } } Return $SiteData @@ -190,7 +197,7 @@ $SiteNice = $TableHeader + ($SiteRawInfo -replace $TableStyling) + $Whitespace $OptionalRawFeatures = new-object PSCustomObject -property $RawAD.OptionalFeatures | convertto-html -Fragment | Select-Object -Skip 1 $OptionalNice = $TableHeader + ($OptionalRawFeatures -replace $TableStyling) + $Whitespace -$UPNRawFeatures = $RawAD.UPNSuffixes | convertto-html -Fragment -as list| Select-Object -Skip 1 +$UPNRawFeatures = $RawAD.UPNSuffixes | convertto-html -Fragment -as list | Select-Object -Skip 1 $UPNNice = $TableHeader + ($UPNRawFeatures -replace $TableStyling) + $Whitespace $DCRawFeatures = $RawAD.GlobalCatalogs | ForEach-Object { Add-Member -InputObject $_ -Type NoteProperty -Name "Domain Controller" -Value $_; $_ } | convertto-html -Fragment | Select-Object -Skip 1 @@ -221,107 +228,108 @@ There are $AdminUsers Domain Administrator users
# Setup the fields for the Asset $AssetFields = @{ - 'domain_name' = $RawAD.ForestName - 'forest_summary' = $ForestNice - 'site_summary' = $SiteNice - 'domain_controllers' = $DCNice - 'fsmo_roles' = $FSMONice - 'optional_features' = $OptionalNice - 'upn_suffixes' = $UPNNice - 'default_password_policies' = $passwordpolicyNice - 'domain_admins' = $adminsnice - 'user_count' = $Users - } + 'domain_name' = $RawAD.ForestName + 'forest_summary' = $ForestNice + 'site_summary' = $SiteNice + 'domain_controllers' = $DCNice + 'fsmo_roles' = $FSMONice + 'optional_features' = $OptionalNice + 'upn_suffixes' = $UPNNice + 'default_password_policies' = $passwordpolicyNice + 'domain_admins' = $adminsnice + 'user_count' = $Users +} # Checking if the FlexibleAsset exists. If not, create a new one. $Layout = Get-HuduAssetLayouts -name $HuduAssetLayoutName if (!$Layout) { -$AssetLayoutFields = @( - @{ - label = 'Domain Name' - field_type = 'Text' - show_in_list = 'true' - position = 1 - }, - @{ - label = 'Forest Summary' - field_type = 'RichText' - show_in_list = 'false' - position = 2 - }, - @{ - label = 'Site Summary' - field_type = 'RichText' - show_in_list = 'false' - position = 3 - }, - @{ - label = 'Domain Controllers' - field_type = 'RichText' - show_in_list = 'false' - position = 4 - }, - @{ - label = 'FSMO Roles' - field_type = 'RichText' - show_in_list = 'false' - position = 5 - }, - @{ - label = 'Optional Features' - field_type = 'RichText' - show_in_list = 'false' - position = 6 - }, - @{ - label = 'UPN Suffixes' - field_type = 'RichText' - show_in_list = 'false' - position = 7 - }, - @{ - label = 'Default Password Policies' - field_type = 'RichText' - show_in_list = 'false' - position = 8 - }, - @{ - label = 'Domain Admins' - field_type = 'RichText' - show_in_list = 'false' - position = 9 - }, - @{ - label = 'User Count' - field_type = 'RichText' - show_in_list = 'false' - position = 10 - } - ) + $AssetLayoutFields = @( + @{ + label = 'Domain Name' + field_type = 'Text' + show_in_list = 'true' + position = 1 + }, + @{ + label = 'Forest Summary' + field_type = 'RichText' + show_in_list = 'false' + position = 2 + }, + @{ + label = 'Site Summary' + field_type = 'RichText' + show_in_list = 'false' + position = 3 + }, + @{ + label = 'Domain Controllers' + field_type = 'RichText' + show_in_list = 'false' + position = 4 + }, + @{ + label = 'FSMO Roles' + field_type = 'RichText' + show_in_list = 'false' + position = 5 + }, + @{ + label = 'Optional Features' + field_type = 'RichText' + show_in_list = 'false' + position = 6 + }, + @{ + label = 'UPN Suffixes' + field_type = 'RichText' + show_in_list = 'false' + position = 7 + }, + @{ + label = 'Default Password Policies' + field_type = 'RichText' + show_in_list = 'false' + position = 8 + }, + @{ + label = 'Domain Admins' + field_type = 'RichText' + show_in_list = 'false' + position = 9 + }, + @{ + label = 'User Count' + field_type = 'RichText' + show_in_list = 'false' + position = 10 + } + ) - Write-Host "Creating New Asset Layout" - $NewLayout = New-HuduAssetLayout -name $HuduAssetLayoutName -icon "fas fa-sitemap" -color "#00adef" -icon_color "#000000" -include_passwords $false -include_photos $false -include_comments $false -include_files $false -fields $AssetLayoutFields - $Layout = Get-HuduAssetLayouts -name $HuduAssetLayoutName + Write-Host "Creating New Asset Layout" + $NewLayout = New-HuduAssetLayout -name $HuduAssetLayoutName -icon "fas fa-sitemap" -color "#00adef" -icon_color "#000000" -include_passwords $false -include_photos $false -include_comments $false -include_files $false -fields $AssetLayoutFields + $Layout = Get-HuduAssetLayouts -name $HuduAssetLayoutName } $Company = Get-HuduCompanies -name $ClientName if ($company) { - #Upload data to Hudu - $Asset = Get-HuduAssets -name $RawAD.ForestName -companyid $company.id -assetlayoutid $layout.id + #Upload data to Hudu + $Asset = Get-HuduAssets -name $RawAD.ForestName -companyid $company.id -assetlayoutid $layout.id - #If the Asset does not exist, we edit the body to be in the form of a new asset, if not, we just upload. - if (!$Asset) { - Write-Host "New Asset Created" - $Asset = New-HuduAsset -name $RawAD.ForestName -company_id $company.id -asset_layout_id $layout.id -fields $AssetFields - } - else { - Write-Host "Asset has been Updated" - $Asset = Set-HuduAsset -asset_id $Asset.id -name $RawAD.ForestName -company_id $company.id -asset_layout_id $layout.id -fields $AssetFields - } + #If the Asset does not exist, we edit the body to be in the form of a new asset, if not, we just upload. + if (!$Asset) { + Write-Host "New Asset Created" + $Asset = New-HuduAsset -name $RawAD.ForestName -company_id $company.id -asset_layout_id $layout.id -fields $AssetFields + } + else { + Write-Host "Asset has been Updated" + $Asset = Set-HuduAsset -asset_id $Asset.id -name $RawAD.ForestName -company_id $company.id -asset_layout_id $layout.id -fields $AssetFields + } -} else { - Write-Host "$ClientName was not found in Hudu" +} +else { + Write-Host "$ClientName was not found in Hudu" } diff --git a/scripts/Win_AD_Join_Computer.ps1 b/scripts/Win_AD_Join_Computer.ps1 index 64fff99c..6ad62d48 100644 --- a/scripts/Win_AD_Join_Computer.ps1 +++ b/scripts/Win_AD_Join_Computer.ps1 @@ -5,32 +5,54 @@ .DESCRIPTION Computer can be joined to AD in a specific OU specified in the parameters or it will join the default location. + .PARAMETER domain + The domain name to join the computer to. + + .PARAMETER password + The password for the domain account. + + .PARAMETER UserAccount + The user account to use for joining the domain. + + .PARAMETER OUPath + The Organizational Unit (OU) to place the computer object in. + .OUTPUTS Results are printed to the console and sent to a log file in C:\Temp .EXAMPLE In parameter set desired items - -domain DOMAIN -password ADMINpassword -UserAccount ADMINaccount -OUPath OU=testOU,DC=test,DC=local + -domain DOMAIN -password ADMINpassword -UserAccount ADMINaccount -OUPath OU=testOU,DC=test,DC=local .NOTES Change Log - V1.0 Initial release + V1.0 Initial release 6/19/2021 rfost52 V1.1 Parameterization; Error Checking with conditionals and exit codes V1.2 Variable declarations cleaned up; minor syntax corrections; Output to file added (@jeevis) Reference Links: - www.google.com - docs.microsoft.com + www.google.com + docs.microsoft.com #> -param( - $domain, - $password, - $UserAccount, - $OUPath -) +param ( + [Parameter(Mandatory = $true, HelpMessage = "The domain name to join the computer to.")] + [ValidateNotNullOrEmpty()] + [string]$Domain, + [Parameter(Mandatory = $true, HelpMessage = "The password for the domain account.")] + [ValidateNotNullOrEmpty()] + [string]$Password, + + [Parameter(Mandatory = $true, HelpMessage = "The user account to use for joining the domain.")] + [ValidateNotNullOrEmpty()] + [string]$UserAccount, + + [Parameter(HelpMessage = "The Organizational Unit (OU) to place the computer object in.")] + [ValidateNotNullOrEmpty()] + [string]$OUPath +) if ([string]::IsNullOrEmpty($domain)) { diff --git a/scripts/Win_Activation_Check.ps1 b/scripts/Win_Activation_Check.ps1 index 3060e577..ffce83ca 100644 --- a/scripts/Win_Activation_Check.ps1 +++ b/scripts/Win_Activation_Check.ps1 @@ -1,3 +1,14 @@ +<# + .SYNOPSIS + Check Windows activation status + .DESCRIPTION + This script checks the Windows activation status by running the "slmgr.vbs" script and returning the results. If the Windows version is activated, the script returns success (exit code 0), otherwise it returns failure (exit code 1). + .OUTPUTS + This cmdlet outputs a message indicating whether Windows is activated or not. + .NOTES + Version: 1.0 7/17/2021 silversword +#> + $WinVerAct = (cscript /Nologo "C:\Windows\System32\slmgr.vbs" /xpr) -join '' if ($WinVerAct -like '*Activated*') { diff --git a/scripts/Win_Antivirus_Verify.ps1 b/scripts/Win_Antivirus_Verify.ps1 index e157831d..1900f77f 100644 --- a/scripts/Win_Antivirus_Verify.ps1 +++ b/scripts/Win_Antivirus_Verify.ps1 @@ -1,40 +1,52 @@ -#https://mcpforlife.com/2020/04/14/how-to-resolve-this-state-value-of-av-providers/ -#https://github.com/wortell/PSHelpers/blob/main/src/Public/Add-ProductStates.ps1 -#Call with optional paramater "-antivirusName AntivirusNameHere" in order to check for a specific antivirus -#antivirusName must match the "displayName" exactly -#If no antivirusName parameter is specified, the tool returns success if there is any active up to date antivirus on the system +<# + .SYNOPSIS + Check if an antivirus is active and up to date -# OS Build must be greater than 14393 to support this script. If it's not it returns exit code 2 + .DESCRIPTION + This script checks if an antivirus is active and up to date on a system. The user can specify a specific antivirus with the optional parameter "-antivirusName", otherwise the tool returns success if there is any active up to date antivirus on the system. + + .PARAMETER [antivirusName] + The name of the antivirus to check for. Must match the "displayName" exactly. + + .EXAMPLE + -antivirusName "AntivirusNameHere" + + .NOTES + Version 1.0 4/7/2021 silversword + https://mcpforlife.com/2020/04/14/how-to-resolve-this-state-value-of-av-providers/ + https://github.com/wortell/PSHelpers/blob/main/src/Public/Add-ProductStates.ps1 + Call with optional paramater "-antivirusName AntivirusNameHere" in order to check for a specific antivirus + antivirusName must match the "displayName" exactly + If no antivirusName parameter is specified, the tool returns success if there is any active up to date antivirus on the system + + OS Build must be greater than 14393 to support this script. If it's not it returns exit code 2 +#> param($antivirusName = "*") -[Flags()] enum ProductState -{ - Off = 0x0000 - On = 0x1000 - Snoozed = 0x2000 - Expired = 0x3000 +[Flags()] enum ProductState { + Off = 0x0000 + On = 0x1000 + Snoozed = 0x2000 + Expired = 0x3000 } -[Flags()] enum SignatureStatus -{ - UpToDate = 0x00 - OutOfDate = 0x10 +[Flags()] enum SignatureStatus { + UpToDate = 0x00 + OutOfDate = 0x10 } -[Flags()] enum ProductOwner -{ - NonMs = 0x000 - Windows = 0x100 +[Flags()] enum ProductOwner { + NonMs = 0x000 + Windows = 0x100 } -[Flags()] enum ProductFlags -{ - SignatureStatus = 0x000000F0 - ProductOwner = 0x00000F00 - ProductState = 0x0000F000 +[Flags()] enum ProductFlags { + SignatureStatus = 0x000000F0 + ProductOwner = 0x00000F00 + ProductState = 0x0000F000 } function Add-ProductStates { @@ -60,16 +72,16 @@ function Add-ProductStates { If (Get-Member -inputobject $Products[0] -name "productState" -Membertype Properties) { $results += $Products.PSObject.Copy() foreach ($item in $Products) { - If($results.Where({$_.instanceGuid -eq $item.instanceGuid}).Properties.name -notmatch "state") { - $results.Where({$_.instanceGuid -eq $item.instanceGuid}) | - Add-Member -NotePropertyName state -NotePropertyValue $([ProductState]($item.productState -band [ProductFlags]::ProductState)) + If ($results.Where({ $_.instanceGuid -eq $item.instanceGuid }).Properties.name -notmatch "state") { + $results.Where({ $_.instanceGuid -eq $item.instanceGuid }) | + Add-Member -NotePropertyName state -NotePropertyValue $([ProductState]($item.productState -band [ProductFlags]::ProductState)) } else { Write-Error 'Could not add state property it already exists...' } - If($results.Where({$_.instanceGuid -eq $item.instanceGuid}).Properties.name -notmatch "signatureStatus") { - $results.Where({$_.instanceGuid -eq $item.instanceGuid}) | - Add-Member -NotePropertyName signatureStatus -NotePropertyValue $([SignatureStatus]($item.productState -band [ProductFlags]::SignatureStatus)) + If ($results.Where({ $_.instanceGuid -eq $item.instanceGuid }).Properties.name -notmatch "signatureStatus") { + $results.Where({ $_.instanceGuid -eq $item.instanceGuid }) | + Add-Member -NotePropertyName signatureStatus -NotePropertyValue $([SignatureStatus]($item.productState -band [ProductFlags]::SignatureStatus)) } else { Write-Error 'Could not add signatureStatus property it already exists...' @@ -79,41 +91,42 @@ function Add-ProductStates { } } If ($ProductState -and (-not $Products)) { - If($results.Properties.name -notmatch "enabled") { + If ($results.Properties.name -notmatch "enabled") { $results += New-Object PSObject -Property @{ - state = $([ProductState]($item.productState -band [ProductFlags]::ProductState)) - signatureStatus = $([SignatureStatus]($item.productState -band [ProductFlags]::SignatureStatus)) + state = $([ProductState]($item.productState -band [ProductFlags]::ProductState)) + signatureStatus = $([SignatureStatus]($item.productState -band [ProductFlags]::SignatureStatus)) } } } } end { - If($results) { + If ($results) { return $results } } } if ([environment]::OSVersion.Version.Build -le 14393) { - write-host "Antivirus check not supported on this OS. Returning Exit Code 2." - exit 2 + write-host "Antivirus check not supported on this OS. Returning Exit Code 2." + exit 2 } $return = Get-CimInstance -Namespace root/SecurityCenter2 -className AntivirusProduct | - Where-Object { +Where-Object { ($_.displayName -like $antivirusName) -and (($_.productState -band [ProductFlags]::ProductState) -eq [ProductState]::On) -and (($_.productState -band [ProductFlags]::SignatureStatus) -eq [SignatureStatus]::UpToDate) - } +} Write-Host "Antivirus selection: $antivirusName" if ($return) { - Write-Host "Antivirus active and up to date" - $return -} else { - Write-Host "Antivirus issue!" - Get-CimInstance -Namespace root/SecurityCenter2 -className AntivirusProduct | Add-ProductStates - exit 1 + Write-Host "Antivirus active and up to date" + $return +} +else { + Write-Host "Antivirus issue!" + Get-CimInstance -Namespace root/SecurityCenter2 -className AntivirusProduct | Add-ProductStates + exit 1 } diff --git a/scripts/Win_AnyDesk_Get_Anynet_ID.ps1 b/scripts/Win_AnyDesk_Get_Anynet_ID.ps1 index a7963150..c344cb8b 100644 --- a/scripts/Win_AnyDesk_Get_Anynet_ID.ps1 +++ b/scripts/Win_AnyDesk_Get_Anynet_ID.ps1 @@ -1,3 +1,17 @@ +<# + .SYNOPSIS + This script extracts the AnyDesk ID from the system.conf file in the AnyDesk application directory. + + .DESCRIPTION + This script searches for the system.conf file in the AnyDesk application directory and extracts the AnyDesk ID from it. + + .OUTPUTS + Returns the AnyDesk ID as a string. + + .NOTES + Version: 1.0 6/30/2021 Samuel Meuchel +#> + $Paths = @($Env:APPDATA, $Env:ProgramData, $Env:ALLUSERSPROFILE) foreach ($Path in $Paths) { diff --git a/scripts_wip/Win_Delete_Securely.ps1 b/scripts_wip/Win_Delete_Securely.ps1 new file mode 100644 index 00000000..0e53e605 --- /dev/null +++ b/scripts_wip/Win_Delete_Securely.ps1 @@ -0,0 +1,28 @@ +<# + .SYNOPSIS + Securely deletes a folder using the cipher command. + + .DESCRIPTION + This PowerShell script securely deletes a folder using the cipher command in Windows. + + .PARAMETER FolderPath + The path to the folder that you want to securely delete. + + .NOTES + This operation cannot be undone, and the data will be permanently deleted. Ensure that you have administrator privileges before running this script. + Version 1.0 3/27/2023 silversword +#> + +param( + [string]$FolderPath +) + +if (-not (Test-Path $FolderPath)) { + Write-Output "Folder path not found: $FolderPath" + exit 1 +} + +# Securely delete the folder +cipher /w:$FolderPath + +Write-Output "Securely deleted folder: $FolderPath" \ No newline at end of file diff --git a/scripts_wip/Win_SecurityAuditv1.ps1 b/scripts_wip/Win_SecurityAuditv1.ps1 new file mode 100644 index 00000000..6a5551f7 --- /dev/null +++ b/scripts_wip/Win_SecurityAuditv1.ps1 @@ -0,0 +1,88 @@ +Write-Host "Security Audit" +Write-Host "--------------" +Write-Host "Date: $(Get-Date -Format "yyyy-MM-dd HH:mm:ss zzz")" +Write-Host "Computer Name: $(("{0}\{1}" -f $computerSystem.Domain, $computerSystem.Name))" +Write-Host "$((get-WMiObject -computername $env:computername -Class win32_operatingSystem).caption) Build $(([System.Diagnostics.FileVersionInfo]::GetVersionInfo("C:\Windows\system32\kernel32.dll")).FileBuildPart)" + +$computerSystem = Get-CimInstance Win32_ComputerSystem +Write-Output "Computer Na$(("{0}\{1}" -f $computerSystem.Domain, $computerSystem.Name))" + +$BuildNo = ([System.Diagnostics.FileVersionInfo]::GetVersionInfo("C:\Windows\system32\kernel32.dll")).FileBuildPart +if ($BuildNo -lt 7601) { + write-host "WARNING: This computer is pre-Windows 7 SP1/Server 2008 R2." + write-host "Microsoft does not support this operating system, therefore, it will not receive any security updates." + write-host "Security Audit: FAILED" + Exit 1 +} + +if ($BuildNo -eq 7601) { + write-host "WARNING: This computer is Windows 7 SP1/Server 2008 R2." + write-host "Microsoft does not support this operating system as of January 14 2020, therefore, it will not receive any security updates." + write-host "Security Audit: FAILED" + Exit 1 +} + +if ($BuildNo -eq 9200) { + write-host "WARNING: This computer is Windows 8.0/Server 2012 has been discontinued by Microsoft." + write-host "Microsoft does not support this operating system therefore, it will not receive any security updates." + write-host "Security Audit: FAILED" + Exit 1 +} + +write-host "---------------------- Account Audit ----------------------" + +# Check for local "Administrator" account +if ((Get-WmiObject -Class Win32_UserAccount -Filter "LocalAccount='$true' AND SID LIKE '%-500'").disabled) { + write-host "- The 'Administrator' account is disabled." +} +else { + write-host "X - WARNING: The 'Administrator' account is enabled. You should never have the account 'Administrator' enabled." +} + + +if ((Get-WmiObject Win32_ComputerSystem | Select-Object -ExpandProperty PartOfDomain) -eq $true) { + # Computer is in a domain. + # Check for local accounts + $localAccountExists = Get-WmiObject -Class Win32_UserAccount -Filter "LocalAccount='$true'" + If ( -not $localAccountExists ) { + Write-Host "$($localAccountExists)" + write-host "- No Local Accounts." + } + else { + # Check for enabled guest account + if ((Get-WmiObject -Class Win32_UserAccount -Filter "LocalAccount='$true' AND SID LIKE '%-501'").disabled) { + write-host "- The Guestasdfasdfasfd account is disabled." + } + else { + write-host "X - WARNING: The Guest account is enabled. " + } + } + +} +else { + # Computer is not in a domain. + Write-Host "This computer is not in a domain." + # Get the local administrators group object + $adminsGroup = [ADSI]"WinNT://./Administrators" + + # Get the members of the administrators group + $admins = $adminsGroup.Members() | foreach { $_.GetType().InvokeMember("Name", 'GetProperty', $null, $_, $null) } + + # Filter out disabled accounts + $admins = $admins | where { $_ -notin 'Administrator', 'Guest' } | foreach { + $user = [ADSI]"WinNT://./$_,user" + if (-not $user.UserFlags.Contains('AccountDisabled')) { + $_ + } + } + + # Check if any members were found and print the list of administrators + if ($admins.Count -eq 0) { + Write-Host "No local administrators found." + } + else { + Write-Host "Local administrators:" + $admins | foreach { Write-Host "- $_" } + } +} +