-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update ./scripts/Collectors/get Domains or Workgroup name.ps1
- Loading branch information
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
scripts_staging/Collectors/get Domains or Workgroup name.ps1
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<# | ||
.SYNOPSIS | ||
Retrieves and displays the domain or workgroup name of the computer. | ||
.DESCRIPTION | ||
This script checks if the computer is part of a domain or a workgroup. | ||
If the computer is part of a domain, it outputs the domain name. | ||
Otherwise, it outputs the workgroup name. | ||
.NOTES | ||
Author: SAN | ||
Date: 01.01.24 | ||
#public | ||
.CHANGELOG | ||
#> | ||
|
||
# Check if the computer is a member of a domain or workgroup | ||
$computerInfo = Get-WmiObject Win32_ComputerSystem | ||
|
||
if ($computerInfo.PartOfDomain -eq $true) { | ||
Write-Host "D: $($computerInfo.Domain)" | ||
} else { | ||
$workgroupName = $computerInfo.Workgroup | ||
Write-Host "W: $workgroupName" | ||
} |