Add AD groups!
This commit is contained in:
parent
c3259c33a2
commit
d0a94224cd
|
|
@ -12,7 +12,7 @@
|
|||
RootModule = 'Get-PC.psm1'
|
||||
|
||||
# Version number of this module.
|
||||
ModuleVersion = '0.4.13'
|
||||
ModuleVersion = '0.4.14'
|
||||
|
||||
# Supported PSEditions
|
||||
# CompatiblePSEditions = @()
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@
|
|||
|
||||
param (
|
||||
[parameter(ValueFromPipeline)]
|
||||
[string]$user
|
||||
[string]$user,
|
||||
[switch]$groups
|
||||
)
|
||||
if($null -eq (get-module -ListAvailable -Name 'ActiveDirectory')){
|
||||
Write-Warning 'Active Drirectory Thick Client is required for this function'
|
||||
|
|
@ -21,6 +22,7 @@
|
|||
$UserInfo = Get-ADUser -Identity $user -Properties *
|
||||
}
|
||||
if($null -eq $UserInfo){
|
||||
if ($groups) { return @() }
|
||||
$props = [ordered]@{
|
||||
Name="User does not exist in AD"
|
||||
UserName=$null
|
||||
|
|
@ -37,6 +39,19 @@
|
|||
|
||||
return $obj
|
||||
}
|
||||
|
||||
if ($groups) {
|
||||
$res = @()
|
||||
foreach ($group in $UserInfo.MemberOf) {
|
||||
if (-not ($group -match "CN=([^,]*),")) { continue }
|
||||
$res += [PSCustomObject]@{
|
||||
Name = $Matches[1]
|
||||
Username = $user
|
||||
}
|
||||
}
|
||||
return $res
|
||||
}
|
||||
|
||||
$manager = $UserInfo.Manager.Split("=,")[1]
|
||||
|
||||
Write-Progress -Activity "Getting user data for $name" -Status 'Querying SCCM for LastLogon data' -PercentComplete 80 -ParentId 1
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ Function Get-PC {
|
|||
Using get-pc hostname will query a workstation (or multiple workstations, comma separated) for information such as model, SSO client, currently logged in user, OS version, RAM, installed printers, etc…
|
||||
|
||||
Expanded functionality can be accessed using these flags
|
||||
-ADGroups | lists AD groups for workstations or shsusers
|
||||
-Apps | shows the installed applications on the computer
|
||||
-AppDiff | shows the installed applications that are not in the standard image
|
||||
-Bypass | used in conjuction with remote viewer will bypass user prompt
|
||||
|
|
@ -110,6 +111,7 @@ Function Get-PC {
|
|||
[Parameter(ValueFromPipeline = $true)]
|
||||
[string[]]$ComputerName = $env:COMPUTERNAME,
|
||||
|
||||
[Switch]$ADGroups,
|
||||
[Switch]$Apps,
|
||||
[Switch]$AppDiff,
|
||||
[Switch]$Bypass,
|
||||
|
|
@ -267,6 +269,12 @@ begin {
|
|||
$PCID++
|
||||
Write-Progress -Activity "Get-PC flags processing" -Status "$comp ($PCID/$NumberofComputers)" -PercentComplete ($PCID*100/$NumberOfComputers) -Id 1
|
||||
#Pulls user data from AD
|
||||
if ($SHSUser -and $ADGroups) {
|
||||
$user = Get-SHSUser $comp -groups
|
||||
$outPutArray += $user
|
||||
continue
|
||||
}
|
||||
|
||||
if ($SHSUser) {
|
||||
$user = Get-SHSUser $comp
|
||||
$outPutArray += $user
|
||||
|
|
@ -643,10 +651,20 @@ begin {
|
|||
if (get-module -ListAvailable -Name 'ActiveDirectory') {
|
||||
Write-Progress -Activity "Get-PC flags processing" -Status "Looking up $comp in AD ($PCID/$NumberofComputers)" -PercentComplete ($PCID*100/$NumberOfComputers) -Id 1
|
||||
try {
|
||||
$adTest = ((Get-ADComputer $comp).DistinguishedName -match "Disabled Computers")
|
||||
$adComp = Get-ADComputer $comp -Properties MemberOf
|
||||
$adTest = ($adComp.DistinguishedName -match "Disabled Computers")
|
||||
if ($adTest) {
|
||||
Write-Warning "$comp is disabled"
|
||||
Write-Warning "Run 'Get-PC $comp -Enable' to attempt to re-enable"
|
||||
} elseif ($ADGroups) {
|
||||
foreach ($group in $adComp.MemberOf) {
|
||||
if (-not ($group -match "CN=([^,]*),")) { continue }
|
||||
$outPutArray += [PSCustomObject]@{
|
||||
Name = $Matches[1]
|
||||
Computer = $comp
|
||||
}
|
||||
}
|
||||
continue
|
||||
}
|
||||
} catch {
|
||||
Write-Warning "$comp is off the domain"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
Patch: 2024-1-17
|
||||
Patch: 2025-2-4
|
||||
-Add ADGroups flag to list out a workstation or user's AD groups
|
||||
|
||||
Patch: 2025-1-17
|
||||
-Fix SHSPrinterWeb bug with site domain names e.g. sagh.int.samhealth.net
|
||||
-Add Better result code handling in UninstallProgram
|
||||
-Add Monitor now reports the initial state of monitored workstations
|
||||
|
|
|
|||
Loading…
Reference in a new issue