PowerShell – Uninstall Silverlight (or other Apps)

  Code.ps1   # MrNetTek # eddiejackson.net # 7/15/2022 # free for public use # free to claim as your own $SoftwareName = “Silverlight” $ItemProperties = Get-ItemProperty “HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*” | Select-Object DisplayName,UninstallString foreach ($Item in $ItemProperties) { $DisplayName = $Item.DisplayName $UninstallString = $Item.UninstallString if($DisplayName -like “*$SoftwareName*”) { Write-Host “$DisplayName : $UninstallString” # Output: Microsoft Silverlight : Read More …

Azure – VDI – Nerdio – Add AD Group to Host Session

  Code.ps1   # MrNetTek # eddiejackson.net # 7/15/2022 # free for public use # free to claim as your own $ErrorActionPreference = ‘Continue’ Write-output “Getting Host Pool Information” $HostPool = Get-AzResource -ResourceId $HostpoolID $HostPoolResourceGroupName = $HostPool.ResourceGroupName $HostPoolName = $Hostpool.Name $Script = @” `$ErrorActionPreference = ‘Continue’ Try { #Add specific user #Add-LocalGroupMember -Group “Administrators” -Member Read More …

PowerShell – Set DPI Aware

  Code.ps1   # MrNetTek # eddiejackson.net # 7/15/2022 # free for public use # free to claim as your own # Add a new type definition using C# code Add-Type -TypeDefinition @’ using System.Runtime.InteropServices; // Import the necessary namespace for DLL import public class ProcessDPI { // Declare an external method from user32.dll to Read More …

PowerShell – Detect Autoscaling

  Code.ps1   # MrNetTek # eddiejackson.net # 7/15/2022 # free for public use # free to claim as your own #DETECT CURRENT AUTOSCALING function Get-DisplayPrimaryScaling { [CmdletBinding()] param () #Add-Type -Assembly System.Drawing # Get DPI Scaling #[void] [System.Reflection.Assembly]::LoadWithPartialName(“System.Drawing”) Add-Type @’ using System; using System.Runtime.InteropServices; using System.Drawing; public class DPI { [DllImport(“gdi32.dll”)] static extern int Read More …

PowerShell – Adding Tabs to a Form

  Code.ps1   # MrNetTek # eddiejackson.net # 7/15/2022 # free for public use # free to claim as your own [void] [System.Reflection.Assembly]::LoadWithPartialName(“System.Windows.Forms”) [void] [System.Reflection.Assembly]::LoadWithPartialName(“System.Drawing”) [void] [System.Reflection.Assembly]::LoadWithPartialName(“PresentationFramework”) [void] [Reflection.Assembly]::LoadWithPartialName(“PresentationCore”) $Form = New-Object System.Windows.Forms.Form $Form.Text = “Test Form” $Form.Size = New-Object System.Drawing.Size(630,840) $Form.StartPosition = “CenterScreen” $Form.ShowInTaskbar = $True $Form.KeyPreview = $True $Form.AutoSize = $True $Form.FormBorderStyle = Read More …

PowerShell – Detect if Administrator

Code.ps1   # MrNetTek # eddiejackson.net # 6/11/2022 # free for public use # free to claim as your own # DETECT IF FORM IS LAUNCH AS ADMIN $currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent()) $currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) if (!$currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { $message = [System.Windows.MessageBox]::Show(“Non-admin detected! `r`n`r`nPlease right-click on app and run as administrator.”,” ADMIN REQUIRED”) exit } Maximize Window Copy Read More …

PowerShell – Add DNS Suffix to Ethernet Connections

Code.ps1   # SUFFIX TO ADD $Domain = ‘YourDomainHere.com’ # ONLY RETURN ETHERNET CONNECTIONS $Nic = Get-DnsClient | Where-Object -Property InterfaceAlias -Match Ethernet # ADD SUFFIX TO EACH ETHERNET CONNECTION Foreach ($N in $Nic) { Set-DnsClient -ConnectionSpecificSuffix $Domain -InterfaceIndex $N.InterfaceIndex $Alias = $N.InterfaceAlias $Index = $N.InterfaceIndex } Maximize Window Copy Code       Notes Read More …

PowerShell – Scan Text File for String

Code.ps1   # MrNetTek # eddiejackson.net # 1/13/2022 # free for public use # free to claim as your own $Path = “C:\PowerShell\test.txt” $Content = (Get-Content -Path $Path | Select-String -Pattern ‘Eddie-PC’).Matches.Success if ($Content) { #ADD MORE CODE HERE Write-Host “Eddie-PC found!” Write-host “exiting…” Start-Sleep 3 Exit } else { #ADD MORE CODE HERE Write-Host Read More …