Posted On February 19, 2020

PowerShell: Checking Computer Type

kimconnect 0 comments
blog.KimConnect.com >> Codes >> PowerShell: Checking Computer Type
# Determine what type of Windows machine (client or server)
switch ((Get-CimInstance -ClassName Win32_OperatingSystem).ProductType){
1 {'client'} # ClientOs
2 {'domaincontroller'} #ServerOs
3 {'memberserver'}
}

# Determine whether OS is WorkStation or Server
(Get-ComputerInfo).OsProductType

PS C:\Windows\system32> invoke-command -computername $name -ScriptBlock {(Get-ComputerInfo).OsProductType}

PSComputerName RunspaceId Value
-------------- ---------- -----
avvo-tableau01 289c27b8-ccfa-4124-8dd2-40f1006219a4 Server

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

PowerShell: Copying File Share Permissions from Source to Destination

# Copy-SMB-Share-Permissions.ps1 # Set some SMB Share variables $sourceSmbPath="\\FILESERVER002\Home" $destinationSmbPath="\\FILESERVER002-n\Home" $dateStamp = Get-Date -Format "yyyy-MM-dd-hhmmss"…

CSS: Variables & Simple Animation

CSS can mimic other interpreted programming languages by enabling features such as variables. The limitation…

Terminal Service Auditing – Generate Report of RDP Sessions with Certain Login Dates

# getLoginEvents.ps1 function getLoginEvents{ param( $computername=$env:computername, $daysLimit=30 ) $ErrorActionPreference='stop' try{ $logins=Get-WinEvent -ComputerName $ComputerName -LogName "Microsoft-Windows-TerminalServices-LocalSessionManager/Operational"|…