diff --git a/Private/Apps.ps1 b/Private/Apps.ps1 index 80c72ef..fe6c95c 100644 --- a/Private/Apps.ps1 +++ b/Private/Apps.ps1 @@ -1,22 +1,6 @@ Function Get-Apps($ComputerName, $TableView) { - $SCCMServer = "shscm01.int.samhealth.net" - - $SCCMNameSpace = "root\sms\site_100" - - $SCCMX64Query = "select SMS_G_System_ADD_REMOVE_PROGRAMS_64.DisplayName, SMS_G_System_ADD_REMOVE_PROGRAMS_64.Version, SMS_G_System_ADD_REMOVE_PROGRAMS_64.Publisher, SMS_G_System_ADD_REMOVE_PROGRAMS_64.InstallDate from SMS_R_System inner join SMS_G_System_ADD_REMOVE_PROGRAMS_64 on - SMS_G_System_ADD_REMOVE_PROGRAMS_64.ResourceId = SMS_R_System.ResourceId inner join SMS_G_System_SYSTEM on - SMS_G_System_SYSTEM.ResourceId = SMS_R_System.ResourceId where SMS_G_System_SYSTEM.Name = '$ComputerName'" - - $SCCMX86Query = "select SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName, SMS_G_System_ADD_REMOVE_PROGRAMS.Version, SMS_G_System_ADD_REMOVE_PROGRAMS.Publisher, SMS_G_System_ADD_REMOVE_PROGRAMS.InstallDate from SMS_R_System inner join SMS_G_System_ADD_REMOVE_PROGRAMS on - SMS_G_System_ADD_REMOVE_PROGRAMS.ResourceID = SMS_R_System.ResourceId inner join SMS_G_System_SYSTEM on - SMS_G_System_SYSTEM.ResourceID = SMS_R_System.ResourceId where SMS_G_System_SYSTEM.Name = '$ComputerName'" - - $64apps = Get-WmiObject -namespace $SCCMNameSpace -DirectRead -computer $SCCMServer -query $SCCMX64Query | - Select-Object -Property DisplayName | Add-Member -NotePropertyName x86/x64 -NotePropertyValue 64 -PassThru | Sort-Object -Property DisplayName - - $86apps = Get-WmiObject -namespace $SCCMNameSpace -DirectRead -computer $SCCMServer -query $SCCMX86Query | - Select-Object -Property DisplayName | Add-Member -NotePropertyName x86/x64 -NotePropertyValue 32 -PassThru | Sort-Object -Property DisplayName + $86apps, $64apps = Get-SCCM_Apps $ComputerName #Checks if local computer if ($comp -eq $env:COMPUTERNAME) { diff --git a/Private/AssetConversion.ps1 b/Private/AssetConversion.ps1 deleted file mode 100644 index d01da36..0000000 --- a/Private/AssetConversion.ps1 +++ /dev/null @@ -1,22 +0,0 @@ -Function Get-AssetConversion($ComputerName){ - - $SiteName="100" - - $SCCMServer="shscm01.int.samhealth.net" - - $SCCMNameSpace="root\sms\site_100" - #Set Asset Tag to $comp - $assetTagSCCM = $ComputerName - - $SCCMQuery = "select SMS_R_System.Name from SMS_R_System inner join SMS_G_System_SYSTEM_ENCLOSURE on SMS_G_System_SYSTEM_ENCLOSURE.ResourceId = SMS_R_System.ResourceId Where SMS_G_System_SYSTEM_ENCLOSURE.SMBIOSAssetTag = '$assetTagSCCM'" - - #Set $comp to find hostname of PC - $nameHolder = Get-WmiObject -namespace $SCCMNameSpace -DirectRead -computer $SCCMServer -query $SCCMQuery | Select-Object -First 1 -ExpandProperty Name - - if($null -ne $nameHolder){ - $ComputerName = $nameHolder - return $ComputerName - } - - return $null -} diff --git a/Private/HostnamesByPrinter.ps1 b/Private/HostnamesByPrinter.ps1 deleted file mode 100644 index 036b635..0000000 --- a/Private/HostnamesByPrinter.ps1 +++ /dev/null @@ -1,17 +0,0 @@ -Function HostnamesByPrinter($ComputerName){ - - $SiteName="100" - - $SCCMServer="shscm01.int.samhealth.net" - - $SCCMNameSpace="root\sms\site_100" - - $FindHostnamesByPrinterQuery = "select SMS_R_System.Name from SMS_R_System inner join SMS_G_System_PRINTER_DEVICE on - SMS_G_System_PRINTER_DEVICE.ResourceId = SMS_R_System.ResourceId where SMS_G_System_PRINTER_DEVICE.Name = '$ComputerName'" - - $FindHostnamesByPrinterSCCM = Get-WmiObject -namespace $SCCMNameSpace -DirectRead -computer $SCCMServer -query $FindHostnamesByPrinterQuery | - Select-Object -ExpandProperty Name - - Return $FindHostnamesByPrinterSCCM - -} \ No newline at end of file diff --git a/Private/SCCMQuery.ps1 b/Private/SCCMQuery.ps1 index fef6f1b..29240a2 100644 --- a/Private/SCCMQuery.ps1 +++ b/Private/SCCMQuery.ps1 @@ -429,4 +429,79 @@ function Get-SCCM_PCFromMAC($mac) { $pcFromMacQuery = "select SMS_R_System.Name from SMS_R_System where SMS_R_System.MACAddresses = '$mac'" return (Get-WmiObject -namespace $SCCMNAMESPACE -DirectRead -computer $SCCMSERVER -query $pcFromMacQuery).Name +} + +function Get-SCCM_Apps($ComputerName) { + + $SCCMX64Query = "select SMS_G_System_ADD_REMOVE_PROGRAMS_64.DisplayName, SMS_G_System_ADD_REMOVE_PROGRAMS_64.Version, SMS_G_System_ADD_REMOVE_PROGRAMS_64.Publisher, SMS_G_System_ADD_REMOVE_PROGRAMS_64.InstallDate from SMS_R_System inner join SMS_G_System_ADD_REMOVE_PROGRAMS_64 on + SMS_G_System_ADD_REMOVE_PROGRAMS_64.ResourceId = SMS_R_System.ResourceId inner join SMS_G_System_SYSTEM on + SMS_G_System_SYSTEM.ResourceId = SMS_R_System.ResourceId where SMS_G_System_SYSTEM.Name = '$ComputerName'" + + $SCCMX86Query = "select SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName, SMS_G_System_ADD_REMOVE_PROGRAMS.Version, SMS_G_System_ADD_REMOVE_PROGRAMS.Publisher, SMS_G_System_ADD_REMOVE_PROGRAMS.InstallDate from SMS_R_System inner join SMS_G_System_ADD_REMOVE_PROGRAMS on + SMS_G_System_ADD_REMOVE_PROGRAMS.ResourceID = SMS_R_System.ResourceId inner join SMS_G_System_SYSTEM on + SMS_G_System_SYSTEM.ResourceID = SMS_R_System.ResourceId where SMS_G_System_SYSTEM.Name = '$ComputerName'" + + $64apps = Get-WmiObject -namespace $SCCMNameSpace -DirectRead -computer $SCCMServer -query $SCCMX64Query | + Select-Object -Property DisplayName | Add-Member -NotePropertyName x86/x64 -NotePropertyValue 64 -PassThru | Sort-Object -Property DisplayName + + $86apps = Get-WmiObject -namespace $SCCMNameSpace -DirectRead -computer $SCCMServer -query $SCCMX86Query | + Select-Object -Property DisplayName | Add-Member -NotePropertyName x86/x64 -NotePropertyValue 32 -PassThru | Sort-Object -Property DisplayName + + return $86apps, $64apps +} + +Function Get-AssetConversion($ComputerName){ + + #Set Asset Tag to $comp + $assetTagSCCM = $ComputerName + + $SCCMQuery = "select SMS_R_System.Name from SMS_R_System inner join SMS_G_System_SYSTEM_ENCLOSURE on SMS_G_System_SYSTEM_ENCLOSURE.ResourceId = SMS_R_System.ResourceId Where SMS_G_System_SYSTEM_ENCLOSURE.SMBIOSAssetTag = '$assetTagSCCM'" + + #Set $comp to find hostname of PC + $nameHolder = Get-WmiObject -namespace $SCCMNameSpace -DirectRead -computer $SCCMServer -query $SCCMQuery | Select-Object -First 1 -ExpandProperty Name + + if($null -ne $nameHolder){ + $ComputerName = $nameHolder + return $ComputerName + } + + return $null +} + +Function HostnamesByPrinter($ComputerName){ + + $FindHostnamesByPrinterQuery = "select SMS_R_System.Name from SMS_R_System inner join SMS_G_System_PRINTER_DEVICE on + SMS_G_System_PRINTER_DEVICE.ResourceId = SMS_R_System.ResourceId where SMS_G_System_PRINTER_DEVICE.Name = '$ComputerName'" + + $FindHostnamesByPrinterSCCM = Get-WmiObject -namespace $SCCMNameSpace -DirectRead -computer $SCCMServer -query $FindHostnamesByPrinterQuery | + Select-Object -ExpandProperty Name + + Return $FindHostnamesByPrinterSCCM + +} + +Function Get-ServiceTagConversion($ComputerName){ + + #Set Service Tag to $comp + $ServiceTagSCCM = $ComputerName + + $SCCMQuery = "select SMS_R_System.Name from SMS_R_System inner join SMS_G_System_SYSTEM_ENCLOSURE on + SMS_G_System_SYSTEM_ENCLOSURE.ResourceId = SMS_R_System.ResourceId where SMS_G_System_SYSTEM_ENCLOSURE.SerialNumber = '$ServiceTagSCCM'" + + #Set $comp to find hostname of PC + $nameHolder = Get-WmiObject -namespace $SCCMNameSpace -DirectRead -computer $SCCMServer -query $SCCMQuery | Select-Object -First 1 -ExpandProperty Name + + if($null -ne $nameHolder) + { + $ComputerName = $nameHolder + return $ComputerName + } + +} + +Function Get-SCCM_UserLastLoggedOn($user) { + $SCCMUserQuery = "select distinct SMS_R_System.Name from SMS_R_System where SMS_R_System.LastLogonUserName = '$user'" + + $computerSCCM = Get-WmiObject -namespace $SCCMNameSpace -DirectRead -computer $SCCMServer -query $SCCMUserQuery | Select-Object -ExpandProperty Name + return $computerSCCM } \ No newline at end of file diff --git a/Private/SHSUser.ps1 b/Private/SHSUser.ps1 index cbc8ca0..d62a12f 100644 --- a/Private/SHSUser.ps1 +++ b/Private/SHSUser.ps1 @@ -37,16 +37,8 @@ return $obj } $manager = $UserInfo.Manager.Split("=,")[1] - - $SiteName="100" - - $SCCMServer="shscm01.int.samhealth.net" - - $SCCMNameSpace="root\sms\site_100" - - $SCCMUserQuery = "select distinct SMS_R_System.Name from SMS_R_System where SMS_R_System.LastLogonUserName = '$user'" - $computerSCCM = Get-WmiObject -namespace $SCCMNameSpace -DirectRead -computer $SCCMServer -query $SCCMUserQuery | Select-Object -ExpandProperty Name + $computerSCCM = Get-SCCM_UserLastLoggedOn $user $computerList = $computerSCCM -join ", " $props = [ordered]@{ Name=$UserInfo.DisplayName diff --git a/Private/ServiceTagConversion.ps1 b/Private/ServiceTagConversion.ps1 deleted file mode 100644 index ff12b6b..0000000 --- a/Private/ServiceTagConversion.ps1 +++ /dev/null @@ -1,23 +0,0 @@ -Function Get-ServiceTagConversion($ComputerName){ - - $SiteName="100" - - $SCCMServer="shscm01.int.samhealth.net" - - $SCCMNameSpace="root\sms\site_100" - #Set Service Tag to $comp - $ServiceTagSCCM = $ComputerName - - $SCCMQuery = "select SMS_R_System.Name from SMS_R_System inner join SMS_G_System_SYSTEM_ENCLOSURE on - SMS_G_System_SYSTEM_ENCLOSURE.ResourceId = SMS_R_System.ResourceId where SMS_G_System_SYSTEM_ENCLOSURE.SerialNumber = '$ServiceTagSCCM'" - - #Set $comp to find hostname of PC - $nameHolder = Get-WmiObject -namespace $SCCMNameSpace -DirectRead -computer $SCCMServer -query $SCCMQuery | Select-Object -First 1 -ExpandProperty Name - - if($null -ne $nameHolder) - { - $ComputerName = $nameHolder - return $ComputerName - } - -} \ No newline at end of file diff --git a/Private/ViewerRemote.ps1 b/Private/ViewerRemote.ps1 index bcc43f3..97463bf 100644 --- a/Private/ViewerRemote.ps1 +++ b/Private/ViewerRemote.ps1 @@ -6,7 +6,6 @@ break } - $SiteName = "100" $RemoteViewerPath = "C:\Program Files (x86)\ConfigMgr\bin\i386\CmRcViewer.exe" $RemoteViewerPathAdd = "C:\Program Files (x86)\ConfigMgr Console\bin\i386\CmRcViewer.exe" $RemoteViewerPathAdd2 = "C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\i386\CmRcViewer.exe"