├── LICENSE ├── README.md └── poshserver ├── Donate.txt ├── License.txt ├── README.md ├── Readme.txt ├── Setup-SkatterTools.ps1 ├── Start-Skattertools.ps1 ├── __template.ps1 ├── about.ps1 ├── accordion.js ├── acknowledgements.ps1 ├── adbrowser.ps1 ├── adcomputer.ps1 ├── adcomputers.ps1 ├── addmember.ps1 ├── addomain.ps1 ├── adforest.ps1 ├── adgroup.ps1 ├── adgroups.ps1 ├── admod.ps1 ├── admod2.ps1 ├── adrep.ps1 ├── adreps.ps1 ├── adsites.ps1 ├── adtool.ps1 ├── aduser.ps1 ├── aduserpwdexp.ps1 ├── adusers.ps1 ├── attachnote.ps1 ├── attachnote2.ps1 ├── banner.ps1 ├── cmaddmember.ps1 ├── cmappinstalls.ps1 ├── cmapps.ps1 ├── cmbgroup.ps1 ├── cmbgroups.ps1 ├── cmcerts.ps1 ├── cmcollection.ps1 ├── cmcollections.ps1 ├── cmcompstat.ps1 ├── cmcompstats.ps1 ├── cmdevice.ps1 ├── cmdevicecollections.ps1 ├── cmdevices.ps1 ├── cmdisc.ps1 ├── cmdiscs.ps1 ├── cmfile.ps1 ├── cmfiles.ps1 ├── cmforestdisc.ps1 ├── cminstalls.ps1 ├── cmpackage.ps1 ├── cmpackages.ps1 ├── cmproduct.ps1 ├── cmproducts.ps1 ├── cmqueries.ps1 ├── cmquery.ps1 ├── cmscript.ps1 ├── cmscripts.ps1 ├── cmserver.ps1 ├── cmservers.ps1 ├── cmsitestatus.ps1 ├── cmsumtasks.ps1 ├── cmtasks.ps1 ├── cmuser.ps1 ├── cmusers.ps1 ├── config.ps1 ├── config.txt ├── dashboard1.ps1 ├── dbrecovery.ps1 ├── dbstats.ps1 ├── downloads.ps1 ├── footer.ps1 ├── graphics ├── 301.GIF ├── dflogo.png ├── sdlogo.png ├── sktools4.png ├── sortasc.png ├── sortdesc.png └── splash3.png ├── help.ps1 ├── index.htm ├── learning.ps1 ├── license.htm ├── main.ps1 ├── notes └── notes.xml ├── queries ├── cmboundaries.sql ├── cmboundarygroup.sql ├── cmboundarygroups.sql ├── cmcerts.sql ├── cmcollection.sql ├── cmcollectionmembers.sql ├── cmcollectionqueryrules.sql ├── cmcollections.sql ├── cmcollectionvariables.sql ├── cmcomponentstatus.sql ├── cmcompstat.sql ├── cmdevice.sql ├── cmdeviceapps.sql ├── cmdevicecollectionmembers.sql ├── cmdevicecollections.sql ├── cmdevicecolls.sql ├── cmdevicedrives.sql ├── cmdevicenetconfigs.sql ├── cmdevices.sql ├── cmdiscoveries.sql ├── cmdiscovery.sql ├── cmdp.sql ├── cmdps.sql ├── cmforests.sql ├── cmpackage.sql ├── cmpackages.sql ├── cmqueries.sql ├── cmquery.sql ├── cmscript.sql ├── cmsitestatus.sql ├── cmtasks.sql ├── cmuser.sql ├── cmusercollectionmembers.sql ├── cmusercollections.sql ├── cmuserdevices.sql └── cmusers.sql ├── reload.ps1 ├── reports ├── Devices - Counts by AD Site Name.sql ├── Devices - Counts by BIOS Version.sql ├── Devices - Counts by DHCP Server.sql ├── Devices - Counts by IP Gateway.sql ├── Devices - Counts by Operating System.sql ├── Devices - Counts by Total Memory.sql ├── Devices - Counts by User Login.sql ├── Devices - Hardware Models.sql ├── Devices - Last 20 Discovered.sql ├── Site - Package Distribution Status Summary.sql ├── Software - Counts by Products Installation.sql ├── Software - Google Chrome Installations.sql ├── Software - Microsoft Visio Installations.sql ├── Software - Office Products Detailed.sql ├── Software - OneDrive Sync Client Versions.sql ├── Software - OneDrive Sync Clients.sql ├── Software - Windows Update Client Versions.sql ├── Software - Windows Update Clients.sql └── Software Updates - ADR Summary.sql ├── search.ps1 ├── searchresults.ps1 ├── showfiles.ps1 ├── sidebar.ps1 ├── skreport.ps1 ├── skreports.ps1 ├── sktools.ps1 ├── stdark.css └── stlight.css /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Skatterbrainz 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SkatterTools 2 | Skattered tools from Skatterbrainz 3 | 4 | ## Latest: 1901.07.01 5 | 6 | ## Overview 7 | 8 | * A portable web console for viewing and managing AD and CM features 9 | * Built from PowerShell to run on PoSH Server (http://www.poshserver.net) 10 | * (similar capability to how Microsoft Windows Admin Center works / local web app) 11 | * Open-source, Fully-Customizable 12 | * THIS IS STILL IN DEVELOPMENT - Enjoy! 13 | * IMPORTANT: "master" is currently "development" channel until all base features are done 14 | * Check back frequently, or click "watch" above to be notified of updates 15 | 16 | ## Installation / Configuration (updated as of 1812.27.01) 17 | ### Update: Do not use the portable version of PoSH Server. Use the full installation version. 18 | 19 | * Download PoSH Server from here: http://www.poshserver.net/ (http://www.poshserver.net/files/PoSHServer.v3.7.zip) 20 | * Extract the ZIP contents somewhere (e.g. %TEMP%) 21 | * Install PoSH Server by launching the PoshServer.exe file and following the prompts. 22 | * Download the SkatterTools repo (big green download button, zip option) 23 | * Extract it to a folder 24 | * Open PowerShell using Run as Administrator and launch "Setup-Skattertools.ps1" 25 | * Edit the "config.txt" file in Notepad (should appear during setup) 26 | * Save and close config.txt 27 | * Right-click "Start SkatterTools Web Service" / Run as Administrator 28 | * Minimize that window 29 | * Double-click the other shortcut "SkatterTools" 30 | * Change your underwear :) 31 | 32 | ## Test Notes 33 | * Tested with IE 11, Edge, FireFox, Chrome 34 | * SQL Server 2016, 2017 35 | * ConfigMgr 1806, 1810, 1811, 1812 36 | 37 | ## Release History 38 | 39 | ### 1901.07.01 40 | * Rewritten and still rewriting, but this version appears stable for now 41 | * So much is changing that I'm stopping the detailed version history for a while 42 | * when the code is stable enough to call 'done' I will reset the history like how our news media resets public opinion 43 | 44 | ### A bunch of almost-daily updates in between 45 | 46 | ### 1812.01.01 (12/1/2018) 47 | * First release, still in development 48 | 49 | ## Disclaimers 50 | * This is still in development and changing at an aggressive pace 51 | * This project is not affiliated with PoSH Server in any way 52 | * This project is FREE and open source. Do not pay anyone for using this 53 | -------------------------------------------------------------------------------- /poshserver/Donate.txt: -------------------------------------------------------------------------------- 1 | Hello, 2 | 3 | PoSHServer is a free product but it still has hidden costs like hosting, ssl certificates etc. 4 | 5 | I'll be glad if you can support this project via PayPal donation: 6 | 7 | https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=S5RUQ9DBHJQMW 8 | 9 | Thanks for your support! 10 | 11 | Yusuf. -------------------------------------------------------------------------------- /poshserver/README.md: -------------------------------------------------------------------------------- 1 | # SkatterTools 2 | Skattered tools from Skatterbrainz 3 | 4 | ## Latest: 1901.07.01 5 | -------------------------------------------------------------------------------- /poshserver/Readme.txt: -------------------------------------------------------------------------------- 1 | PowerShell Web Server 2 | Secure, flexible and lightweight web server to meet your requirements. 3 | 4 | Website: 5 | http://www.poshserver.net 6 | 7 | Documentation: 8 | http://www.yusufozturk.info/wp-download.php?file=PoSHServer.Documentation.pdf 9 | 10 | Contact: 11 | ysfozy@gmail.com 12 | 13 | -------------------------------------------------------------------------------- /poshserver/Setup-SkatterTools.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .NOTES 3 | 2018.31.01 - DS 4 | #> 5 | [CmdletBinding()] 6 | param () 7 | 8 | function New-DesktopShortcut { 9 | [CmdletBinding()] 10 | param ( 11 | [parameter(Mandatory=$True)] 12 | [string] $Name, 13 | [parameter(Mandatory=$True)] 14 | [string] $Target, 15 | [parameter(Mandatory=$False)] 16 | [string] $Arguments = "", 17 | [parameter(Mandatory=$False)] 18 | [ValidateSet('file','web')] 19 | [string] $ShortcutType = 'file', 20 | [switch] $AllUsers 21 | ) 22 | if ($ShortcutType -eq 'file' -and (!(Test-Path $Target))) { 23 | Write-Warning "Target not found: $Target" 24 | break 25 | } 26 | try { 27 | if ($AllUsers) { 28 | $ShortcutFile = "$env:ALLUSERSPROFILES\Desktop\$Name.lnk" 29 | } 30 | else { 31 | $ShortcutFile = "$env:USERPROFILE\Desktop\$Name.lnk" 32 | } 33 | $WScriptShell = New-Object -ComObject WScript.Shell 34 | $Shortcut = $WScriptShell.CreateShortcut($ShortcutFile) 35 | $Shortcut.TargetPath = $Target 36 | if ($ShortcutType -eq 'file' -and $Arguments -ne "") { 37 | $Shortcut.Arguments = $Arguments 38 | $Shortcut.IconLocation = "$env:SystemRoot\System32\shell32.dll,167" 39 | } 40 | else { 41 | $Shortcut.IconLocation = "$env:SystemRoot\System32\shell32.dll,174" 42 | } 43 | $Shortcut.Save() 44 | } 45 | catch { 46 | Write-Error $Error[0].Exception.Message 47 | } 48 | } 49 | 50 | function Get-Shortcut { 51 | [CmdletBinding()] 52 | param ( 53 | [parameter(Mandatory=$True)] 54 | [ValidateNotNullOrEmpty()] 55 | [string] $Path 56 | ) 57 | if (!(Test-Path $Path)) { 58 | Write-Error "$Path was not found!" 59 | break 60 | } 61 | $ScPath = Get-Item $Path 62 | try { 63 | $WScriptShell = New-Object -ComObject WScript.Shell 64 | $Shortcut = $WScriptShell.CreateShortcut($Path) 65 | if ($ScPath.Extension -eq '.url') { 66 | $props = [ordered]@{ 67 | Name = $Shortcut.FullName 68 | Target = $Shortcut.TargetPath 69 | Icon = $Shortcut.IconLocation 70 | } 71 | } 72 | else { 73 | $props = [ordered]@{ 74 | Name = $Shortcut.FullName 75 | Target = $Shortcut.TargetPath 76 | Arguments = $Shortcut.Arguments 77 | Icon = $Shortcut.IconLocation 78 | } 79 | } 80 | New-Object PSObject -Property $props 81 | } 82 | catch {} 83 | } 84 | 85 | try { 86 | Write-Host "unblocking scripts in skattertools folder..." -ForegroundColor Cyan 87 | Get-ChildItem -Path $PSScriptRoot -Filter "*.ps1" -Recurse | Unblock-File -Confirm:$False 88 | $configFile = (Join-Path $PSScriptRoot -ChildPath "config.txt") 89 | $sktoolsfile = (Join-Path $PSScriptRoot -ChildPath "Start-SkatterTools.ps1") 90 | Write-Host "opening config.txt for user customization..." -ForegroundColor Cyan 91 | Start-Process "notepad.exe" -ArgumentList $configFile -Wait 92 | foreach ($m in @('dbatools','carbon')) { 93 | if (!(Get-Module -Name $m -ListAvailable)) { 94 | Write-Host "installing powershell module: $m" -ForegroundColor Cyan 95 | Install-Module -Name $m -AllowClobber 96 | } 97 | } 98 | Write-Host "creating desktop shortcuts..." -ForegroundColor Cyan 99 | New-DesktopShortcut -Name "Start SkatterTools Web Service" -Target "$env:WINDIR\System32\WindowsPowerShell\v1.0\powershell.exe" -Arguments $sktoolsfile 100 | New-DesktopShortcut -Name "SkatterTools" -Target "http://localhost:8080/" -ShortcutType web 101 | Write-Host "skattertools setup complete!" -ForegroundColor Cyan 102 | } 103 | catch { 104 | Write-Warning "Welcome to pukeville! Something just puked and died" 105 | Write-Error $Error[0].Exception.Message 106 | } -------------------------------------------------------------------------------- /poshserver/Start-Skattertools.ps1: -------------------------------------------------------------------------------- 1 | Import-Module PoSHServer 2 | Start-PoSHServer -HomeDirectory $PSScriptRoot -------------------------------------------------------------------------------- /poshserver/__template.ps1: -------------------------------------------------------------------------------- 1 | $SearchField = Get-PageParam -TagName 'f' -Default "" 2 | $SearchValue = Get-PageParam -TagName 'v' -Default "" 3 | $SearchType = Get-PageParam -TagName 'x' -Default "equals" 4 | $SortField = Get-PageParam -TagName 's' -Default "" 5 | $Detailed = Get-PageParam -TagName 'zz' -Default "" 6 | $TabSelected = Get-PageParam -TagName 'tab' -Default "" 7 | $CustomName = Get-PageParam -TagName 'n' -Default "" 8 | 9 | $PageTitle = "PageTitle" 10 | $PageCaption = "PageTitle" 11 | $SortField = "" 12 | $content = "" 13 | $tabset = "" 14 | 15 | # insert code here to build HTML $content string 16 | 17 | @" 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 |

$PageCaption

26 | 27 | $tabset 28 | $content 29 | 30 | 31 | 32 | "@ -------------------------------------------------------------------------------- /poshserver/about.ps1: -------------------------------------------------------------------------------- 1 | $PageTitle = "About $Global:AppName" 2 | 3 | $tabset = "" 4 | $content = " 5 | 6 | 18 | 29 | 30 |
7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
Version$SkToolsVersion
CM Tools Enabled$CMEnabled
AD Tools Enabled$ADenabled
ConfigMgr DB Host$CmDBHost
ConfigMgr Site$CmSiteCode
Current User$PoshUserName
Install Path$HomeDirectory
SMS Provider$CmSMSProvider
17 |
19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 |
CM Collection Manage$CmCollectionManage
AD Group Manage$ADGroupManage
CustomConfig$CustomConfig
Web Theme$STTheme
Notes Enabled$SkNotesEnable
Notes Path$SkNotesPath
Last Load$LastLoadTime
28 |
" 31 | 32 | Show-SkPage 33 | -------------------------------------------------------------------------------- /poshserver/accordion.js: -------------------------------------------------------------------------------- 1 | function SetMenu() { 2 | var acc = document.getElementsByClassName("accordion"); 3 | var i; 4 | 5 | for (i = 0; i < acc.length; i++) { 6 | acc[i].addEventListener("click", function() { 7 | this.classList.toggle("active"); 8 | var panel = this.nextElementSibling; 9 | if (panel.style.maxHeight){ 10 | panel.style.maxHeight = null; 11 | } else { 12 | panel.style.maxHeight = panel.scrollHeight + "px"; 13 | } 14 | }); 15 | } 16 | return; 17 | }; 18 | -------------------------------------------------------------------------------- /poshserver/acknowledgements.ps1: -------------------------------------------------------------------------------- 1 | $PageTitle = "Acknowledgements" 2 | 3 | $tabset = "" 4 | $links = @( 5 | 'https://docs.microsoft.com/en-us/powershell/module/configurationmanager/?view=sccm-ps', 6 | 'https://www.petri.com/managing-active-directory-groups-adsi-powershell', 7 | 'https://stackoverflow.com', 8 | 'https://www.petri.com/active-directory-powershell-with-adsi', 9 | 'https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/?view=powershell-5.1', 10 | 'https://lazywinadmin.com/2014/04/powershell-get-list-of-my-domain.html', 11 | 'http://tech-comments.blogspot.com/2010/10/powershell-adsisearcher-basics.html', 12 | 'https://serverfault.com/questions/512228/how-to-check-ad-ds-domain-forest-functional-level-from-domain-joined-workstation', 13 | 'https://blogs.msmvps.com/richardsiddaway/category/powershellandactivedirectory', 14 | 'https://www.andersrodland.com/ultimate-sccm-querie-collection-list/', 15 | 'https://github.com/paulwetter/DocumentConfigMgrCB/blob/master/DocumentCMCB.ps1' 16 | ) 17 | $content = "" 18 | foreach ($link in $links) { 19 | $content += "" 20 | } 21 | $content += "
$link
" 22 | 23 | Show-SkPage 24 | 25 | -------------------------------------------------------------------------------- /poshserver/adbrowser.ps1: -------------------------------------------------------------------------------- 1 | $SearchField = Get-PageParam -TagName 'f' -Default "" 2 | $SearchValue = Get-PageParam -TagName 'v' -Default "" 3 | $SearchType = Get-PageParam -TagName 'x' -Default 'equals' 4 | $SortField = Get-PageParam -TagName 's' -Default 'FullPath' 5 | $SortOrder = Get-PageParam -TagName 'so' -Default 'Asc' 6 | $TabSelected = Get-PageParam -TagName 'tab' -Default "" 7 | $Detailed = Get-PageParam -TagName 'zz' -Default "" 8 | $CustomName = Get-PageParam -TagName 'n' -Default "" 9 | $IsFiltered = $False 10 | $PageTitle = "AD OU Explorer" 11 | $PageCaption = "AD OU Explorer" 12 | $content = "" 13 | $tabset = "" 14 | $outree = $null 15 | $query = $null 16 | $xxx = "" 17 | 18 | if (![string]::IsNullOrEmpty($SearchValue)) { 19 | $oulist = Get-ADsOUTree | Where {$_.FullPath -like "$SearchValue*"} 20 | $IsFiltered = $True 21 | } 22 | else { 23 | $oulist = Get-ADsOUTree | Where {$_.ChildPath.Length -eq 1} 24 | } 25 | $rowcount = 0 26 | if ($SearchValue -ne "") { 27 | $content = "

$($SearchValue.ToUpper())

" 28 | } 29 | else { 30 | $content = "

$($env:USERDNSDOMAIN)

" 31 | } 32 | $content += "" 33 | $content += "
" 34 | $content += "" 35 | $content += "" 36 | foreach ($ou in $oulist) { 37 | $ouname = $ou.Name 38 | $fpath = $ou.FullPath 39 | $cdist = $ou.ChildPath.Length 40 | if ($SearchValue -ne "" -and $cdist -eq 1) { 41 | $xlink = "< back..." 42 | } 43 | elseif ($fpath -eq $SearchValue) { 44 | $spath = ($fpath -replace "$ouname", "").TrimEnd('/') 45 | $xlink = "< back..." 46 | } 47 | else { 48 | $xlink = "$ouname" 49 | } 50 | #$content += "" 51 | $content += "" 52 | $rowcount++ 53 | } 54 | $content += "" 55 | $content += "
Name
$xlink$fpath ($cdist)
$xlink
$rowcount found
" 56 | $content += "
" 57 | try { 58 | # convert "contoso.local/CORP" to "ou=CORP,dc=contoso,dc=local" 59 | $pathset = ($SearchValue -split '/') 60 | # convert "contoso.local" to "dc=contoso,dc=local" 61 | $domset = ($pathset[0].Split('.') | %{"dc=$_"}) -join ',' 62 | # convert ("CORP","Workstations") to "ou=workstations,ou=corp" 63 | $tailset = $pathset[1..($pathset.Length -1)] 64 | [array]::Reverse($tailset) 65 | $tailset = ($tailset | %{"ou=$_"}) -join ',' 66 | $oupath = "$tailset,$domset" 67 | $items = Get-AdOuObjects -ou $oupath 68 | $content += "" 69 | $content += "" 70 | $xlist = @('Organizational-Unit','Service-Connection-Point') 71 | foreach ($item in $items) { 72 | if ($item.path -eq $oupath -and ($item.name -ne $ouname -and $item.type -notin $xlist)) { 73 | $itemName = $item.name 74 | $objName = ($item.ObjName).TrimEnd('$') 75 | $itemTypeName = $item.type 76 | switch ($itemTypeName) { 77 | 'person' { 78 | $tlink = "$itemName" 79 | break; 80 | } 81 | 'computer' { 82 | $tlink = "$itemName" 83 | break; 84 | } 85 | 'group' { 86 | $tlink = "$itemName" 87 | break; 88 | } 89 | default { 90 | $tlink = $itemName 91 | break; 92 | } 93 | } 94 | $content += "" 95 | } 96 | } 97 | $content += "
NameClass
$tlink$itemTypeName
" 98 | } 99 | catch {} 100 | finally { 101 | $content += "
" 102 | #$content += Write-DetailInfo -PageRef "adbrowser.ps1" -Mode $Detailed 103 | } 104 | 105 | @" 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 |

$PageCaption

114 | 115 | $tabset 116 | $content 117 | 118 | 119 | 120 | "@ -------------------------------------------------------------------------------- /poshserver/adcomputers.ps1: -------------------------------------------------------------------------------- 1 | Get-SkParams | Out-Null 2 | 3 | $PageTitle = "AD Computers" 4 | if (![string]::IsNullOrEmpty($Script:SearchValue)) { 5 | $PageTitle += ": $($Script:SearchValue)" 6 | } 7 | $content = "" 8 | $menulist = "" 9 | $tabset = "" 10 | $pagelink = Split-Path -Leaf $MyInvocation.MyCommand.Definition 11 | 12 | $tabset = New-MenuTabSet -BaseLink 'adcomputers.ps1?x=begins&f=name&v=' -DefaultID $TabSelected 13 | $content = Get-ADObjectTableMultiple -ObjectType 'computer' -Columns ('Name','OS','OSver','LastLogon') -NoSortHeadings -SortColumn "Name" 14 | 15 | Show-SkPage -------------------------------------------------------------------------------- /poshserver/addmember.ps1: -------------------------------------------------------------------------------- 1 | $ResourceName = $PoshPost.resname 2 | $ResourceType = $PoshPost.restype 3 | $ResourceID = $PoshPost.resid 4 | $CollectionName = $PoshPost.collid 5 | #$CollectionName = $PoshPost.collname 6 | 7 | $PageTitle = "Add Collection Member" 8 | $PageCaption = $PageTitle 9 | $content = "" 10 | $query = "" 11 | $tabset = "" 12 | 13 | if ($ResourceID.IndexOf(':') -gt 0) { 14 | $xx = $ResourceID -split ':' 15 | $ResourceID = $xx[0] 16 | $ResourceName = $xx[1] 17 | } 18 | 19 | switch ($ResourceType) { 20 | 5 { 21 | $TargetLink = "cmdevice.ps1?f=resourceid&v=$ResourceID&x=equals&n=$ResourceName&tab=Collections" 22 | $laststep = "defined targetlink: device" 23 | break; 24 | } 25 | 4 { 26 | $TargetLink = "cmuser.ps1?f=resourceid&v=$ResourceID&x=equals&n=$ResourceName&tab=Collections" 27 | $laststep = "defined targetlink: user" 28 | break; 29 | } 30 | } 31 | 32 | #$result = Add-CMCollectionMemberDirect -CollectionName $CollectionName -ResourceName $ResourceName 33 | try { 34 | switch ($ResourceType) { 35 | 5 { 36 | if ($ResourceID -eq "") { 37 | $laststep = "getting resourceid" 38 | [string]$ResourceID = $(Get-WmiObject -ComputerName $CmSMSProvider -Namespace "Root\Sms\Site_$CmSiteCode" -Query "Select * From SMS_R_System Where Name='$($ResourceName)'").ResourceID 39 | } 40 | $laststep = "defining new rule object" 41 | $SmsNewRule = $([wmiclass]$("\\$($CmSMSProvider)\root\sms\site_$($CmSiteCode):SMS_CollectionRuleDirect")).CreateInstance() 42 | $laststep = "getting collection object" 43 | $SmsCollection = Get-WmiObject -ComputerName $CmSMSProvider -Namespace "Root\Sms\Site_$CmSiteCode" -Query "Select * From SMS_Collection Where Name='$($CollectionName)'" 44 | [void]$SmsCollection.Get() 45 | $SmsNewRule.ResourceClassName = "SMS_R_System" 46 | $SmsNewRule.ResourceID = $ResourceID 47 | $SmsNewRule.RuleName = $ResourceName 48 | $laststep = "adding rule to collection" 49 | [System.Management.ManagementBaseObject[]]$SmsRules = $SmsCollection.CollectionRules 50 | $SmsRules += $SmsNewRule 51 | $SmsCollection.CollectionRules = $SmsRules 52 | $laststep = "updating collection" 53 | [void]$SmsCollection.Put() 54 | $laststep = "update completed" 55 | $result = "Success" 56 | break; 57 | } 58 | 4 { 59 | $result = "NotImplemented" 60 | break; 61 | } 62 | } # switch 63 | } 64 | catch { 65 | $result = "Error: $($Error[0].Exception.Message)" 66 | } 67 | 68 | $content = "" 69 | $content += "" 70 | $content += "" 71 | $content += "" 72 | $content += "" 73 | $content += "" 74 | $content += "" 75 | $content += "" 76 | $content += "" 77 | 78 | $content += "" 79 | $content += "" 82 | $content += "
Resource Name$ResourceName
Resource ID$ResourceID
Resource Type$ResourceType
Collection Name$CollectionName
SMS Provider$CmSMSProvider
SMS Site Code$CmSiteCode
Request Status$result
Last step$laststep
Return Link$TargetLink
" 80 | $content += "

Adding to collection...

" 81 | $content += "
" 83 | 84 | $content += Write-DetailInfo -PageRef "addmember.ps1" -Mode $Detailed 85 | 86 | @" 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 |

$PageCaption

96 | 97 | $content 98 | 99 | 100 | 101 | "@ -------------------------------------------------------------------------------- /poshserver/addomain.ps1: -------------------------------------------------------------------------------- 1 | $SearchField = Get-PageParam -TagName 'f' -Default "" 2 | $SearchValue = Get-PageParam -TagName 'v' -Default "" 3 | $SearchType = Get-PageParam -TagName 'x' -Default "" 4 | $SortField = Get-PageParam -TagName 's' -Default "" 5 | $SortOrder = Get-PageParam -TagName 'so' -Default "" 6 | $TabSelected = Get-PageParam -TagName 'tab' -Default "" 7 | $Detailed = Get-PageParam -TagName 'zz' -Default "" 8 | $CustomName = Get-PageParam -TagName 'n' -Default "" 9 | $IsFiltered = $False 10 | $PageTitle = "AD Domain Options" 11 | $PageCaption = "AD Domain Options" 12 | $content = "" 13 | $tabset = "" 14 | $xxx = "" 15 | 16 | $domainname = $env:USERDOMAIN 17 | [adsi]$domain = "WinNT://$domainname" 18 | 19 | $pwa1 = $($domain.MinPasswordAge) / 86400 20 | $pwa2 = $($domain.MaxPasswordAge) / 86400 21 | $pwln = $domain.MinPasswordLength 22 | $mbpa = $domain.MaxBadPasswordsAllowed 23 | $phln = $domain.PasswordHistoryLength 24 | $alin = $domain.AutoUnlockInterval 25 | 26 | $content = "" 27 | $content += "" 28 | $content += "" 29 | $content += "" 30 | $content += "" 31 | $content += "" 32 | $content += "" 33 | $content += "" 34 | $content += "
Option / SettingValue
Minimum Password Age$pwa1 days
Maximum Password Age$pwa2 days
Minimum Password Length$pwln
Max Bad Passwords Allowed$mbpa
Password History Length$phln
Account Lockout Interval$alin
" 35 | 36 | # get summary of object types 37 | #$domain.Children | Group-Object {$_.schemaclassname} | Select-Object Count,Name 38 | #$domain.Children | Where-Object {$_.schemaclassname -eq 'computer'} 39 | 40 | @" 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 |

$PageCaption

49 | 50 | $tabset 51 | $content 52 | 53 | 54 | 55 | "@ -------------------------------------------------------------------------------- /poshserver/adforest.ps1: -------------------------------------------------------------------------------- 1 | $SearchField = Get-PageParam -TagName 'f' -Default "" 2 | $SearchValue = Get-PageParam -TagName 'v' -Default "" 3 | $SearchType = Get-PageParam -TagName 'x' -Default "" 4 | $SortField = Get-PageParam -TagName 's' -Default "" 5 | $SortOrder = Get-PageParam -TagName 'so' -Default "" 6 | $TabSelected = Get-PageParam -TagName 'tab' -Default "" 7 | $Detailed = Get-PageParam -TagName 'zz' -Default "" 8 | $CustomName = Get-PageParam -TagName 'n' -Default "" 9 | 10 | $PageTitle = "AD Forest" 11 | $PageCaption = "AD Forest" 12 | $content = "" 13 | $tabset = "" 14 | 15 | $schemaVersion = $( 16 | #https://blogs.msmvps.com/richardsiddaway/2016/12/14/active-directory-schema-versions/ 17 | $sch = [System.DirectoryServices.ActiveDirectory.ActiveDirectorySchema]::GetCurrentSchema() 18 | $de = $sch.GetDirectoryEntry() 19 | switch ($de.ObjectVersion) { 20 | 13 {"{0,25} " -f "Schema Version $($de.ObjectVersion) = Windows 2000"; break} 21 | 30 {"{0,25} " -f "Schema Version $($de.ObjectVersion) = Windows 2003"; break} 22 | 31 {"{0,25} " -f "Schema Version $($de.ObjectVersion) = Windows 2003 R2"; break} 23 | 44 {"{0,25} " -f "Schema Version $($de.ObjectVersion) = Windows 2008"; break} 24 | 47 {"{0,25} " -f "Schema Version $($de.ObjectVersion) = Windows 2008 R2"; break} 25 | 56 {"{0,25} " -f "Schema Version $($de.ObjectVersion) = Windows 2012"; break} 26 | 69 {"{0,25} " -f "Schema Version $($de.ObjectVersion) = Windows 2012 R2"; break} 27 | 87 {"{0,25} " -f "Schema Version $($de.ObjectVersion) = Windows 2016"; break} 28 | default {"{0,25} {1,2} " -f "Unknown Schema Version", $($de.ObjectVersion); break} 29 | } 30 | ) 31 | 32 | $forest = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest() 33 | 34 | switch ($forest.ForestModeLevel) { 35 | 0 { $flvl = 'Windows Server 2000'; break; } 36 | 1 { $flvl = 'Windows Server 2003 Interim'; break; } 37 | 2 { $flvl = 'Windows Server 2003'; break; } 38 | 3 { $flvl = 'Windows Server 2008'; break; } 39 | 4 { $flvl = 'Windows Server 2008 R2'; break; } 40 | 5 { $flvl = 'Windows Server 2012'; break; } 41 | 6 { $flvl = 'Windows Server 2012 R2'; break; } 42 | 7 { $flvl = 'Windows Server 2016'; break; } 43 | default { $flvl = 'Windows Server 2000'; break; } 44 | } 45 | 46 | $rootDom = $forest.RootDomain 47 | #$rootDom.DomainControllers 48 | switch ($rootDom.DomainModeLevel) { 49 | 0 { $dlvl = 'Windows Server 2000 mixed'; break; } 50 | 1 { $dlvl = 'Windows Server 2003 Interim'; break; } 51 | 2 { $dlvl = 'Windows Server 2003'; break; } 52 | 3 { $dlvl = 'Windows Server 2008'; break; } 53 | 4 { $dlvl = 'Windows Server 2008 R2'; break; } 54 | 5 { $dlvl = 'Windows Server 2012'; break; } 55 | 6 { $dlvl = 'Windows Server 2012 R2'; break; } 56 | 7 { $dlvl = 'Windows Server 2016'; break; } 57 | default { $dlvl = 'Windows Server 2000'; break; } 58 | } 59 | 60 | $im = $rootDom.InfrastructureRoleOwner 61 | $pdc = $rootDom.PdcRoleOwner 62 | $rid = $rootDom.RidRoleOwner 63 | 64 | $pdcName = $pdc.Name 65 | $pdcIP = $pdc.IPAddress 66 | $pdcOS = $pdc.OSVersion 67 | $pdcSite = $pdc.SiteName 68 | $pdcGC = $pdc.IsGlobalCatalog() 69 | $pdcx = $pdc.GetAllReplicationNeighbors() 70 | 71 | $imName = $im.Name 72 | $imIP = $im.IPAddress 73 | $imOS = $im.OSVersion 74 | $imSite = $im.SiteName 75 | $imGC = $im.IsGlobalCatalog() 76 | $imx = $im.GetAllReplicationNeighbors() 77 | 78 | $ridName = $rid.Name 79 | $ridIP = $rid.IPAddress 80 | $ridOS = $rid.OSVersion 81 | $ridSite = $rid.SiteName 82 | $ridGC = $rid.IsGlobalCatalog() 83 | $ridx = $rid.GetAllReplicationNeighbors() 84 | 85 | $smdc = $forest.SchemaRoleOwner 86 | $smnm = $forest.NamingRoleOwner 87 | 88 | $smdcx = "$smdc" 89 | $smnmx = "$smnm" 90 | $ridnx = "$ridName" 91 | $pdcnx = "$pdcName" 92 | $imnx = "$imName" 93 | 94 | $content = "" 95 | $content += "" 96 | $content += "" 97 | $content += "" 98 | $content += "" 99 | $content += "" 100 | $content += "" 101 | $content += "" 102 | $content += "" 103 | $content += "" 104 | $content += "" 105 | $content += "" 106 | $content += "
Active Directory Forest$($forest.Name)
Forest Schema$schemaVersion
Forest Mode Level$flvl
Root Domain Level$dlvl
FSMO - PDC emulator$pdcnx ($pdcIP - $pdcOS)
FSMO - Infrastructure master$imnx ($imIP - $imOS)
FSMO - RID master$ridnx ($ridIP - $ridOS)
FSMO - Schema master$smdcx
FSMO - Naming master$smnmx
Global Catalogs
    $($forest.GlobalCatalogs | %{"
  • $_
  • "})
Partitions
    $($forest.ApplicationPartitions | %{"
  • $_
  • "})
" 107 | 108 | @" 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 |

$PageCaption

117 | 118 | $content 119 | 120 | 121 | 122 | "@ -------------------------------------------------------------------------------- /poshserver/adgroup.ps1: -------------------------------------------------------------------------------- 1 | $SearchField = Get-PageParam -TagName 'f' -Default "" 2 | $SearchValue = Get-PageParam -TagName 'v' -Default "" 3 | $SearchType = Get-PageParam -TagName 'x' -Default 'like' 4 | $SortField = Get-PageParam -TagName 's' -Default 'Name' 5 | $SortOrder = Get-PageParam -TagName 'so' -Default 'Asc' 6 | $TabSelected = Get-PageParam -TagName 'tab' -Default 'general' 7 | $Detailed = Get-PageParam -TagName 'zz' -Default "" 8 | 9 | $PageTitle = "AD Group: $SearchValue" 10 | $PageCaption = "AD Group: $SearchValue" 11 | $content = "" 12 | $tabset = "" 13 | 14 | if ($SkNotesEnable -eq 'true') { 15 | $tabs = @('General','Members','Notes') 16 | } 17 | else { 18 | $tabs = @('General','Members') 19 | } 20 | 21 | switch ($TabSelected) { 22 | 'General' { 23 | try { 24 | $group = Get-ADsGroups | Where-Object {$_."$SearchField" -eq $SearchValue} 25 | $content = " 26 | 27 | 28 | 29 | 30 | 31 | 32 |
Name$($group.Name)
LDAP Path$($group.DN)
OU Path$($group.OU)
Description$($group.Description)
Date Created$($group.Created)
Last Modified$($group.Changed)
" 33 | } 34 | catch { 35 | $content += $Error[0].Exception.Message 36 | } 37 | break; 38 | } 39 | 'Members' { 40 | try { 41 | $rowcount = 0 42 | $columns = @('UserName','Title','Type','LDAP Path', '...') 43 | $members = Get-ADsGroupMembers -GroupName $SearchValue | Sort-Object UserName 44 | $xxx = "members: $($members.count)" 45 | $content += "" 46 | $content += "" 47 | #$content += New-ColumnSortRow -ColumnNames $columns -BaseLink "adgroup.ps1?f=name&v=$SearchValue" -SortDirection $SortOrder 48 | $content += $columns | ForEach-Object { "" } 49 | $content += "" 50 | foreach ($member in $members) { 51 | $uname = $member.UserName 52 | if ($member.Type -eq 'User') { 53 | $xlink = "aduser.ps1?f=UserName&v=$uname&x=equals&tab=general" 54 | } 55 | else { 56 | $xlink = "adgroup.ps1?f=name&v=$uname&x=equals&tab=general" 57 | } 58 | $rmvlink = "Remove" 59 | $content += "" 60 | $content += "" 61 | $content += "" 62 | $content += "" 63 | $content += "" 64 | $content += "" 65 | $rowcount++ 66 | } 67 | $content += "" 68 | $content += "
$_
$uname$($member.Title)$($member.Type)$($member.DN)$rmvlink
$(Write-RowCount -ItemName 'member' -RowCount $rowcount)

" 69 | $content += "
" 70 | $content += "" 71 | $content += "" 72 | $content += "" 73 | $content += "
" 74 | } 75 | catch { 76 | $content += $Error[0].Exception.Message 77 | } 78 | break; 79 | } 80 | 'Notes' { 81 | $content += Show-NoteAttachments -ObjectType "adgroup" -ObjectName $SearchValue -ReturnBaseLink "adgroup.ps1" -ReturnBaseSearchField "name" 82 | break; 83 | } 84 | } # switch 85 | $tabset = New-MenuTabSet2 -MenuTabs $tabs -BaseLink "adgroup.ps1" 86 | $content += Write-DetailInfo -PageRef "adgroup.ps1" -Mode $Detailed 87 | 88 | @" 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 |

$PageCaption

97 | 98 | $tabset 99 | $content 100 | 101 | 102 | 103 | "@ -------------------------------------------------------------------------------- /poshserver/adgroups.ps1: -------------------------------------------------------------------------------- 1 | Get-SkParams | Out-Null 2 | 3 | $PageTitle = "AD Groups" 4 | if (![string]::IsNullOrEmpty($Script:SearchValue)) { 5 | $PageTitle += ": $($Script:SearchValue)" 6 | } 7 | $content = "" 8 | $menulist = "" 9 | $tabset = "" 10 | $pagelink = Split-Path -Leaf $MyInvocation.MyCommand.Definition 11 | 12 | $tabset = New-MenuTabSet -BaseLink 'adgroups.ps1?x=begins&f=name&v=' -DefaultID $TabSelected 13 | $content = Get-ADObjectTableMultiple -ObjectType 'group' -Columns ('Name','Description') -SortColumn "Name" -NoSortHeadings 14 | 15 | Show-SkPage -------------------------------------------------------------------------------- /poshserver/admod.ps1: -------------------------------------------------------------------------------- 1 | [string]$username = $PoshPost.userid 2 | [string]$groupname = $PoshPost.groupid 3 | [string]$opname = $PoshPost.op 4 | 5 | if ([string]::IsNullOrEmpty($username)) { 6 | [string]$username = $PoshQuery.userid 7 | } 8 | if ([string]::IsNullOrEmpty($groupname)) { 9 | [string]$groupname = $PoshQuery.groupid 10 | } 11 | if ([string]::IsNullOrEmpty($opname)) { 12 | [string]$opname = $PoshQuery.op 13 | } 14 | 15 | $PageTitle = "AD Account Operation: $opname" 16 | $PageCaption = $PageTitle 17 | 18 | $blockedGroups = @( 19 | 'Access Control Assistance Operators', 20 | 'Administrators', 21 | 'Allowed RODC Password Replication Group', 22 | 'Cert Publishers', 23 | 'Certificate Service DCOM Access', 24 | 'Cloneable Domain Controllers', 25 | 'Cryptographic Operators', 26 | 'Denied RODC Password Replication Group', 27 | 'DHCP Users', 28 | 'Distributed COM Users', 29 | 'DnsAdmins', 30 | 'DnsUpdateProxy', 31 | 'Domain Admins', 32 | 'Domain Computers', 33 | 'Domain Controllers', 34 | 'Domain Guests', 35 | 'Domain Users', 36 | 'Enterprise Admins', 37 | 'Enterprise Key Admins', 38 | 'Enterprise Read-only Domain Controllers', 39 | 'Group Policy Creator Owners', 40 | 'Guests', 41 | 'IIS_IUSRS', 42 | 'Incoming Forest Trust Builders', 43 | 'Key Admins', 44 | 'Network Configuration Operators', 45 | 'Pre-Windows 2000 Compatible Access', 46 | 'Protected Users', 47 | 'RAS and IAS Servers', 48 | 'RDS Endpoint Servers', 49 | 'RDS Management Servers', 50 | 'RDS Remote Access Servers', 51 | 'Read-only Domain Controllers', 52 | 'Remote Management Users', 53 | 'Replicator', 54 | 'Schema Admins', 55 | 'Server Operators', 56 | 'Storage Replica Administrators', 57 | 'System Managed Accounts Group', 58 | 'Terminal Server License Servers', 59 | 'Users', 60 | 'Windows Authorization Access Group' 61 | ) 62 | 63 | if ([string]::IsNullOrEmpty($username) -and [string]::IsNullOrEmpty($groupname)) { 64 | $content = "
" 65 | $content += "Missing required parameters: userid -and- groupid
" 66 | } 67 | else { 68 | if (![string]::IsNullOrEmpty($username) -and ![string]::IsNullOrEmpty($groupname)) { 69 | # both input params were provided 70 | $content = "
both
" 71 | } 72 | elseIf (![string]::IsNullOrEmpty($username)) { 73 | # username provided, prompt for group 74 | $list = "" 75 | [array]$groupsAll = Get-ADsGroups | Sort-Object Name | Select -ExpandProperty Name 76 | [array]$groupsUsr = Get-ADsUserGroups -UserName $username | Sort-Object Name | Select -ExpandProperty Name 77 | [array]$result = $groupsAll | Select-String $($groupsUsr -join "|") -NotMatch 78 | foreach ($item in $result) { 79 | if ($item -notin $blockedGroups) { 80 | $list += "" 81 | } 82 | } 83 | $content = "

$opname`: $username to AD Groups

" 84 | $content += "
" 85 | $content += "" 86 | $content += "" 87 | $content += "
" 88 | $content += "
" 91 | $content += " " 92 | $content += "" 93 | $content += "
" 94 | } 95 | else { 96 | # groupname provided, prompt for user 97 | $content = "

$opname $username to AD Group

" 98 | $content += "
" 99 | $content += "... form data ..." 100 | $content += "
" 101 | } 102 | } 103 | 104 | @" 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 |

$PageCaption

113 | 114 | $content 115 | 116 | 117 | 118 | "@ -------------------------------------------------------------------------------- /poshserver/admod2.ps1: -------------------------------------------------------------------------------- 1 | [string]$username = $PoshPost.userid 2 | [string]$groupname = $PoshPost.groupid 3 | [string]$opname = $PoshPost.op 4 | 5 | if ([string]::IsNullOrEmpty($username)) { 6 | [string]$username = $PoshQuery.userid 7 | } 8 | if ([string]::IsNullOrEmpty($groupname)) { 9 | [string]$groupname = $PoshQuery.groupid 10 | } 11 | if ([string]::IsNullOrEmpty($opname)) { 12 | [string]$opname = $PoshQuery.op 13 | } 14 | 15 | $PageTitle = "AD Account Operation: $opname" 16 | $PageCaption = $PageTitle 17 | 18 | if ([string]::IsNullOrEmpty($username) -or [string]::IsNullOrEmpty($groupname)) { 19 | $content = "
" 20 | $content += "Username or Groupname parameters were not provided
" 21 | } 22 | else { 23 | try { 24 | [adsi]$group = "WinNT://contoso/$groupname,group" 25 | switch($opname) { 26 | 'addmember' { 27 | [void]$group.Add("WinNT://contoso/$username,user") 28 | break; 29 | } 30 | 'delmember' { 31 | [void]$group.Remove("WinNT://contoso/$username,user") 32 | break; 33 | } 34 | } 35 | $result = "success" 36 | } 37 | catch { 38 | $result = "failed: $($Error[0].Exception.Message)" 39 | } 40 | finally { 41 | $content = "" 42 | $content += "" 43 | $content += "" 44 | $content += "" 45 | $content += "
action: $opname
result: $result
Return to User Account
" 46 | } 47 | } 48 | 49 | @" 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 |

$PageCaption

58 | 59 | $content 60 | 61 | 62 | 63 | "@ -------------------------------------------------------------------------------- /poshserver/adrep.ps1: -------------------------------------------------------------------------------- 1 | $MaxLoginDays = Get-PageParam -TagName "d" -Default "" 2 | $AccountType = Get-PageParam -TagName "a" -Default "" 3 | $PageTitle = "AD Reports: Last Login > $MaxLoginDays days" 4 | $PageCaption = "AD Reports: Last Login > $MaxLoginDays days" 5 | 6 | try { 7 | switch ($AccountType) { 8 | "user" { 9 | $users = @(Get-ADsUsers) 10 | $uDates = @($users | Select -ExpandProperty LastLogon) 11 | 12 | $content = "" 13 | $content += "" 14 | 15 | $ulist = $users | ?{(New-TimeSpan -Start $_.LastLogon -End (Get-Date)).Days -gt $MaxLoginDays} 16 | 17 | foreach ($usr in $ulist) { 18 | $ux = Get-AdValueLink -PropertyName "UserName" -Value $($usr.Name) 19 | $content += "" 20 | $content += "" 21 | $content += "" 22 | $content += "" 23 | $content += "" 24 | } 25 | $content += "" 26 | $content += "
User NameDistinguishedNameLogin
$ux$([string]$usr.DN)$([string]$usr.LastLogon)
$($ulist.Count) users
" 27 | break; 28 | } 29 | "computer" { 30 | $comps = @(Get-ADsComputers -SearchType All) 31 | $mDates = @($comps | Select -ExpandProperty LastLogon) 32 | 33 | $content = "" 34 | $content += "" 35 | 36 | $mlist = $comps | ?{(New-TimeSpan -Start $_.LastLogon -End (Get-Date)).Days -gt $MaxLoginDays} 37 | 38 | foreach ($m in $mlist) { 39 | $cx = Get-AdValueLink -PropertyName "ComputerName" -Value $($m.Name) 40 | $content += "" 41 | $content += "" 42 | $content += "" 43 | $content += "" 44 | $content += "" 45 | } 46 | $content += "" 47 | $content += "
Computer NameDistinguishedNameLogin
$cx$([string]$m.DN)$([string]$m.LastLogon)
$($ulist.Count) computers
" 48 | break; 49 | } 50 | } # switch 51 | } 52 | catch { 53 | $content = "
Error: $($Error[0].Exception.Message)
" 54 | } 55 | 56 | @" 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 |

$PageCaption

65 | 66 | $content 67 | 68 | 69 | 70 | "@ -------------------------------------------------------------------------------- /poshserver/adreps.ps1: -------------------------------------------------------------------------------- 1 | $PageTitle = "AD Reports" 2 | $PageCaption = "AD Reports" 3 | 4 | $users = Get-ADsUsers 5 | $comps = Get-ADsComputers -SearchType All 6 | $noexp = Get-ADsUserPwdNoExpire 7 | $exps = Get-ADsUserPwdExpirations | ? {$_.Expires -lt 14} | ? {$_.UserName -ne 'krbtgt'} 8 | 9 | $uDates = $users | Select -ExpandProperty LastLogon 10 | $mDates = $comps | Select -ExpandProperty LastLogon 11 | 12 | $dayslist = @(30, 60, 90, 180, 365) 13 | 14 | $content = "" 15 | $content += "
" 16 | 17 | $content += "

User Accounts

" 18 | 19 | $content += "" 20 | $content += "" 21 | foreach ($dx in $dayslist) { 22 | $content += "" 23 | $num = ($uDates | %{(New-TimeSpan -Start $_ -End $(Get-Date)).Days} | ?{$_ -gt $dx}).Count 24 | $content += "" 25 | $content += "" 26 | $content += "" 27 | } 28 | $content += "" 30 | $content += "" 32 | $content += "
UsersDays since last login
$num$dx days
" 29 | $content += "$($noexp.Count)Password never expires
" 31 | $content += "$($exps.Count)Password expires within 14 days
" 33 | 34 | $content += "
" 35 | 36 | $content += "

Computer Accounts

" 37 | 38 | $content += "" 39 | $content += "" 40 | foreach ($dx in $dayslist) { 41 | $content += "" 42 | $num = ($mDates | %{(New-TimeSpan -Start $_ -End $(Get-Date)).Days} | ?{$_ -gt $dx}).Count 43 | $content += "" 44 | $content += "" 45 | $content += "" 46 | } 47 | $content += "
ComputersDays since last login
$num$dx days
" 48 | 49 | $content += "
" 50 | 51 | @" 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 |

$PageCaption

60 | 61 | $content 62 | 63 | 64 | 65 | "@ -------------------------------------------------------------------------------- /poshserver/adsites.ps1: -------------------------------------------------------------------------------- 1 | $SearchField = Get-PageParam -TagName 'f' -Default "" 2 | $SearchValue = Get-PageParam -TagName 'v' -Default "" 3 | $SearchType = Get-PageParam -TagName 'x' -Default 'like' 4 | $SortField = Get-PageParam -TagName 's' -Default 'Name' 5 | $SortOrder = Get-PageParam -TagName 'so' -Default 'Asc' 6 | $TabSelected = Get-PageParam -TagName 'tab' -Default 'all' 7 | $Detailed = Get-PageParam -TagName 'zz' -Default "" 8 | $CustomName = Get-PageParam -TagName 'n' -Default "" 9 | 10 | $PageTitle = "AD Sites" 11 | $PageCaption = "AD Sites" 12 | $content = "" 13 | $tabset = "" 14 | 15 | try { 16 | $Forest = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest() 17 | $sitelist = $Forest.Sites | ForEach-Object { 18 | $sitename = [string]$_.name 19 | $subnets = [string[]]$_.subnets 20 | $locname = [string]$_.Location 21 | $adjsites = [string[]]$_.AdjacentSites 22 | $props = [ordered]@{ 23 | SiteName = $sitename 24 | Location = $locname 25 | Subnets = $($subnets | %{$_}) 26 | AdjacentSites = $adjsites 27 | } 28 | New-Object PSObject -Property $props 29 | } 30 | $content = "" 31 | $content += "" 32 | $rowcount = 0 33 | $sitelist | ForEach-Object { 34 | $content += "" 35 | $content += "" 36 | $content += "" 37 | $content += "" 38 | $content += "" 39 | $rowcount++ 40 | } 41 | $content += "" 42 | $content += "
NameLocationSubnetsAdjacent Sites
$($_.SiteName)$($_.Location)$($_.Subnets -join ',')$($_.AdjacentSites -join ',')
$(Write-RowCount 'site' $rowcount)
" 43 | } 44 | catch { 45 | $content += "
$($Error[0].Exception.Message)
" 46 | } 47 | 48 | @" 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 |

$PageCaption

57 | 58 | $tabset 59 | $content 60 | 61 | 62 | 63 | "@ -------------------------------------------------------------------------------- /poshserver/adtool.ps1: -------------------------------------------------------------------------------- 1 | $DeviceName = Get-PageParam -Tagname 'c' -Default "" 2 | $ToolName = Get-PageParam -Tagname 't' -Default "" 3 | 4 | $ReturnLink = "Return" 5 | 6 | switch ($ToolName) { 7 | 'gpupdate' { 8 | $output = Invoke-Command -ComputerName $DeviceName -ScriptBlock { "GPUPDATE.exe /FORCE" } 9 | $result = "Result = $output" 10 | break; 11 | } 12 | } 13 | 14 | $content = "
$result

$ReturnLink
" 15 | 16 | @" 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 |

$PageCaption

25 | 26 | $content 27 | 28 | 29 | 30 | "@ -------------------------------------------------------------------------------- /poshserver/aduserpwdexp.ps1: -------------------------------------------------------------------------------- 1 | $SearchField = Get-PageParam -TagName 'f' -Default "" 2 | $SearchValue = Get-PageParam -TagName 'v' -Default "" 3 | $SearchType = Get-PageParam -TagName 'x' -Default "" 4 | $SortField = Get-PageParam -TagName 's' -Default "" 5 | $SortOrder = Get-PageParam -TagName 'so' -Default "" 6 | $TabSelected = Get-PageParam -TagName 'tab' -Default "" 7 | $Detailed = Get-PageParam -TagName 'zz' -Default "" 8 | $Extension1 = Get-PageParam -TagName 'x1' -Default "" 9 | $CustomFlag = Get-PageParam -TagName 'p' -Default "" 10 | $IsFiltered = $False 11 | $content = "" 12 | $tabset = "" 13 | 14 | switch ($CustomFlag) { 15 | "0" { 16 | $PageTitle = "AD Reports: Non-Expiring Password" 17 | $PageCaption = "AD Reports: Non-Expiring Password" 18 | try { 19 | $users = Get-ADsUserPwdNoExpire 20 | $content = "" 21 | $content += "" 22 | $rowcount = 0 23 | foreach ($user in $users) { 24 | $name = $user.Name 25 | $dn = $user.DistinguishedName 26 | $udata = [adsi]"LDAP://$dn" 27 | $usam = [string] $udata.sAMaccountName 28 | $ulink = "$usam" 29 | $content += "" 30 | $rowcount++ 31 | } 32 | $content += "" 33 | $content += "
UserNameNameLDAP Path
$ulink$name$dn
$rowcount accounts
" 34 | } 35 | catch { 36 | $content += "
" 37 | $content += "$($Error[0].Exception.Message)
" 38 | } 39 | break; 40 | } 41 | "1" { 42 | $PageTitle = "AD Reports: Password Expires Soon" 43 | $PageCaption = "AD Reports: Password Expires Soon" 44 | try { 45 | $users = Get-ADsUserPwdExpirations | ? {$_.Expires -lt 14} | ? {$_.UserName -ne 'krbtgt'} 46 | $content = "" 47 | $content += "" 48 | $rowcount = 0 49 | foreach ($user in $users) { 50 | $name = $user.UserName 51 | $pwdset = $user.LastPwdSet 52 | $pwdexp = $user.Expires 53 | $ulink = "$usam" 54 | $content += "" 55 | $rowcount++ 56 | } 57 | if ($rowcount -eq 0) { 58 | $content += "" 59 | } 60 | $content += "" 61 | $content += "
UserNamePwd SetDays Left
$ulink$pwdset$pwdexp
No user accounts were found that are expiring within 14 days
$rowcount accounts
" 62 | } 63 | catch { 64 | $content += "
" 65 | $content += "$($Error[0].Exception.Message)
" 66 | } 67 | break; 68 | } 69 | } 70 | 71 | 72 | 73 | @" 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 |

$PageCaption

82 | 83 | $content 84 | 85 | 86 | 87 | "@ -------------------------------------------------------------------------------- /poshserver/adusers.ps1: -------------------------------------------------------------------------------- 1 | Get-SkParams | Out-Null 2 | 3 | $PageTitle = "AD Users" 4 | if (![string]::IsNullOrEmpty($Script:SearchValue)) { 5 | $PageTitle += ": $($Script:SearchValue)" 6 | } 7 | $content = "" 8 | $menulist = "" 9 | $tabset = "" 10 | $pagelink = Split-Path -Leaf $MyInvocation.MyCommand.Definition 11 | 12 | $tabset = New-MenuTabSet -BaseLink 'adusers.ps1?x=begins&f=username&v=' -DefaultID $TabSelected 13 | $content = Get-ADObjectTableMultiple -ObjectType 'user' -Columns ('UserName','DisplayName','Title','Department','LastLogon') -SortColumn "UserName" -NoSortHeadings 14 | 15 | Show-SkPage -------------------------------------------------------------------------------- /poshserver/attachnote.ps1: -------------------------------------------------------------------------------- 1 | $ObjectType = $PoshPost.otype 2 | $ObjectName = $PoshPost.oid 3 | 4 | switch($ObjectType) { 5 | 'aduser' { 6 | $keyname = 'username' 7 | break 8 | } 9 | 'adgroup' { 10 | $keyname = 'name' 11 | break 12 | } 13 | 'adcomputer' { 14 | $keyname = 'name' 15 | break 16 | } 17 | } 18 | $ReturnLink = "$ObjectType.ps1?f=$keyname&v=$ObjectName&tab=notes" 19 | 20 | @" 21 | 22 | 23 | 24 | 25 | 26 | 27 |

Attach a Note

28 | 29 |
30 | 31 | 32 | 33 | 34 | 35 | 38 | 39 | 40 | 43 | 44 | 45 | 49 | 50 |
36 | Type: $ObjectType | Name: $ObjectName | Link: $ReturnLink 37 |
41 | 42 |
46 | 47 | 48 |
51 |
52 | 53 | 54 | 55 | "@ -------------------------------------------------------------------------------- /poshserver/attachnote2.ps1: -------------------------------------------------------------------------------- 1 | $Comment = $PostPost.comment 2 | $ObjectType = $PoshPost.otype 3 | $ObjectName = $PoshPost.oid 4 | 5 | switch($ObjectType) { 6 | 'aduser' { 7 | $keyname = 'username' 8 | break 9 | } 10 | 'adgroup' { 11 | $keyname = 'name' 12 | break 13 | } 14 | 'adcomputer' { 15 | $keyname = 'name' 16 | break 17 | } 18 | } 19 | $xxx = "objecttype: $ObjectType
objectname: $ObjectName
keyname: $keyname" 20 | $TargetLink = "$ObjectType.ps1`?f=$keyname&v=$ObjectName&tab=notes" 21 | $xxx += "
target: $TargetLink" 22 | $xxx += "
comment: $Comment" 23 | 24 | if ([string]::IsNullOrEmpty($Comment)) { 25 | $content = "
No text was entered for note attachment
" 26 | } 27 | else { 28 | New-NoteAttachment -Comment -ObjectType -ObjectID 29 | $content = "
30 |

Adding Note...

31 |
32 |

33 | `"`"

34 |
" 35 | } 36 | $content = "
$xxx
" 37 | 38 | @" 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 |

$PageCaption

48 | 49 | $content 50 | 51 | 52 | 53 | "@ -------------------------------------------------------------------------------- /poshserver/banner.ps1: -------------------------------------------------------------------------------- 1 | $img = "" 2 | switch ($Global:AppName) { 3 | 'DeathFace' { $img = ""; break; } 4 | 'SkyDouche' { $img = ""; break; } 5 | } 6 | @" 7 | 8 | 9 | 10 | 11 | 12 | $img $($Global:AppName) 13 | 14 | 15 | "@ -------------------------------------------------------------------------------- /poshserver/cmaddmember.ps1: -------------------------------------------------------------------------------- 1 | $ResourceName = $PoshPost.resname 2 | $ResourceType = $PoshPost.restype 3 | $ResourceID = $PoshPost.resid 4 | $CollectionName = $PoshPost.collid 5 | #$CollectionName = $PoshPost.collname 6 | 7 | $PageTitle = "Add Collection Member" 8 | $PageCaption = $PageTitle 9 | $content = "" 10 | $query = "" 11 | $tabset = "" 12 | 13 | if ($ResourceID.IndexOf(':') -gt 0) { 14 | $xx = $ResourceID -split ':' 15 | $ResourceID = $xx[0] 16 | $ResourceName = $xx[1] 17 | } 18 | 19 | switch ($ResourceType) { 20 | 5 { 21 | $TargetLink = "cmdevice.ps1?f=resourceid&v=$ResourceID&x=equals&n=$ResourceName&tab=Collections" 22 | $laststep = "defined targetlink: device" 23 | break; 24 | } 25 | 4 { 26 | $TargetLink = "cmuser.ps1?f=resourceid&v=$ResourceID&x=equals&n=$ResourceName&tab=Collections" 27 | $laststep = "defined targetlink: user" 28 | break; 29 | } 30 | } 31 | 32 | #$result = Add-CMCollectionMemberDirect -CollectionName $CollectionName -ResourceName $ResourceName 33 | try { 34 | switch ($ResourceType) { 35 | 5 { 36 | if ($ResourceID -eq "") { 37 | $laststep = "getting resourceid" 38 | [string]$ResourceID = $(Get-WmiObject -ComputerName $CmSMSProvider -Namespace "Root\Sms\Site_$CmSiteCode" -Query "Select * From SMS_R_System Where Name='$($ResourceName)'").ResourceID 39 | } 40 | $laststep = "defining new rule object" 41 | $SmsNewRule = $([wmiclass]$("\\$($CmSMSProvider)\root\sms\site_$($CmSiteCode):SMS_CollectionRuleDirect")).CreateInstance() 42 | $laststep = "getting collection object" 43 | $SmsCollection = Get-WmiObject -ComputerName $CmSMSProvider -Namespace "Root\Sms\Site_$CmSiteCode" -Query "Select * From SMS_Collection Where Name='$($CollectionName)'" 44 | [void]$SmsCollection.Get() 45 | $SmsNewRule.ResourceClassName = "SMS_R_System" 46 | $SmsNewRule.ResourceID = $ResourceID 47 | $SmsNewRule.RuleName = $ResourceName 48 | $laststep = "adding rule to collection" 49 | [System.Management.ManagementBaseObject[]]$SmsRules = $SmsCollection.CollectionRules 50 | $SmsRules += $SmsNewRule 51 | $SmsCollection.CollectionRules = $SmsRules 52 | $laststep = "updating collection" 53 | [void]$SmsCollection.Put() 54 | $laststep = "update completed" 55 | $result = "Success" 56 | break; 57 | } 58 | 4 { 59 | $result = "NotImplemented" 60 | break; 61 | } 62 | } # switch 63 | } 64 | catch { 65 | $result = "Error: $($Error[0].Exception.Message)" 66 | } 67 | 68 | $content = "" 69 | $content += "" 70 | $content += "" 71 | $content += "" 72 | $content += "" 73 | $content += "" 74 | $content += "" 75 | $content += "" 76 | $content += "" 77 | 78 | $content += "" 79 | $content += "" 82 | $content += "
Resource Name$ResourceName
Resource ID$ResourceID
Resource Type$ResourceType
Collection Name$CollectionName
SMS Provider$CmSMSProvider
SMS Site Code$CmSiteCode
Request Status$result
Last step$laststep
Return Link$TargetLink
" 80 | $content += "

Adding to collection...

" 81 | $content += "
" 83 | 84 | #$content += Write-DetailInfo -PageRef "addmember.ps1" -Mode $Detailed 85 | 86 | @" 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 |

$PageCaption

96 | 97 | $content 98 | 99 | 100 | 101 | "@ -------------------------------------------------------------------------------- /poshserver/cmappinstalls.ps1: -------------------------------------------------------------------------------- 1 | $ProductName = Get-PageParam -TagName 'p' -Default "" 2 | $Publisher = Get-PageParam -TagName 'm' -Default "" 3 | $Version = Get-PageParam -TagName 'v' -Default "" 4 | $SortField = Get-PageParam -TagName 's' -Default "ComputerName" 5 | $PageTitle = "App Installs: $ProductName" 6 | $PageCaption = "App Installs: $ProductName" 7 | $SortField = "" 8 | $content = "" 9 | $tabset = "" 10 | 11 | try { 12 | if ([string]::IsNullOrEmpty($ProductName)) { 13 | throw "Product name was not specified" 14 | } 15 | $query = "SELECT 16 | dbo.v_R_System.ResourceID, 17 | dbo.v_R_System.Name0 as ComputerName 18 | FROM 19 | dbo.v_GS_ADD_REMOVE_PROGRAMS INNER JOIN 20 | dbo.v_R_System ON dbo.v_GS_ADD_REMOVE_PROGRAMS.ResourceID = dbo.v_R_System.ResourceID 21 | WHERE 22 | (dbo.v_GS_ADD_REMOVE_PROGRAMS.DisplayName0 = '$ProductName')" 23 | 24 | if (![string]::IsNullOrEmpty($Publisher)) { 25 | $query += " AND (dbo.v_GS_ADD_REMOVE_PROGRAMS.Publisher0 = '$Publisher')" 26 | } 27 | if (![string]::IsNullOrEmpty($Version)) { 28 | $query += " AND (dbo.v_GS_ADD_REMOVE_PROGRAMS.Version0 = '$Version')" 29 | } 30 | 31 | $query += " ORDER BY Name0" 32 | 33 | $result = @(Invoke-DbaQuery -SqlInstance $CmDbHost -Database "CM_$CmSiteCode" -Query $query -ErrorAction SilentlyContinue) 34 | $result = $result | Sort-Object $SortField 35 | 36 | 37 | } 38 | catch {} 39 | 40 | @" 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 |

$PageCaption

49 | 50 | $tabset 51 | $content 52 | 53 | 54 | 55 | "@ -------------------------------------------------------------------------------- /poshserver/cmapps.ps1: -------------------------------------------------------------------------------- 1 | $SearchField = Get-PageParam -TagName 'f' -Default "" 2 | $SearchValue = Get-PageParam -TagName 'v' -Default "" 3 | $SearchType = Get-PageParam -TagName 'x' -Default "" 4 | $SortField = Get-PageParam -TagName 's' -Default "" 5 | $SortOrder = Get-PageParam -TagName 'so' -Default "" 6 | $TabSelected = Get-PageParam -TagName 'tab' -Default "" 7 | $Detailed = Get-PageParam -TagName 'zz' -Default "" 8 | $CustomName = Get-PageParam -TagName 'n' -Default "" 9 | $IsFiltered = $False 10 | $PageTitle = "CM Applications" 11 | $PageCaption = "CM Applications" 12 | $content = "" 13 | $tabset = "" 14 | $outree = $null 15 | $query = $null 16 | $xxx = "" 17 | 18 | try { 19 | $query = "SELECT DISTINCT 20 | dbo.v_GS_ADD_REMOVE_PROGRAMS.DisplayName0, 21 | dbo.v_GS_ADD_REMOVE_PROGRAMS.Publisher0, 22 | dbo.v_GS_ADD_REMOVE_PROGRAMS.Version0, 23 | COUNT(*) AS Installs 24 | FROM 25 | dbo.v_R_System INNER JOIN 26 | dbo.v_GS_ADD_REMOVE_PROGRAMS ON 27 | dbo.v_R_System.ResourceID = dbo.v_GS_ADD_REMOVE_PROGRAMS.ResourceID 28 | GROUP BY 29 | DisplayName0, 30 | Publisher0, 31 | Version0" 32 | $result = @(Invoke-DbaQuery -SqlInstance $CmDbHost -Database "CM_$CmSiteCode" -Query $query -ErrorAction SilentlyContinue) 33 | if ($result.Count -gt 0) { 34 | $content = "" 35 | foreach ($rs in $result) { 36 | $pn = $rs.ProductName 37 | $pv = $rs.Version 38 | $vn = $rs.Publisher 39 | $qx = $rs.Installs 40 | $content += "" 41 | } 42 | $content += "
$pn$pv$vn$qx
" 43 | } 44 | } 45 | catch { 46 | $content = "
Error: $($Error[0].Exception.Message)
" 47 | } 48 | 49 | @" 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 |

$PageCaption

58 | 59 | $tabset 60 | $content 61 | 62 | 63 | 64 | "@ -------------------------------------------------------------------------------- /poshserver/cmbgroup.ps1: -------------------------------------------------------------------------------- 1 | $SearchField = Get-PageParam -TagName 'f' -Default "" 2 | $SearchValue = Get-PageParam -TagName 'v' -Default "" 3 | $SearchType = Get-PageParam -TagName 'x' -Default "like" 4 | $SortField = Get-PageParam -TagName 's' -Default "name" 5 | $SortOrder = Get-PageParam -TagName 'so' -Default "asc" 6 | $TabSelected = Get-PageParam -TagName 'tab' -Default 'General' 7 | $Detailed = Get-PageParam -TagName 'zz' -Default "" 8 | $CustomName = Get-PageParam -TagName 'n' -Default "" 9 | $IsFiltered = $False 10 | $PageTitle = "CM Boundary Group: $CustomName" 11 | $PageCaption = "CM Boundary Group: $CustomName" 12 | $content = "" 13 | $tabset = "" 14 | $outree = $null 15 | $query = $null 16 | $xxx = "" 17 | 18 | switch ($TabSelected) { 19 | 'General' { 20 | $xxx += ";queryfile: cmboundarygroup.sql" 21 | $content = Get-SkQueryTableSingle -QueryFile "cmboundarygroup.sql" -PageLink "cmbgroup.ps1" -Columns ('BGName','DefaultSiteCode','GroupID','GroupGUID','Description','Flags','CreatedBy','CreatedOn','ModifiedBy','ModifiedOn','MemberCount','SiteSystemCount','Shared') 22 | break; 23 | } 24 | 'Boundaries' { 25 | $xxx += ";queryfile: cmboundaries.sql" 26 | $content = Get-SkQueryTableMultiple -QueryFile "cmboundaries.sql" -PageLink "cmbgroup.ps1" -Columns ('DisplayName','BoundaryID','BValue','BoundaryType','BoundaryFlags','CreatedBy','CreatedOn','ModifiedBy','ModifiedOn','GroupID','BGName') -NoUnFilter 27 | break; 28 | } 29 | } 30 | 31 | if ($SkNotesEnable -eq 'true') { 32 | $tabs = @('General','Boundaries','Systems','Notes') 33 | } 34 | else { 35 | $tabs = @('General','Boundaries','Systems') 36 | } 37 | $tabset = New-MenuTabSet2 -MenuTabs $tabs -BaseLink "cmbgroup.ps1" 38 | $content += Write-DetailInfo -PageRef "cmbgroup.ps1" -Mode $Detailed 39 | 40 | @" 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 |

$PageCaption

49 | 50 | $tabset 51 | $content 52 | 53 | 54 | 55 | "@ -------------------------------------------------------------------------------- /poshserver/cmbgroups.ps1: -------------------------------------------------------------------------------- 1 | $Script:SearchField = Get-PageParam -TagName 'f' -Default "" 2 | $Script:SearchValue = Get-PageParam -TagName 'v' -Default "" 3 | $Script:SearchType = Get-PageParam -TagName 'x' -Default "like" 4 | $Script:SortField = Get-PageParam -TagName 's' -Default "Name" 5 | $Script:SortOrder = Get-PageParam -TagName 'so' -Default "asc" 6 | $Script:TabSelected = Get-PageParam -TagName 'tab' -Default 'all' 7 | $Script:Detailed = Get-PageParam -TagName 'zz' -Default "" 8 | $Script:CustomName = Get-PageParam -TagName 'n' -Default "" 9 | $Script:IsFiltered = $False 10 | $Script:PageTitle = "CM Boundary Groups" 11 | $Script:PageCaption = "CM Boundary Groups" 12 | $content = "" 13 | $tabset = "" 14 | $outree = $null 15 | $query = $null 16 | $xxx = "" 17 | 18 | $content = Get-SkQueryTableMultiple -QueryFile "cmboundarygroups.sql" -PageLink "cmbgroups.ps1" -Columns ('BGName','GroupID','Description','Flags','DefaultSiteCode','CreatedOn','Boundaries','SiteSystems') 19 | 20 | #$tabset = New-MenuTabSet -BaseLink 'cmbgroups.ps1?x=begins&f=bgname&v=' -DefaultID $Script:TabSelected 21 | $content += Write-DetailInfo -PageRef "cmgroups.ps1" -Mode $Detailed 22 | 23 | @" 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |

$PageCaption

32 | 33 | $tabset 34 | $content 35 | 36 | 37 | 38 | "@ -------------------------------------------------------------------------------- /poshserver/cmcerts.ps1: -------------------------------------------------------------------------------- 1 | $Script:SearchField = Get-PageParam -TagName 'f' -Default "" 2 | $Script:SearchValue = Get-PageParam -TagName 'v' -Default "" 3 | $Script:SearchType = Get-PageParam -TagName 'x' -Default "like" 4 | $Script:SortField = Get-PageParam -TagName 's' -Default "ServerName" 5 | $Script:SortOrder = Get-PageParam -TagName 'so' -Default "asc" 6 | $Script:TabSelected = Get-PageParam -TagName 'tab' -Default 'all' 7 | $Script:Detailed = Get-PageParam -TagName 'zz' -Default "" 8 | $Script:CustomName = Get-PageParam -TagName 'n' -Default "" 9 | $Script:IsFiltered = $False 10 | $Script:PageTitle = "CM Certificates" 11 | $Script:PageCaption = "CM Certificates" 12 | $content = "" 13 | $tabset = "" 14 | $outree = $null 15 | $query = $null 16 | $xxx = "" 17 | 18 | $content = Get-SkQueryTableMultiple -QueryFile "cmcerts.sql" -PageLink "cmcerts.ps1" -Columns ('ServerName','IssuedTo','CertType','KeyType','ValidFrom','ValidUntil','Approved','Blocked') 19 | 20 | #$tabset = New-MenuTabSet -BaseLink 'cmcerts.ps1?x=begins&f=name&v=' -DefaultID $TabSelected 21 | #$content += Write-DetailInfo -PageRef "cmcerts.ps1" -Mode $Detailed 22 | 23 | @" 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |

$PageCaption

32 | 33 | $tabset 34 | $content 35 | 36 | 37 | 38 | "@ -------------------------------------------------------------------------------- /poshserver/cmcollection.ps1: -------------------------------------------------------------------------------- 1 | $Script:SearchField = Get-PageParam -TagName 'f' -Default "CollectionName" 2 | $Script:SearchValue = Get-PageParam -TagName 'v' -Default "" 3 | $Script:SearchType = Get-PageParam -TagName 'x' -Default 'equals' 4 | $Script:SortField = Get-PageParam -TagName 's' -Default "CollectionName" 5 | $Script:SortOrder = Get-PageParam -TagName 'so' -Default 'Asc' 6 | $Script:TabSelected = Get-PageParam -TagName 'tab' -Default 'General' 7 | $Script:Detailed = Get-PageParam -TagName 'zz' -Default "" 8 | $Script:CustomName = Get-PageParam -TagName 'n' -Default "" 9 | $ScriptCollectionType = Get-PageParam -TagName 't' -Default "" 10 | $Script:IsFiltered = $False 11 | 12 | if ([string]::IsNullOrEmpty($Script:CustomName)) { 13 | $collName = Get-SkCmCollectionName -CollectionID $Script:SearchValue 14 | } 15 | else { 16 | $collName = $Script:CustomName 17 | } 18 | 19 | if ($CollectionType -eq '2') { 20 | $Ctype = "Device" 21 | $ResType = 5 22 | $CollType = 2 23 | } 24 | else { 25 | $Ctype = "User" 26 | $ResType = 4 27 | $CollType = 1 28 | } 29 | $Script:PageTitle = "CM Collection: $collName" 30 | $Script:PageCaption = "CM Collection: $collName" 31 | $content = "" 32 | $tabset = "" 33 | if ($SkNotesEnabled -eq "true") { 34 | $tabs = @('General','Members','QueryRules','Variables','Tools','Notes') 35 | } 36 | else { 37 | $tabs = @('General','Members','QueryRules','Variables','Tools') 38 | } 39 | 40 | switch ($Script:TabSelected) { 41 | 'General' { 42 | $xxx = "Collection Type: $CollType" 43 | $params = @{ 44 | QueryFile = "cmcollection.sql" 45 | PageLink = "cmcollection.ps1" 46 | Columns = ('CollectionName','CollectionID','Comment','Members','Type','Variables','LimitedTo') 47 | } 48 | $content = Get-SkQueryTableSingle @params 49 | #$content = Get-SkQueryTableSingle -QueryFile "cmcollection.sql" -PageLink "cmcollection.ps1" -Columns ('CollectionName','CollectionID','Comment','Members','Type','Variables','LimitedTo') 50 | break; 51 | } 52 | 'Members' { 53 | $xxx = "Collection Type: $CollType" 54 | if ($CollType -eq 2) { 55 | $qfile = "cmdevicecollectionmembers.sql" 56 | } 57 | else { 58 | $qfile = "cmusercollectionmembers.sql" 59 | } 60 | $content = Get-SkQueryTableMultiple -QueryFile $qfile -PageLink "cmcollection.ps1" -NoUnFilter -NoCaption 61 | break; 62 | } 63 | 'QueryRules' { 64 | $xxx = "Collection Type: $CollType" 65 | $content = Get-SkQueryTableMultiple -QueryFile "cmcollectionqueryrules.sql" -PageLink "cmcollection.ps1" -Columns ('RuleName','QueryID','QueryExpression','LimitToCollectionID') -NoUnFilter -NoCaption -Sorting "RuleName" 66 | break; 67 | } 68 | 'Variables' { 69 | $content = Get-SkQueryTableMultiple -QueryFile "cmcollectionvariables.sql" -PageLink "cmcollection.ps1" -Columns ('Name','Value','IsMasked') 70 | break; 71 | } 72 | 'Tools' { 73 | $content = "" 74 | $content += "" 75 | $content += "
Still in Development. Check back soon.
" 76 | break; 77 | } 78 | 'Notes' { 79 | $content = "" 80 | $content += "" 81 | $content += "
Still in Development. Check back soon.
" 82 | break; 83 | } 84 | } # switch 85 | 86 | $tabset = New-MenuTabSet2 -MenuTabs $tabs -BaseLink "cmcollection.ps1" 87 | 88 | $content += Write-DetailInfo -PageRef "cmcollection.ps1" -Mode $Detailed 89 | 90 | @" 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 |

$PageCaption

99 | 100 | $tabset 101 | $content 102 | 103 | 104 | 105 | "@ -------------------------------------------------------------------------------- /poshserver/cmcollections.ps1: -------------------------------------------------------------------------------- 1 | Get-SkParams | Out-Null 2 | $Script:CollectionType = Get-PageParam -TagName 't' -Default '2' 3 | if ($CollectionType -eq '2') { 4 | $Ctype = "Device" 5 | $qfname = "cmdevicecollections.sql" 6 | } 7 | else { 8 | $Ctype = "User" 9 | $qfname = "cmusercollections.sql" 10 | } 11 | 12 | $PageTitle = "CM $CType Collections" 13 | if (![string]::IsNullOrEmpty($Script:SearchValue)) { 14 | $PageTitle += ": $($Script:SearchValue)" 15 | } 16 | $content = "" 17 | $menulist = "" 18 | $tabset = "" 19 | $pagelink = Split-Path -Leaf $MyInvocation.MyCommand.Definition 20 | 21 | $content = Get-SkQueryTableMultiple -QueryFile $qfname -PageLink "cmcollections.ps1" -NoCaption 22 | $tabset = New-MenuTabSet -BaseLink "cmcollections.ps1?t=$CollectionType&f=collectionname&x=begins&v=" -DefaultID $TabSelected 23 | $content += Write-DetailInfo -PageRef "cmcollections.ps1" -Mode $Detailed 24 | 25 | Show-SkPage -------------------------------------------------------------------------------- /poshserver/cmcompstat.ps1: -------------------------------------------------------------------------------- 1 | $Script:SearchField = Get-PageParam -TagName 'f' -Default "" 2 | $Script:SearchValue = Get-PageParam -TagName 'v' -Default "" 3 | $Script:SearchType = Get-PageParam -TagName 'x' -Default 'exact' 4 | $Script:SortField = Get-PageParam -TagName 's' -Default 'ComponentName' 5 | $Script:CustomName = Get-PageParam -TagName 'n' -Default "" 6 | $Script:SortOrder = Get-PageParam -TagName 'so' -Default 'Asc' 7 | $Script:PageTitle = "CM Site Components" 8 | $Script:PageCaption = "CM Site Components" 9 | $tabset = "" 10 | 11 | $content = Get-SkQueryTableMultiple -QueryFile "cmcomponentstatus.sql" -PageLink "cmcompstat.ps1" -Columns ('ComponentName','Status','State','LastContacted','Info','Warning','Error') 12 | 13 | @" 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |

$PageCaption

22 | 23 | $tabset 24 | $content 25 | 26 | 27 | 28 | "@ -------------------------------------------------------------------------------- /poshserver/cmcompstats.ps1: -------------------------------------------------------------------------------- 1 | $Script:SearchField = Get-PageParam -TagName 'f' -Default "Component" 2 | $Script:SearchValue = Get-PageParam -TagName 'v' -Default "" 3 | $Script:SearchType = Get-PageParam -TagName 'x' -Default 'equals' 4 | $Script:SortField = Get-PageParam -TagName 's' -Default 'RecordID' 5 | $Script:SortOrder = Get-PageParam -TagName 'so' -Default 'DESC' 6 | $Script:TabSelected = Get-PageParam -TagName 'tab' -Default '' 7 | $Script:Detailed = Get-PageParam -TagName 'zz' -Default "" 8 | $Script:IsFiltered = $False 9 | $Script:PageTitle = "CM Component Status: $Script:SearchValue" 10 | $Script:PageCaption = "CM Component Status: $Script:SearchValue" 11 | $content = "" 12 | $tabset = "" 13 | $outree = $null 14 | $query = $null 15 | $xxx = "" 16 | 17 | $content = Get-SkQueryTableMultiple -QueryFile "cmcompstat.sql" -PageLink "cmcompstats.ps1" -Columns ('RecordID','MessageID','MessageType','Severity','MachineName','ModuleName','Win32Error','Time','SiteCode','TopLevelSiteCode','ProcessID','ThreadID','ReportFunction','SuccessfulTransaction','Transaction','PerClient') -NoUnFilter -NoCaption 18 | 19 | $content += Write-DetailInfo -PageRef "cmcompstats.ps1" -Mode $Detailed 20 | 21 | @" 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 |

$PageCaption

30 | 31 | $content 32 | 33 | 34 | 35 | "@ -------------------------------------------------------------------------------- /poshserver/cmdevice.ps1: -------------------------------------------------------------------------------- 1 | Get-SkParams | Out-Null 2 | $Script:SearchField = "Name" 3 | $Script:SearchType = "equals" 4 | 5 | $PageTitle = "CM Device" 6 | if (![string]::IsNullOrEmpty($Script:SearchValue)) { 7 | $PageTitle += ": $($Script:SearchValue)" 8 | } 9 | $content = "" 10 | $menulist = "" 11 | $tabset = "" 12 | $pagelink = Split-Path -Leaf $MyInvocation.MyCommand.Definition 13 | 14 | $plist = @('General','Storage','Collections','Disks','Network','Ping','Tools') 15 | $menulist = New-SkMenuList -PropertyList $plist -TargetLink "cmdevice.ps1?v=$Script:SearchValue" -Default $Script:TabSelected 16 | $tabset = $menulist 17 | 18 | switch ($TabSelected) { 19 | 'General' { 20 | $output = $null 21 | $params = @{ 22 | QueryFile = "cmdevice.sql" 23 | PageLink = "cmdevice.ps1" 24 | Columns = ('Name','ResourceID','Manufacturer','Model','SerialNumber','OperatingSystem','OSBuild','ClientVersion','LastHwScan','LastDDR','LastPolicyRequest','ADSiteName') 25 | } 26 | #$xxx = $params -join ';' 27 | $content = Get-SkQueryTableSingle @params 28 | break; 29 | } 30 | 'Collections' { 31 | try { 32 | $xxx = "query defined" 33 | $params = @{ 34 | QueryFile = "cmdevicecolls.sql" 35 | PageLink = "cmdevice.ps1" 36 | Columns = ('CollectionID','CollectionName') 37 | } 38 | $content = Get-SkQueryTableMultiple @params -NoUnFilter -NoCaption 39 | 40 | if ($CmCollectionManage -eq 'TRUE') { 41 | $dcolls = Get-CmDeviceCollectionMemberships -ComputerName $Script:SearchValue -Inverse 42 | if ($dcolls.count -gt 0) { 43 | $content += "
" 44 | $content += "" 45 | $content += "" 46 | $content += "" 47 | $content += "
" 48 | $content += " " 56 | $content += " (direct membership collections only)
" 57 | } 58 | } 59 | } 60 | catch { 61 | $content = "
Error: $($Error[0].Exception.Message)
" 62 | } 63 | break; 64 | } 65 | 'Network' { 66 | $content = Get-SkQueryTableMultiple -QueryFile "cmdevicenetconfigs.sql" -PageLink "cmdevice.ps1" 67 | break; 68 | } 69 | 'Disks' { 70 | $output = $null 71 | $content = Get-SkQueryTableMultiple -QueryFile "cmdevicedrives.sql" -PageLink "cmdevice.ps1" -Columns ('Drive','DiskType','Description','DiskSize','Used','FreeSpace','PCT') 72 | break; 73 | } 74 | 'Software' { 75 | $SearchField = 'Name0' 76 | $content = Get-SkQueryTableMultiple -QueryFile "cmdeviceapps.sql" -PageLink "cmdevice.ps1" -Columns ('ProductName','Publisher','Version') -Sorting "ProductName" -NoUnFilter -NoCaption 77 | break; 78 | } 79 | 'Notes' { 80 | break; 81 | } 82 | } 83 | 84 | $content += Write-DetailInfo -PageRef "cmdevice.ps1" -Mode $Detailed 85 | 86 | Show-SkPage -------------------------------------------------------------------------------- /poshserver/cmdevicecollections.ps1: -------------------------------------------------------------------------------- 1 | $SearchField = Get-PageParam -TagName 'f' -Default "" 2 | $SearchValue = Get-PageParam -TagName 'v' -Default "" 3 | $SearchType = Get-PageParam -TagName 'x' -Default 'like' 4 | $SortField = Get-PageParam -TagName 's' -Default 'CollectionName' 5 | $SortOrder = Get-PageParam -TagName 'so' -Default 'Asc' 6 | $TabSelected = Get-PageParam -TagName 'tab' -Default 'all' 7 | $Detailed = Get-PageParam -TagName 'zz' -Default "" 8 | $CustomName = "" 9 | 10 | $PageTitle = "CM Collections" 11 | $PageCaption = "CM Collections" 12 | $content = "" 13 | $tabset = "" 14 | 15 | if ($SearchField -eq 'collectionname') { 16 | $TabSelected = $SearchValue 17 | } 18 | if ($SearchValue -eq 'all') { 19 | $SearchValue = "" 20 | } 21 | else { 22 | $PageTitle += " ($SearchValue)" 23 | $PageCaption = $PageTitle 24 | } 25 | 26 | $query = 'SELECT DISTINCT 27 | dbo.v_Collection.Name as CollectionName, 28 | dbo.v_FullCollectionMembership.CollectionID, 29 | dbo.v_Collection.Comment, 30 | dbo.v_Collection.MemberCount as Members, 31 | dbo.v_Collection.CollectionType as [Type], 32 | dbo.v_Collections.CollectionVariablesCount as Variables, 33 | dbo.v_Collections.LimitToCollectionID as LimitedTo 34 | FROM 35 | dbo.v_FullCollectionMembership INNER JOIN 36 | dbo.v_Collection ON 37 | dbo.v_FullCollectionMembership.CollectionID = dbo.v_Collection.CollectionID 38 | INNER JOIN dbo.v_Collections ON 39 | dbo.v_Collection.Name = dbo.v_Collections.CollectionName' 40 | 41 | if (![string]::IsNullOrEmpty($SearchValue)) { 42 | if ($SearchType -eq 'like') { 43 | $query += " WHERE ($SearchField like '$SearchValue%')" 44 | } 45 | else { 46 | $query += " WHERE ($SearchField = '$SearchValue')" 47 | } 48 | $IsFiltered = $True 49 | } 50 | $query += " ORDER BY $SortField $SortOrder" 51 | $xxx = "query: $query" 52 | 53 | try { 54 | $connection = New-Object -ComObject "ADODB.Connection" 55 | $connString = "Data Source=$CmDBHost;Initial Catalog=CM_$CmSiteCode;Integrated Security=SSPI;Provider=SQLOLEDB" 56 | $connection.Open($connString); 57 | $IsOpen = $True 58 | $xxx += "
connection opened" 59 | $rs = New-Object -ComObject "ADODB.RecordSet" 60 | $rs.Open($query, $connection) 61 | $xxx += "
recordset defined" 62 | $colcount = $rs.Fields.Count 63 | $rowcount = 0 64 | $xxx += "
$colcount columns returned" 65 | if ($rs.BOF -and $rs.EOF) { 66 | $content = "" 67 | } 68 | else { 69 | $rs.MoveFirst() 70 | $content = '
No matching records found
' 71 | for ($i = 0; $i -lt $colcount; $i++) { 72 | $fn = $rs.Fields($i).Name 73 | $content += "" 74 | } 75 | $content += '' 76 | while (!$rs.EOF) { 77 | $content += "" 78 | for ($i = 0; $i -lt $colcount; $i++) { 79 | $fn = $rs.Fields($i).Name 80 | $fv = $rs.Fields($i).Value 81 | $content += "" 82 | } 83 | $content += "" 84 | $rs.MoveNext(); 85 | $rowcount++ 86 | } # while 87 | } 88 | $content += "" 93 | $content += "
$fn
$fv
$rowcount rows returned" 89 | if ($IsFiltered -eq $true) { 90 | $content += " - Show All" 91 | } 92 | $content += "
" 94 | } 95 | catch { 96 | $xxx += $Error[0].InnerException 97 | } 98 | finally { 99 | if ($IsOpen) { 100 | [void]$connection.Close() 101 | } 102 | } 103 | 104 | $tabset = New-MenuTabSet -BaseLink "cmdevicecollections.ps1?x=like&f=collectionname&v=" -DefaultID $TabSelected 105 | $content += Write-DetailInfo -PageRef "cmdevicecollections.ps1" -Mode $Detailed 106 | 107 | @" 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 |

$PageCaption

116 | 117 | $tabset 118 | $content 119 | 120 | 121 | 122 | "@ -------------------------------------------------------------------------------- /poshserver/cmdevices.ps1: -------------------------------------------------------------------------------- 1 | Get-SkParams | Out-Null 2 | 3 | $PageTitle = "CM Devices" 4 | if (![string]::IsNullOrEmpty($Script:SearchValue)) { 5 | $PageTitle += ": $($Script:SearchValue)" 6 | } 7 | $content = "" 8 | $menulist = "" 9 | $tabset = "" 10 | $pagelink = Split-Path -Leaf $MyInvocation.MyCommand.Definition 11 | 12 | $tabset = New-MenuTabSet -BaseLink "cmdevices.ps1`?x=begins&f=name&v=" -DefaultID $Script:TabSelected 13 | 14 | $qfile = "cmdevices.sql" 15 | $content = Get-SkQueryTableMultiple -QueryFile $qfile -PageLink $pagelink -Columns ('Name','ResourceID','Manufacturer','Model','OSName','OSBuild','ADSiteName') -Sorting "Name" 16 | 17 | Show-SkPage -------------------------------------------------------------------------------- /poshserver/cmdisc.ps1: -------------------------------------------------------------------------------- 1 | $Script:SearchField = Get-PageParam -TagName 'f' -Default "" 2 | $Script:SearchValue = Get-PageParam -TagName 'v' -Default "" 3 | $Script:SearchType = Get-PageParam -TagName 'x' -Default 'like' 4 | $Script:SortField = Get-PageParam -TagName 's' -Default "" 5 | $Script:SortOrder = Get-PageParam -TagName 'so' -Default 'Asc' 6 | $Script:TabSelected = Get-PageParam -TagName 'tab' -Default 'General' 7 | $Script:Detailed = Get-PageParam -TagName 'zz' -Default "" 8 | $Script:CustomName = Get-PageParam -TagName 'n' -Default "" 9 | 10 | $Script:PageTitle = "CM Discovery Method: $CustomName" 11 | $Script:PageCaption = "CM Discovery Method: $CustomName" 12 | 13 | $tabset = "" 14 | 15 | $content = Get-SkQueryTableMultiple -QueryFile "cmdiscovery.sql" -PageLink "cmdisc.ps1" -Columns ('ItemType','ID','Sitenumber','Name','Value1','Value2','Value3','SourceTable') -NoUnFilter 16 | 17 | $content += Write-DetailInfo -PageRef "cmdisc.ps1" -Mode $Detailed 18 | 19 | @" 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 |

$PageCaption

28 | 29 | $tabset 30 | $content 31 | 32 | 33 | 34 | "@ -------------------------------------------------------------------------------- /poshserver/cmdiscs.ps1: -------------------------------------------------------------------------------- 1 | $Script:SearchField = Get-PageParam -TagName 'f' -Default "" 2 | $Script:SearchValue = Get-PageParam -TagName 'v' -Default "" 3 | $Script:SearchType = Get-PageParam -TagName 'x' -Default "like" 4 | $Script:SortField = Get-PageParam -TagName 's' -Default "itemtype" 5 | $Script:SortOrder = Get-PageParam -TagName 'so' -Default "asc" 6 | $Script:TabSelected = Get-PageParam -TagName 'tab' -Default 'all' 7 | $Script:Detailed = Get-PageParam -TagName 'zz' -Default "" 8 | $Script:CustomName = Get-PageParam -TagName 'n' -Default "" 9 | $Script:IsFiltered = $False 10 | $Script:PageTitle = "CM Discovery Methods" 11 | $Script:PageCaption = "CM Discovery Methods" 12 | $content = "" 13 | $tabset = "" 14 | $outree = $null 15 | $query = $null 16 | $xxx = "" 17 | 18 | $content = Get-SkQueryTableMultiple -QueryFile "cmdiscoveries.sql" -PageLink "cmdiscs.ps1" -Columns ('ItemType','SiteNumber','SourceTable') 19 | 20 | #$tabset = New-MenuTabSet -BaseLink 'cmdiscs.ps1?x=begins&f=name&v=' -DefaultID $TabSelected 21 | $content += Write-DetailInfo -PageRef "cmdiscs.ps1" -Mode $Detailed 22 | 23 | @" 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |

$PageCaption

32 | 33 | $tabset 34 | $content 35 | 36 | 37 | 38 | "@ -------------------------------------------------------------------------------- /poshserver/cmfile.ps1: -------------------------------------------------------------------------------- 1 | $FileName = Get-PageParam -TagName 'n' -Default "" 2 | $FileVersion = Get-PageParam -TagName 'v' -Default "" 3 | $FileSize = Get-PageParam -TagName 's' -Default "" 4 | $SearchType = Get-PageParam -TagName 'x' -Default 'equals' 5 | $SortField = Get-PageParam -TagName 's' -Default 'ComputerName' 6 | $SortOrder = Get-PageParam -TagName 'so' -Default 'Asc' 7 | $TabSelected = Get-PageParam -TagName 'tab' -Default "" 8 | $Detailed = Get-PageParam -TagName 'zz' -Default "" 9 | 10 | $PageTitle = "CM Software File: $FileName" 11 | $PageCaption = "CM Software File: $FileName" 12 | 13 | try { 14 | $query = 'SELECT distinct 15 | dbo.v_R_System.Name0 as ComputerName, 16 | dbo.v_GS_SoftwareFile.ResourceID, 17 | dbo.v_GS_SoftwareFile.FilePath, 18 | dbo.v_GS_SoftwareFile.CreationDate, 19 | dbo.v_GS_SoftwareFile.FileModifiedDate, 20 | dbo.v_GS_SoftwareFile.FileCount 21 | from dbo.v_GS_SoftwareFile INNER JOIN 22 | dbo.v_R_System ON dbo.v_GS_SoftwareFile.ResourceID = dbo.v_R_System.ResourceID 23 | where 24 | (dbo.v_GS_SoftwareFile.FileName = '''+$FileName+''')' 25 | if (![string]::IsNullOrEmpty($FileVersion)) { 26 | $query += ' AND (dbo.v_GS_SoftwareFile.FileVersion = '''+$FileVersion+''')' 27 | } 28 | if (![string]::IsNullOrEmpty($FileSize)) { 29 | $query += ' AND (dbo.v_GS_SoftwareFile.FileSize = '+$FileSize+')' 30 | } 31 | $query += ' order by name0' 32 | 33 | $connection = New-Object -ComObject "ADODB.Connection" 34 | $connString = "Data Source=$CmDBHost;Initial Catalog=CM_$CmSiteCode;Integrated Security=SSPI;Provider=SQLOLEDB" 35 | $connection.Open($connString); 36 | $IsOpen = $True 37 | $rs = New-Object -ComObject "ADODB.RecordSet" 38 | $rs.Open($query, $connection) 39 | $xxx += "
recordset defined" 40 | $content = '' 41 | if ($rs.BOF -and $rs.EOF) { 42 | $content += "" 44 | } 45 | else { 46 | $colcount = $rs.Fields.Count 47 | $xxx += "$colcount columns returned" 48 | $rs.MoveFirst() 49 | for ($i = 0; $i -lt $colcount; $i++) { 50 | $content += '' 51 | } 52 | $content += '' 53 | $rowcount = 0 54 | while (!$rs.EOF) { 55 | $content += '' 56 | $cn = $rs.Fields("ComputerName").Value 57 | $id = $rs.Fields("ResourceID").Value 58 | $fp = $rs.Fields("FilePath").Value 59 | $dc = $rs.Fields("CreationDate").Value 60 | $fc = $rs.Fields("FileCount").Value 61 | $dm = $rs.Fields("FileModifiedDate").Value 62 | $cx = "$cn" 63 | $content += "" 64 | [void]$rs.MoveNext() 65 | $rowcount++ 66 | } 67 | $content += '
" 43 | $content += "No matching results found
'+$rs.Fields($i).Name+'
$cx$id$fp$dc$dm$fc
'+$rowcount+' instances found' 68 | if ($IsFiltered -eq $true) { 69 | $content += " - Show All" 70 | } 71 | $content += '
' 72 | } 73 | } 74 | catch { 75 | $content = "Error: $($Error[0].Exception.Message)" 76 | } 77 | finally { 78 | if ($isopen -eq $true) { 79 | $connection.Close() 80 | } 81 | } 82 | 83 | $content += Write-DetailInfo -PageRef "cminstalls.ps1" -Mode $Detailed 84 | 85 | @" 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 |

$PageCaption

94 | 95 | $content 96 | 97 | $(if ($DebugMode -eq 1) {"

$query

"}) 98 | 99 | 100 | 101 | "@ -------------------------------------------------------------------------------- /poshserver/cmfiles.ps1: -------------------------------------------------------------------------------- 1 | $SearchField = Get-PageParam -TagName 'f' -Default "FileName" 2 | $SearchValue = Get-PageParam -TagName 'v' -Default 'A' 3 | $SearchType = Get-PageParam -TagName 'x' -Default 'begins' 4 | $SortField = Get-PageParam -TagName 's' -Default 'filename' 5 | $SortOrder = Get-PageParam -TagName 'so' -Default 'Asc' 6 | $TabSelected = Get-PageParam -TagName 'tab' -Default 'A' 7 | $Detailed = Get-PageParam -TagName 'zz' -Default "" 8 | 9 | $PageTitle = "CM Software Files" 10 | $PageCaption = "CM Software Files" 11 | 12 | if ($SearchValue -eq 'all') { 13 | $SearchValue = "" 14 | $TabSelected = 'all' 15 | } 16 | else { 17 | if ($SearchField -eq 'FileName') { 18 | $TabSelected = $SearchValue.Substring(0,1) 19 | } 20 | } 21 | 22 | $query = 'select distinct 23 | FileName, 24 | FileVersion, 25 | FileSize, 26 | count (*) as Copies 27 | from v_gs_softwarefile' 28 | 29 | if (![string]::IsNullOrEmpty($SearchValue)) { 30 | switch ($SearchType) { 31 | 'like' { $query += " where ($SearchField like '%SearchValue%')"; $cap = 'contains'; break; } 32 | 'begins' { $query += " where ($SearchField like '$SearchValue%')"; $cap = 'begins with'; break; } 33 | 'ends' { $query += " where ($SearchField like '%$SearchValue')"; $cap = 'ends with'; break; } 34 | default { $query += " where ($SearchField = '$SearchValue')"; $cap = '='; break; } 35 | } 36 | $IsFiltered = $True 37 | $PageTitle += " ($cap $SearchValue)" 38 | $PageCaption = $PageTitle 39 | } 40 | $query += " group by filename, fileversion, filesize, filedescription" 41 | $query += " order by $SortField" 42 | 43 | try { 44 | $connection = New-Object -ComObject "ADODB.Connection" 45 | $connString = "Data Source=$CmDBHost;Initial Catalog=CM_$CmSiteCode;Integrated Security=SSPI;Provider=SQLOLEDB" 46 | $connection.Open($connString); 47 | $IsOpen = $True 48 | $rs = New-Object -ComObject "ADODB.RecordSet" 49 | $rs.Open($query, $connection) 50 | $xxx += "
recordset defined" 51 | $content = '' 52 | if ($rs.BOF -and $rs.EOF) { 53 | $content += "" 55 | } 56 | else { 57 | $colcount = $rs.Fields.Count 58 | $xxx += "$colcount columns returned" 59 | $rs.MoveFirst() 60 | for ($i = 0; $i -lt $colcount; $i++) { 61 | $content += '' 62 | } 63 | $content += '' 64 | $rowcount = 0 65 | $tcopies = 0 66 | while (!$rs.EOF) { 67 | $content += '' 68 | $fn = $rs.Fields("FileName").Value 69 | $fv = $rs.Fields("FileVersion").Value 70 | $fs = $rs.Fields("FileSize").Value 71 | $qx = $rs.Fields("Copies").Value 72 | $tcopies += $qx 73 | $fnx = "$fn" 74 | $content += "" 75 | [void]$rs.MoveNext() 76 | $rowcount++ 77 | } 78 | $content += '
" 54 | $content += "No matching results found
'+$rs.Fields($i).Name+'
$fnx$fv$fs$qx
'+$rowcount+' files returned' 79 | if ($IsFiltered -eq $true) { 80 | $content += " - Show All" 81 | } 82 | $content += "$tcopies
" 83 | } 84 | } 85 | catch { 86 | $content = "Error: $($Error[0].Exception.Message)" 87 | } 88 | finally { 89 | if ($isopen -eq $true) { 90 | $connection.Close() 91 | } 92 | } 93 | 94 | $tabset = New-MenuTabSet -BaseLink 'cmfiles.ps1?x=begins&f=filename&v=' -DefaultID $TabSelected 95 | $content += Write-DetailInfo -PageRef "cmfiles.ps1" -Mode $Detailed 96 | 97 | @" 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 |

$PageCaption

106 | 107 | $tabset 108 | $content 109 | 110 | $(if ($DebugMode -eq 1) {"

$query

"}) 111 | 112 | 113 | 114 | "@ -------------------------------------------------------------------------------- /poshserver/cmforestdisc.ps1: -------------------------------------------------------------------------------- 1 | $SearchField = Get-PageParam -TagName 'f' -Default "" 2 | $SearchValue = Get-PageParam -TagName 'v' -Default "" 3 | $SearchType = Get-PageParam -TagName 'x' -Default "like" 4 | $SortField = Get-PageParam -TagName 's' -Default "name" 5 | $SortOrder = Get-PageParam -TagName 'so' -Default "asc" 6 | $TabSelected = Get-PageParam -TagName 'tab' -Default 'all' 7 | $Detailed = Get-PageParam -TagName 'zz' -Default "" 8 | $CustomName = Get-PageParam -TagName 'n' -Default "" 9 | $IsFiltered = $False 10 | $PageTitle = "CM AD Forest Discovery" 11 | $PageCaption = "CM AD Forest Discovery" 12 | $content = "" 13 | $tabset = "" 14 | $outree = $null 15 | $query = $null 16 | $xxx = "" 17 | 18 | $content = Get-SkQueryTableMultiple -QueryFile "cmforests.sql" -PageLink "cmforests.ps1" -Columns ('ForestID','SMSSiteCode','SMSSiteName','LastDiscoveryTime','LastDiscoveryStatus','LastPublishingTime','PublishingStatus','DiscoveryEnabled','PublishingEnabled') 19 | 20 | #$tabset = New-MenuTabSet -BaseLink 'cmforestdisc.ps1' -DefaultID $TabSelected 21 | $content += Write-DetailInfo -PageRef "cmforestdisc.ps1" -Mode $Detailed 22 | 23 | @" 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |

$PageCaption

32 | 33 | $tabset 34 | $content 35 | 36 | 37 | 38 | "@ -------------------------------------------------------------------------------- /poshserver/cminstalls.ps1: -------------------------------------------------------------------------------- 1 | $ProductName = Get-PageParam -TagName 'pn' -Default "" 2 | $ProductVersion = Get-PageParam -TagName 'pv' -Default "" 3 | $SearchType = "equals" 4 | $SortField = Get-PageParam -TagName 's' -Default "computername" 5 | $SortOrder = Get-PageParam -TagName 'so' -Default "asc" 6 | $TabSelected = Get-PageParam -TagName 'tab' -Default "" 7 | $Detailed = Get-PageParam -TagName 'zz' -Default "" 8 | $CustomName = Get-PageParam -TagName 'n' -Default "" 9 | $IsFiltered = $False 10 | 11 | $ProductName = Get-CheapDecode $ProductName 12 | #$ProductVersion = Get-CheapDecode $ProductVersion 13 | 14 | $PageTitle = "CM Installed Software: $ProductName ($ProductVersion)" 15 | $PageCaption = $PageTitle 16 | $content = "" 17 | $tabset = "" 18 | $outree = $null 19 | $query = $null 20 | $xxx = "" 21 | 22 | # example url = "http://localhost:8080/cminstalls.ps1?pn=Microsoft%20Visual%20C++%202013%20Redistributable%20(x64)%20-%2012.0.40660&pv=12.0.40660.0" 23 | 24 | try { 25 | $query = 'SELECT DISTINCT 26 | dbo.v_R_System.Name0 AS ComputerName, 27 | dbo.v_R_System.ResourceID, 28 | dbo.v_GS_INSTALLED_SOFTWARE_CATEGORIZED.InstalledLocation0 AS InstallPath, 29 | dbo.v_GS_INSTALLED_SOFTWARE_CATEGORIZED.InstallSource0 AS [Source], 30 | dbo.v_GS_INSTALLED_SOFTWARE_CATEGORIZED.InstallDate0 AS InstallDate 31 | FROM dbo.v_GS_INSTALLED_SOFTWARE_CATEGORIZED INNER JOIN 32 | dbo.v_R_System ON dbo.v_GS_INSTALLED_SOFTWARE_CATEGORIZED.ResourceID = dbo.v_R_System.ResourceID 33 | where (ProductName0 = '''+ $ProductName +''') and (ProductVersion0 = '''+ $ProductVersion+''') 34 | order by '+$SortField+' '+$SortOrder 35 | 36 | $connection = New-Object -ComObject "ADODB.Connection" 37 | $connString = "Data Source=$CmDBHost;Initial Catalog=CM_$CmSiteCode;Integrated Security=SSPI;Provider=SQLOLEDB" 38 | $connection.Open($connString); 39 | $IsOpen = $True 40 | $rs = New-Object -ComObject "ADODB.RecordSet" 41 | $rs.Open($query, $connection) 42 | $xxx += "
recordset defined" 43 | $content = '' 44 | if ($rs.BOF -and $rs.EOF) { 45 | $content += "" 47 | } 48 | else { 49 | $colcount = $rs.Fields.Count 50 | $xxx += "$colcount columns returned" 51 | $rs.MoveFirst() 52 | for ($i = 0; $i -lt $colcount; $i++) { 53 | $content += '' 54 | } 55 | $content += '' 56 | $rowcount = 0 57 | while (!$rs.EOF) { 58 | $content += '' 59 | $cn = $rs.Fields("ComputerName").Value 60 | $id = $rs.Fields("ResourceID").Value 61 | $fp = $rs.Fields("InstallPath").Value 62 | $sp = $rs.Fields("Source").Value 63 | $dt = $rs.Fields("InstallDate").Value 64 | $cx = "$cn" 65 | $content += "" 66 | [void]$rs.MoveNext() 67 | $rowcount++ 68 | } 69 | $content += '
" 46 | $content += "No matching results found for: $ProductName ($ProductVersion)
'+$rs.Fields($i).Name+'
$cx$id$fp$sp$dt
'+$rowcount+' installations returned' 70 | if ($IsFiltered -eq $true) { 71 | $content += " - Show All" 72 | } 73 | $content += '
' 74 | } 75 | } 76 | catch { 77 | $content = "Error: $($Error[0].Exception.Message)" 78 | } 79 | finally { 80 | if ($isopen -eq $true) { 81 | $connection.Close() 82 | } 83 | } 84 | 85 | $content += Write-DetailInfo -PageRef "cminstalls.ps1" -Mode $Detailed 86 | 87 | @" 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 |

$PageCaption

96 | 97 | $tabset 98 | $content 99 | 100 | $(if ($DebugMode -eq 1) {"

$query

"}) 101 | 102 | 103 | 104 | "@ -------------------------------------------------------------------------------- /poshserver/cmpackage.ps1: -------------------------------------------------------------------------------- 1 | $Script:SearchField = Get-PageParam -TagName 'f' -Default "" 2 | $Script:SearchValue = Get-PageParam -TagName 'v' -Default "" 3 | $Script:SearchType = Get-PageParam -TagName 'x' -Default "equals" 4 | $Script:SortField = Get-PageParam -TagName 's' -Default "name" 5 | $Script:SortOrder = Get-PageParam -TagName 'so' -Default "asc" 6 | $Script:TabSelected = Get-PageParam -TagName 'tab' -Default 'General' 7 | $Script:Detailed = Get-PageParam -TagName 'zz' -Default "" 8 | $Script:CustomName = Get-PageParam -TagName 'n' -Default "" 9 | $Script:IsFiltered = $False 10 | $Script:PageTitle = "CM Software" 11 | $Script:PageCaption = "CM Software" 12 | $content = "" 13 | $tabset = "" 14 | $outree = $null 15 | $query = $null 16 | $xxx = "" 17 | 18 | switch ($TabSelected) { 19 | 'General' { 20 | $content = Get-SkQueryTableSingle -QueryFile "cmpackage.sql" -PageLink "cmpackage.ps1" -Columns ('PackageID','Name','Version','Manufacturer','PackageType','PkgType','Description','PkgSourcePath','SourceVersion','SourceDate','SourceSite','LastRefreshTime') 21 | break; 22 | } 23 | 'Programs' { 24 | try { 25 | $query = 'select 26 | ProgramName, 27 | Comment, 28 | Description, 29 | CommandLine, 30 | Duration, 31 | DiskSpaceRequired, 32 | ProgramFlags 33 | from [dbo].[v_Program] 34 | WHERE (PackageID = '''+$SearchValue+''') 35 | order by ProgramName' 36 | $connection = New-Object -ComObject "ADODB.Connection" 37 | $connString = "Data Source=$CmDBHost;Initial Catalog=CM_$CmSiteCode;Integrated Security=SSPI;Provider=SQLOLEDB" 38 | $connection.Open($connString); 39 | $IsOpen = $true 40 | $rs = New-Object -ComObject "ADODB.RecordSet" 41 | $rowcount = 0 42 | $rs.Open($query, $connection) 43 | if ($rs.BOF -and $rs.EOF) { 44 | $content = "
No Programs found for this Package
" 45 | } 46 | else { 47 | $colcount = $rs.Fields.Count 48 | $content = "" 49 | for ($i = 0; $i -lt $colcount; $i++) { 50 | $fn = $rs.Fields($i).Name 51 | $fv = $rs.Fields($i).Value 52 | $content += "" 53 | $content += "" 54 | } 55 | $content += "
$fn$fv
" 56 | } 57 | } 58 | catch { 59 | $content += "
Error: $($Error[0].Exception.Message)
" 60 | } 61 | finally { 62 | if ($IsOpen -eq $true) { 63 | [void]$connection.Close() 64 | } 65 | } 66 | break; 67 | } 68 | 'Advertisements' { 69 | $content = "
" 70 | $content += "Coming soon
" 71 | break; 72 | } 73 | } 74 | 75 | if ($SkNotesEnable -eq 'true') { 76 | $tabs = @('General','Programs','Advertisements','Notes') 77 | } 78 | else { 79 | $tabs = @('General','Programs','Advertisements') 80 | } 81 | $tabset = New-MenuTabSet2 -MenuTabs $tabs -BaseLink "cmpackage.ps1" 82 | 83 | @" 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 |

$PageCaption

92 | 93 | $tabset 94 | $content 95 | 96 | 97 | 98 | "@ -------------------------------------------------------------------------------- /poshserver/cmpackages.ps1: -------------------------------------------------------------------------------- 1 | $Script:SearchField = Get-PageParam -TagName 'f' -Default "" 2 | $Script:SearchValue = Get-PageParam -TagName 'v' -Default "all" 3 | $Script:SearchType = Get-PageParam -TagName 'x' -Default "like" 4 | $Script:SortField = Get-PageParam -TagName 's' -Default "name" 5 | $Script:SortOrder = Get-PageParam -TagName 'so' -Default "asc" 6 | $Script:TabSelected = Get-PageParam -TagName 'tab' -Default 'all' 7 | $Script:Detailed = Get-PageParam -TagName 'zz' -Default "" 8 | $CustomName = Get-PageParam -TagName 'n' -Default "" 9 | $Script:IsFiltered = $False 10 | $Script:PageTitle = "CM Software" 11 | $Script:PageCaption = "CM Software" 12 | $content = "" 13 | $tabset = "" 14 | $outree = $null 15 | $query = $null 16 | $xxx = "" 17 | 18 | $Script:TabSelected = $Script:SearchValue 19 | if ($Script:SearchValue -eq 'all') { 20 | $Script:SearchValue = "" 21 | } 22 | 23 | $xxx = "requesting query result" 24 | $content = Get-SkQueryTableMultiple -QueryFile "cmpackages.sql" -PageLink "cmpackages.ps1" -Columns ('PackageID','PkgName','PackageType','PkgType','Description','Version') 25 | 26 | if ($Script:SearchField -eq 'PkgType') { 27 | $cap = Get-CmPackageTypeName -PkgType $Script:SearchValue 28 | $Script:PageTitle += ": $cap" 29 | $Script:PageCaption = $PageTitle 30 | } 31 | 32 | $tabset = New-MenuTabSet -BaseLink 'cmpackages.ps1?x=begins&f=name&v=' -DefaultID $TabSelected 33 | $content += Write-DetailInfo -PageRef "cmpackages.ps1" -Mode $Detailed 34 | 35 | @" 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 |

$PageCaption

44 | 45 | $tabset 46 | $content 47 | 48 | 49 | 50 | "@ -------------------------------------------------------------------------------- /poshserver/cmproduct.ps1: -------------------------------------------------------------------------------- 1 | $SearchField = Get-PageParam -TagName 'f' -Default "" 2 | $SearchValue = Get-PageParam -TagName 'v' -Default "" 3 | $SearchType = Get-PageParam -TagName 'x' -Default 'like' 4 | $SortField = Get-PageParam -TagName 's' -Default 'productname' 5 | $SortOrder = Get-PageParam -TagName 'so' -Default 'Asc' 6 | $TabSelected = Get-PageParam -TagName 'tab' -Default 'All' 7 | $Detailed = Get-PageParam -TagName 'zz' -Default "" 8 | 9 | $PageTitle = "CM Installed Software" 10 | $PageCaption = "CM Installed Software" 11 | 12 | if ($SearchValue -eq 'all') { 13 | $SearchValue = "" 14 | } 15 | else { 16 | if ($SearchField -eq 'ProductName0') { 17 | $TabSelected = $SearchValue.Substring(0,1) 18 | } 19 | } 20 | 21 | $query = 'select distinct 22 | productname0 as ProductName, 23 | productcode0 as ProductCode, 24 | productversion0 as Version, 25 | publisher0 as Publisher, 26 | installsource0 as Source, 27 | uninstallstring0 as Uninstall, 28 | installdate0 as InstallDate, 29 | normalizedname as NormalName, 30 | normalizedversion as NormalVersion, 31 | normalizedpublisher as NormalPublisher, 32 | FamilyName, 33 | CategoryName 34 | from v_GS_INSTALLED_SOFTWARE_CATEGORIZED' 35 | #> 36 | 37 | if (![string]::IsNullOrEmpty($SearchValue)) { 38 | switch ($SearchType) { 39 | 'like' { $query += " where ($SearchField like '%SearchValue%')"; break; } 40 | 'begins' { $query += " where ($SearchField like '$SearchValue%')"; break; } 41 | 'ends' { $query += " where ($SearchField like '%$SearchValue')"; break; } 42 | default { $query += " where ($SearchField = '$SearchValue')"; break; } 43 | } 44 | $IsFiltered = $True 45 | $PageTitle += " ($SearchValue)" 46 | $PageCaption = $PageTitle 47 | } 48 | $query += " group by productname0, productcode0, productversion0, publisher0" 49 | $query += " order by $SortField" 50 | 51 | try { 52 | $connection = New-Object -ComObject "ADODB.Connection" 53 | $connString = "Data Source=$CmDBHost;Initial Catalog=CM_$CmSiteCode;Integrated Security=SSPI;Provider=SQLOLEDB" 54 | $connection.Open($connString); 55 | $IsOpen = $True 56 | $rs = New-Object -ComObject "ADODB.RecordSet" 57 | $rs.Open($query, $connection) 58 | $xxx += "
recordset defined" 59 | $content = '' 60 | if ($rs.BOF -and $rs.EOF) { 61 | $content += "" 63 | } 64 | else { 65 | $colcount = $rs.Fields.Count 66 | $xxx += "$colcount columns returned" 67 | $rs.MoveFirst() 68 | for ($i = 0; $i -lt $colcount; $i++) { 69 | $content += '' 70 | } 71 | $content += '' 72 | $rowcount = 0 73 | while (!$rs.EOF) { 74 | $content += '' 75 | $pn = $rs.Fields('ProductName').Value 76 | $pc = $rs.Fields('ProductCode').Value 77 | $pv = $rs.Fields('Version').Value 78 | $vn = $rs.Fields('Publisher').Value 79 | $qx = $rs.Fields('Installs').Value 80 | $xx = "$qx" 81 | $px = "$pn" 82 | $vx = "$vn" 83 | $content += "" 84 | $content += "" 85 | [void]$rs.MoveNext() 86 | $rowcount++ 87 | } 88 | $content += '
" 62 | $content += "No matching results found
'+$rs.Fields($i).Name+'
$px$pc$pv$vx$xx
'+$rowcount+' products returned' 89 | if ($IsFiltered -eq $true) { 90 | $content += " - Show All" 91 | } 92 | $content += '
' 93 | } 94 | } 95 | catch { 96 | $content = "Error: $($Error[0].Exception.Message)" 97 | } 98 | finally { 99 | if ($isopen -eq $true) { 100 | $connection.Close() 101 | } 102 | } 103 | 104 | $tabset = New-MenuTabSet -BaseLink 'cmproducts.ps1?x=begins&f=productname0&v=' -DefaultID $TabSelected 105 | $content += Write-DetailInfo -PageRef "cmproducts.ps1" -Mode $Detailed 106 | 107 | @" 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 |

$PageCaption

116 | 117 | $tabset 118 | $content 119 | 120 | $(if ($DebugMode -eq 1) {"

$query

"}) 121 | 122 | 123 | 124 | "@ -------------------------------------------------------------------------------- /poshserver/cmproducts.ps1: -------------------------------------------------------------------------------- 1 | $SearchField = Get-PageParam -TagName 'f' -Default "" 2 | $SearchValue = Get-PageParam -TagName 'v' -Default "" 3 | $SearchType = Get-PageParam -TagName 'x' -Default 'like' 4 | $SortField = Get-PageParam -TagName 's' -Default 'productname' 5 | $SortOrder = Get-PageParam -TagName 'so' -Default 'Asc' 6 | $TabSelected = Get-PageParam -TagName 'tab' -Default 'All' 7 | $Detailed = Get-PageParam -TagName 'zz' -Default "" 8 | 9 | $PageTitle = "CM Installed Software" 10 | $PageCaption = "CM Installed Software" 11 | 12 | if ($SearchValue -eq 'all') { 13 | $SearchValue = "" 14 | } 15 | else { 16 | if ($SearchField -eq 'ProductName0') { 17 | $TabSelected = $SearchValue.Substring(0,1) 18 | } 19 | } 20 | 21 | $query = 'select distinct 22 | productname0 as ProductName, 23 | productcode0 as ProductCode, 24 | productversion0 as Version, 25 | publisher0 as Publisher, 26 | count(*) as Installs 27 | from v_GS_INSTALLED_SOFTWARE_CATEGORIZED' 28 | 29 | <# 30 | # for individual product page 31 | 32 | $query = 'select distinct 33 | productname0 as ProductName, 34 | productcode0 as ProductCode, 35 | productversion0 as Version, 36 | publisher0 as Publisher, 37 | installsource0 as Source, 38 | uninstallstring0 as Uninstall, 39 | installdate0 as InstallDate, 40 | normalizedname as NormalName, 41 | normalizedversion as NormalVersion, 42 | normalizedpublisher as NormalPublisher, 43 | FamilyName, 44 | CategoryName 45 | from v_GS_INSTALLED_SOFTWARE_CATEGORIZED' 46 | #> 47 | 48 | if (![string]::IsNullOrEmpty($SearchValue)) { 49 | switch ($SearchType) { 50 | 'like' { $query += " where ($SearchField like '%SearchValue%')"; break; } 51 | 'begins' { $query += " where ($SearchField like '$SearchValue%')"; break; } 52 | 'ends' { $query += " where ($SearchField like '%$SearchValue')"; break; } 53 | default { $query += " where ($SearchField = '$SearchValue')"; break; } 54 | } 55 | $IsFiltered = $True 56 | $PageTitle += " ($SearchValue)" 57 | $PageCaption = $PageTitle 58 | } 59 | $query += " group by productname0, productcode0, productversion0, publisher0" 60 | $query += " order by $SortField" 61 | 62 | try { 63 | $connection = New-Object -ComObject "ADODB.Connection" 64 | $connString = "Data Source=$CmDBHost;Initial Catalog=CM_$CmSiteCode;Integrated Security=SSPI;Provider=SQLOLEDB" 65 | $connection.Open($connString); 66 | $IsOpen = $True 67 | $rs = New-Object -ComObject "ADODB.RecordSet" 68 | $rs.Open($query, $connection) 69 | $xxx += "
recordset defined" 70 | $content = '' 71 | if ($rs.BOF -and $rs.EOF) { 72 | $content += "" 74 | } 75 | else { 76 | $colcount = $rs.Fields.Count 77 | $xxx += "$colcount columns returned" 78 | $rs.MoveFirst() 79 | for ($i = 0; $i -lt $colcount; $i++) { 80 | $content += '' 81 | } 82 | $content += '' 83 | $rowcount = 0 84 | while (!$rs.EOF) { 85 | $content += '' 86 | $pn = $rs.Fields('ProductName').Value 87 | $pc = $rs.Fields('ProductCode').Value 88 | $pv = $rs.Fields('Version').Value 89 | $vn = $rs.Fields('Publisher').Value 90 | $qx = $rs.Fields('Installs').Value 91 | $pn2 = Get-CheapEncode $pn 92 | #$pv2 = Get-CheapEncode $pv 93 | #$pn2 = $pn 94 | $pv2 = $pv 95 | $xx = ''+$qx+'' 96 | $px = ''+$pn+'' 97 | $vx = ''+$vn+'' 98 | $content += "" 99 | $content += "" 100 | [void]$rs.MoveNext() 101 | $rowcount++ 102 | } 103 | $content += '
" 73 | $content += "No matching results found
'+$rs.Fields($i).Name+'
$px$pc$pv$vx$xx
'+$rowcount+' products returned' 104 | if ($IsFiltered -eq $true) { 105 | $content += " - Show All" 106 | } 107 | $content += '
' 108 | } 109 | } 110 | catch { 111 | $content = "Error: $($Error[0].Exception.Message)" 112 | } 113 | finally { 114 | if ($isopen -eq $true) { 115 | $connection.Close() 116 | } 117 | } 118 | 119 | $tabset = New-MenuTabSet -BaseLink 'cmproducts.ps1?x=begins&f=productname0&v=' -DefaultID $TabSelected 120 | $content += Write-DetailInfo -PageRef "cmproducts.ps1" -Mode $Detailed 121 | 122 | @" 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 |

$PageCaption

131 | 132 | $tabset 133 | $content 134 | 135 | $(if ($DebugMode -eq 1) {"

$query

"}) 136 | 137 | 138 | 139 | "@ -------------------------------------------------------------------------------- /poshserver/cmqueries.ps1: -------------------------------------------------------------------------------- 1 | $Script:SearchField = Get-PageParam -TagName 'f' -Default "" 2 | $Script:SearchValue = Get-PageParam -TagName 'v' -Default "" 3 | $Script:SearchType = Get-PageParam -TagName 'x' -Default "like" 4 | $Script:SortField = Get-PageParam -TagName 's' -Default "QueryName" 5 | $Script:SortOrder = Get-PageParam -TagName 'so' -Default "asc" 6 | $Script:TabSelected = Get-PageParam -TagName 'tab' -Default 'all' 7 | $Script:Detailed = Get-PageParam -TagName 'zz' -Default "" 8 | $Script:CustomName = Get-PageParam -TagName 'n' -Default "" 9 | $Script:IsFiltered = $False 10 | $Script:PageTitle = "CM Queries" 11 | $Script:PageCaption = "CM Queries" 12 | $content = "" 13 | $tabset = "" 14 | $outree = $null 15 | $query = $null 16 | $xxx = "" 17 | 18 | $content = Get-SkQueryTableMultiple -QueryFile "cmqueries.sql" -PageLink "cmqueries.ps1" -Columns ('QueryName','QueryID','Comments','TargetClassName','LimitToCollectionID') 19 | 20 | #$tabset = New-MenuTabSet -BaseLink 'cmqueries.ps1?x=begins&f=name&v=' -DefaultID $TabSelected 21 | $content += Write-DetailInfo -PageRef "cmqueries.ps1" -Mode $Detailed 22 | 23 | @" 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |

$PageCaption

32 | 33 | $tabset 34 | $content 35 | 36 | 37 | 38 | "@ -------------------------------------------------------------------------------- /poshserver/cmquery.ps1: -------------------------------------------------------------------------------- 1 | $SearchField = Get-PageParam -TagName 'f' -Default "" 2 | $SearchValue = Get-PageParam -TagName 'v' -Default "" 3 | $SearchType = Get-PageParam -TagName 'x' -Default "like" 4 | $SortField = Get-PageParam -TagName 's' -Default "name" 5 | $SortOrder = Get-PageParam -TagName 'so' -Default "asc" 6 | $TabSelected = Get-PageParam -TagName 'tab' -Default 'all' 7 | $Detailed = Get-PageParam -TagName 'zz' -Default "" 8 | $CustomName = Get-PageParam -TagName 'n' -Default "" 9 | $IsFiltered = $False 10 | $PageTitle = "CM Query: $CustomName" 11 | $PageCaption = "CM Query: $CustomName" 12 | $content = "" 13 | $tabset = "" 14 | $outree = $null 15 | $query = $null 16 | $xxx = "" 17 | 18 | $content = Get-SkQueryTableSingle -QueryFile "cmquery.sql" -PageLink "cmquery.ps1" -Columns ('QueryName','Comments','QueryKey','Architecture','Lifetime','QryFmtKey','QueryType','CollectionID','WQL','SQL') 19 | 20 | #$tabset = New-MenuTabSet -BaseLink 'cmqueries.ps1?x=begins&f=name&v=' -DefaultID $TabSelected 21 | $content += Write-DetailInfo -PageRef "cmquery.ps1" -Mode $Detailed 22 | 23 | @" 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |

$PageCaption

32 | 33 | $tabset 34 | $content 35 | 36 | 37 | 38 | "@ -------------------------------------------------------------------------------- /poshserver/cmscript.ps1: -------------------------------------------------------------------------------- 1 | $Script:SearchField = Get-PageParam -TagName 'f' -Default "ScriptGuid" 2 | $Script:SearchValue = Get-PageParam -TagName 'v' -Default "" 3 | $Script:SearchType = Get-PageParam -TagName 'x' -Default "equals" 4 | $Script:SortField = Get-PageParam -TagName 's' -Default "" 5 | $Script:SortOrder = Get-PageParam -TagName 'so' -Default "asc" 6 | $Script:TabSelected = Get-PageParam -TagName 'tab' -Default '' 7 | $Script:Detailed = Get-PageParam -TagName 'zz' -Default "" 8 | $Script:CustomName = Get-PageParam -TagName 'n' -Default "" 9 | $Script:IsFiltered = $False 10 | $Script:PageTitle = "CM Script: $CustomName" 11 | $Script:PageCaption = "CM Script: $CustomName" 12 | $content = "" 13 | $tabset = "" 14 | $outree = $null 15 | $query = $null 16 | $xxx = "" 17 | 18 | $content = Get-SkQueryTableSingle -QueryFile "cmscript.sql" -PageLink "cmscript.ps1" -Columns ('ScriptName','ScriptVersion','ScriptGuid','Author','ScriptType','Feature','ApprovalState','Approval','Approver','Script','ScriptHashAlgorithm','ScriptHash','LastUpdateTime','Comment','ParameterlistXML','ParameterGroupHash') 19 | $content += Write-DetailInfo -PageRef "cmscript.ps1" -Mode $Detailed 20 | 21 | @" 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 |

$PageCaption

30 | 31 | $tabset 32 | $content 33 | 34 | 35 | 36 | "@ -------------------------------------------------------------------------------- /poshserver/cmscripts.ps1: -------------------------------------------------------------------------------- 1 | $SearchField = Get-PageParam -TagName 'f' -Default "" 2 | $SearchValue = Get-PageParam -TagName 'v' -Default "" 3 | $SearchType = Get-PageParam -TagName 'x' -Default "like" 4 | $SortField = Get-PageParam -TagName 's' -Default "ScriptName" 5 | $SortOrder = Get-PageParam -TagName 'so' -Default "asc" 6 | $TabSelected = Get-PageParam -TagName 'tab' -Default 'all' 7 | $Detailed = Get-PageParam -TagName 'zz' -Default "" 8 | $CustomName = Get-PageParam -TagName 'n' -Default "" 9 | $IsFiltered = $False 10 | $PageTitle = "CM Scripts" 11 | $PageCaption = "CM Scripts" 12 | $content = "" 13 | $tabset = "" 14 | $outree = $null 15 | $query = $null 16 | $xxx = "" 17 | 18 | try { 19 | $query = 'select distinct 20 | ScriptGuid, 21 | ScriptVersion, 22 | ScriptName, 23 | Author, 24 | CASE 25 | when (ApprovalState = 0) then ''Pending'' 26 | when (ApprovalState = 1) then ''Denied'' 27 | when (ApprovalState = 3) then ''Approved'' 28 | else ''Unknown'' 29 | end as Approval, 30 | LastUpdateTime 31 | FROM vSMS_Scripts' 32 | 33 | if (![string]::IsNullOrEmpty($SearchValue)) { 34 | $IsFiltered = $True 35 | switch ($SearchType) { 36 | 'equals' { 37 | $query += " where ($SearchField = '$SearchValue')" 38 | break; 39 | } 40 | 'like' { 41 | $query += " where ($SearchField like '%$SearchValue%')" 42 | break; 43 | } 44 | 'begins' { 45 | $query += " where ($SearchField like '$SearchValue%')" 46 | break; 47 | } 48 | 'ends' { 49 | $query += " where ($SearchField like '%$SearchValue')" 50 | break; 51 | } 52 | } 53 | $PageTitle += ": $SearchValue" 54 | $PageCaption = $PageTitle 55 | } 56 | $query += " order by $SortField $SortOrder" 57 | 58 | $connection = New-Object -ComObject "ADODB.Connection" 59 | $connString = "Data Source=$CmDBHost;Initial Catalog=CM_$CmSiteCode;Integrated Security=SSPI;Provider=SQLOLEDB" 60 | $connection.Open($connString); 61 | $IsOpen = $true 62 | $rs = New-Object -ComObject "ADODB.RecordSet" 63 | $rowcount = 0 64 | $rs.Open($query, $connection) 65 | if ($rs.BOF -and $rs.EOF) { 66 | $content = "
No records found!
" 67 | } 68 | else { 69 | $colcount = 1 70 | $content = "" 71 | $content += "" 72 | [void]$rs.MoveFirst() 73 | while (!$rs.EOF) { 74 | $scid = $rs.Fields("ScriptGuid").value 75 | $scv = $rs.Fields("ScriptVersion").value 76 | $scn = $rs.Fields("ScriptName").value 77 | $sca = $rs.Fields("Author").value 78 | $scav = $rs.Fields("Approval").value 79 | $scut = $rs.Fields("LastUpdateTime").value 80 | $xlink = "$scn" 81 | $content += "" 82 | [void]$rs.MoveNext() 83 | $rowcount++ 84 | } 85 | $content += "" 90 | $content += "
NameVersionAuthorApprovalLast Update
$xlink$scv$sca$scav$scut
$rowcount items returned" 86 | if ($IsFiltered -eq $true) { 87 | $content += " - Show All" 88 | } 89 | $content += "
" 91 | [void]$rs.Close() 92 | } 93 | } 94 | catch { 95 | $content += "
Error: $($Error[0].Exception.Message)
" 96 | } 97 | finally { 98 | if ($IsOpen -eq $true) { 99 | [void]$connection.Close() 100 | } 101 | } 102 | 103 | $content += Write-DetailInfo -PageRef "cmpackages.ps1" -Mode $Detailed 104 | 105 | @" 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 |

$PageCaption

114 | 115 | $tabset 116 | $content 117 | 118 | 119 | 120 | "@ -------------------------------------------------------------------------------- /poshserver/cmserver.ps1: -------------------------------------------------------------------------------- 1 | $Script:RoleCode = Get-PageParam -TagName 'rc' -Default "" 2 | $Script:SearchField = Get-PageParam -TagName 'f' -Default "ServerName" 3 | $Script:SearchValue = Get-PageParam -TagName 'n' -Default "" 4 | $Script:IsFiltered = $False 5 | $Script:PageTitle = "CM Site System" 6 | $Script:PageCaption = "CM Site System" 7 | $content = "" 8 | $tabset = "" 9 | $xxx = "" 10 | 11 | try { 12 | switch ($Script:RoleCode) { 13 | 'dp' { 14 | $Script:PageCaption += ": $CustomName" 15 | $content = Get-SkQueryTableSingle -QueryFile "cmdp.sql" -PageLink "cmserver.ps1" 16 | break; 17 | } 18 | default { 19 | $content = "
Not implemented
" 20 | break; 21 | } 22 | } 23 | } 24 | catch { 25 | $content = "
Error: $($Error[0].Exception.Message)
" 26 | } 27 | 28 | @" 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 |

$PageCaption

37 | 38 | $tabset 39 | $content 40 | 41 | 42 | 43 | "@ -------------------------------------------------------------------------------- /poshserver/cmservers.ps1: -------------------------------------------------------------------------------- 1 | $Script:SearchField = Get-PageParam -TagName 'f' -Default "" 2 | $Script:SearchValue = Get-PageParam -TagName 'v' -Default "" 3 | $Script:SearchType = Get-PageParam -TagName 'x' -Default "like" 4 | $Script:SortField = Get-PageParam -TagName 's' -Default "Name" 5 | $Script:SortOrder = Get-PageParam -TagName 'so' -Default "asc" 6 | $Script:TabSelected = Get-PageParam -TagName 'tab' -Default 'all' 7 | $Script:Detailed = Get-PageParam -TagName 'zz' -Default "" 8 | $Script:CustomName = Get-PageParam -TagName 'n' -Default "" 9 | $Script:RoleCode = Get-PageParam -TagName 'rc' -Default "" 10 | $Script:IsFiltered = $False 11 | $Script:PageTitle = "CM Site Systems" 12 | $Script:PageCaption = "CM Site Systems" 13 | $content = "" 14 | $tabset = "" 15 | $outree = $null 16 | $query = $null 17 | $xxx = "" 18 | 19 | try { 20 | switch ($Script:RoleCode) { 21 | 'dp' { 22 | $content = Get-SkQueryTableMultiple -QueryFile "cmdps.sql" -PageLink "cmservers.ps1" -Columns ('DPID','DPName','Description','SMSSiteCode','IsPXE','DPType','Type') 23 | $Script:PageCaption += ": Distribution Points" 24 | break; 25 | } 26 | default { 27 | $content = "
Not implemented
" 28 | break; 29 | } 30 | } 31 | } 32 | catch { 33 | $content = "
Error: $($Error[0].Exception.Message)
" 34 | } 35 | 36 | #$tabset = New-MenuTabSet -BaseLink 'cmbgroups.ps1?x=begins&f=bgname&v=' -DefaultID $Script:TabSelected 37 | $content += Write-DetailInfo -PageRef "cmservers.ps1" -Mode $Detailed 38 | 39 | @" 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 |

$PageCaption

48 | 49 | $tabset 50 | $content 51 | 52 | 53 | 54 | "@ -------------------------------------------------------------------------------- /poshserver/cmsitestatus.ps1: -------------------------------------------------------------------------------- 1 | $Script:SearchField = Get-PageParam -TagName 'f' -Default "" 2 | $Script:SearchValue = Get-PageParam -TagName 'v' -Default "" 3 | $Script:SearchType = Get-PageParam -TagName 'x' -Default 'like' 4 | $Script:SortField = Get-PageParam -TagName 's' -Default 'sitesystem' 5 | $Script:SortOrder = Get-PageParam -TagName 'so' -Default 'Asc' 6 | $Script:TabSelected = Get-PageParam -TagName 'tab' -Default 'All' 7 | $Script:Detailed = Get-PageParam -TagName 'zz' -Default "" 8 | $Script:IsFiltered = $False 9 | $Script:PageTitle = "CM Site Status" 10 | $Script:PageCaption = "CM Site Status" 11 | $content = "" 12 | $tabset = "" 13 | $outree = $null 14 | $query = $null 15 | $xxx = "" 16 | 17 | $content = Get-SkQueryTableMultiple -QueryFile "cmsitestatus.sql" -PageLink "cmsitestatus.ps1" -Columns ('SiteStatus','Role','SiteCode','SiteSystem','TimeReported') 18 | $content += Write-DetailInfo -PageRef "cmsitestatus.ps1" -Mode $Detailed 19 | 20 | @" 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 |

$PageCaption

29 | 30 | $content 31 | 32 | 33 | 34 | "@ -------------------------------------------------------------------------------- /poshserver/cmsumtasks.ps1: -------------------------------------------------------------------------------- 1 | $SearchField = Get-PageParam -TagName 'f' -Default "" 2 | $SearchValue = Get-PageParam -TagName 'v' -Default "" 3 | $SearchType = Get-PageParam -TagName 'x' -Default "like" 4 | $SortField = Get-PageParam -TagName 's' -Default "taskname" 5 | $SortOrder = Get-PageParam -TagName 'so' -Default "asc" 6 | $TabSelected = Get-PageParam -TagName 'tab' -Default 'all' 7 | $Detailed = Get-PageParam -TagName 'zz' -Default "" 8 | $CustomName = Get-PageParam -TagName 'n' -Default "" 9 | $IsFiltered = $False 10 | $PageTitle = "CM Summary Tasks" 11 | $PageCaption = "CM Summary Tasks" 12 | $content = "" 13 | $tabset = "" 14 | $outree = $null 15 | $query = $null 16 | $xxx = "" 17 | 18 | try { 19 | $query = 'SELECT DISTINCT 20 | [TaskName], 21 | --[TaskCommand], 22 | --[RunInterval], 23 | --[LastRunDuration], 24 | --[LastSuccessfulCompletionTime], 25 | [LastRunResult], 26 | --[RunNow], 27 | [Enabled], 28 | --[TaskParameter], 29 | [LastStartTime], 30 | [NextStartTime] 31 | --[SiteTypes] 32 | FROM [v_SummaryTasks]' 33 | $query += " order by $SortField $SortOrder" 34 | 35 | if (![string]::IsNullOrEmpty($SearchValue)) {$IsFiltered = $True} 36 | 37 | $connection = New-Object -ComObject "ADODB.Connection" 38 | $connString = "Data Source=$CmDBHost;Initial Catalog=CM_$CmSiteCode;Integrated Security=SSPI;Provider=SQLOLEDB" 39 | $connection.Open($connString); 40 | $IsOpen = $true 41 | $rs = New-Object -ComObject "ADODB.RecordSet" 42 | $rowcount = 0 43 | $rs.Open($query, $connection) 44 | if ($rs.BOF -and $rs.EOF) { 45 | $content = "
No records found!
" 46 | } 47 | else { 48 | $colcount = $rs.Fields.Count 49 | $content = "" 50 | for ($i = 0; $i -lt $colcount; $i++) { 51 | $fn = $rs.Fields($i).Name 52 | $content += "" 53 | } 54 | $content += "" 55 | [void]$rs.MoveFirst() 56 | while (!$rs.EOF) { 57 | $content += "" 58 | for ($i = 0; $i -lt $colcount; $i++) { 59 | $fn = $rs.Fields($i).Name 60 | $fv = $rs.Fields($i).Value 61 | switch($fn) { 62 | 'TaskName' { 63 | $fvx = $fv 64 | # more work on this soon 65 | break; 66 | } 67 | default { 68 | $fvx = $fv 69 | break; 70 | } 71 | } 72 | $content += "" 73 | } 74 | $content += "" 75 | [void]$rs.MoveNext() 76 | $rowCount++ 77 | } 78 | [void]$rs.Close() 79 | $content += "" 84 | $content += "
$fn
$fvx
$rowcount items returned" 80 | if ($IsFiltered -eq $true) { 81 | $content += " - Show All" 82 | } 83 | $content += "
" 85 | } 86 | } 87 | catch { 88 | $content += "
Error: $($Error[0].Exception.Message)
" 89 | } 90 | finally { 91 | if ($IsOpen -eq $true) { 92 | [void]$connection.Close() 93 | } 94 | } 95 | 96 | #$tabset = New-MenuTabSet -BaseLink 'cmsumtasks.ps1?x=begins&f=name&v=' -DefaultID $TabSelected 97 | $content += Write-DetailInfo -PageRef "cmsumtasks.ps1" -Mode $Detailed 98 | 99 | @" 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 |

$PageCaption

108 | 109 | $tabset 110 | $content 111 | 112 | 113 | 114 | "@ -------------------------------------------------------------------------------- /poshserver/cmtasks.ps1: -------------------------------------------------------------------------------- 1 | $Script:SearchField = Get-PageParam -TagName 'f' -Default "TaskName" 2 | $Script:SearchValue = Get-PageParam -TagName 'v' -Default "" 3 | $Script:SearchType = Get-PageParam -TagName 'x' -Default "like" 4 | $Script:SortField = Get-PageParam -TagName 's' -Default "TaskName" 5 | $Script:SortOrder = Get-PageParam -TagName 'so' -Default "asc" 6 | $Script:TabSelected = Get-PageParam -TagName 'tab' -Default 'all' 7 | $Script:Detailed = Get-PageParam -TagName 'zz' -Default "" 8 | $Script:CustomName = Get-PageParam -TagName 'n' -Default "" 9 | $Script:IsFiltered = $False 10 | $Script:PageTitle = "CM Maintenance Tasks" 11 | $Script:PageCaption = "CM Maintenance Tasks" 12 | $content = "" 13 | $tabset = "" 14 | $outree = $null 15 | $query = $null 16 | $xxx = "" 17 | 18 | $content = Get-SkQueryTableMultiple -QueryFile "cmtasks.sql" -PageLink "cmtasks.ps1" -NoUnFilter 19 | 20 | #$tabset = New-MenuTabSet -BaseLink 'cmqueries.ps1?x=begins&f=name&v=' -DefaultID $TabSelected 21 | $content += Write-DetailInfo -PageRef "cmqueries.ps1" -Mode $Detailed 22 | 23 | @" 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |

$PageCaption

32 | 33 | $tabset 34 | $content 35 | 36 | 37 | 38 | "@ -------------------------------------------------------------------------------- /poshserver/cmuser.ps1: -------------------------------------------------------------------------------- 1 | $Script:SearchField = Get-PageParam -TagName 'f' -Default "UserName" 2 | $Script:SearchValue = Get-PageParam -TagName 'v' -Default "" 3 | $Script:SearchType = Get-PageParam -TagName 'x' -Default 'equals' 4 | $Script:SortField = Get-PageParam -TagName 's' -Default "" 5 | $Script:SortOrder = Get-PageParam -TagName 'so' -Default 'Asc' 6 | $Script:TabSelected = Get-PageParam -TagName 'tab' -Default 'General' 7 | $Script:Detailed = Get-PageParam -TagName 'zz' -Default "" 8 | $Script:CustomName = Get-PageParam -TagName 'n' -Default "" 9 | $Script:PageTitle = "CM User: $CustomName" 10 | $Script:PageCaption = "CM User: $CustomName" 11 | 12 | $content = "" 13 | $tabset = "" 14 | 15 | switch ($Script:TabSelected) { 16 | 'General' { 17 | $xxx = "queryfile: cmuser.sql" 18 | $content = Get-SkQueryTableSingle -QueryFile "cmuser.sql" -PageLink "cmuser.ps1" -Columns ('UserName','FullName','UserDomain','ResourceID','Department','Title','Email','UPN','UserDN','SID','Mgr') 19 | break; 20 | } 21 | 'Computers' { 22 | $xxx = "queryfile: cmuserdevices.sql" 23 | $content = Get-SkQueryTableMultiple -QueryFile "cmuserdevices.sql" -PageLink "cmuser.ps1" -Columns ('ComputerName','ProfilePath','TimeStamp','ResourceID','ADSite') -NoUnFilter 24 | break; 25 | } 26 | } # switch 27 | 28 | if ($SkNotesEnable -eq 'true') { 29 | $tabs = @('General','Computers','Notes') 30 | } 31 | else { 32 | $tabs = @('General','Computers') 33 | } 34 | 35 | $tabset = New-MenuTabSet2 -MenuTabs $tabs -BaseLink "cmuser.ps1" 36 | $content += Write-DetailInfo -PageRef "cmuser.ps1" -Mode $Detailed 37 | 38 | @" 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 |

$PageCaption

47 | 48 | $tabset 49 | $content 50 | 51 | 52 | 53 | "@ -------------------------------------------------------------------------------- /poshserver/cmusers.ps1: -------------------------------------------------------------------------------- 1 | $Script:SearchField = Get-PageParam -TagName 'f' -Default "" 2 | $Script:SearchValue = Get-PageParam -TagName 'v' -Default "" 3 | $Script:SearchType = Get-PageParam -TagName 'x' -Default 'like' 4 | $Script:SortField = Get-PageParam -TagName 's' -Default 'UserName' 5 | $Script:SortOrder = Get-PageParam -TagName 'so' -Default 'Asc' 6 | $Script:TabSelected = Get-PageParam -TagName 'tab' -Default $DefaultGroupsTab 7 | $Script:Detailed = Get-PageParam -TagName 'zz' -Default "" 8 | 9 | $Script:PageTitle = "CM Users" 10 | $Script:PageCaption = "CM Users" 11 | 12 | $Script:TabSelected = $Script:SearchValue 13 | if ($Script:SearchValue -eq 'all') { 14 | $Script:SearchValue = "" 15 | } 16 | 17 | $content = Get-SkQueryTableMultiple -QueryFile "cmusers.sql" -PageLink "cmusers.ps1" -Columns ('ResourceID','UserName','AADUserID','Domain','UPN','Department','Title') -ColumnSorting 18 | 19 | $tabset = New-MenuTabSet -BaseLink 'cmusers.ps1?x=begins&f=UserName&v=' -DefaultID $TabSelected 20 | $content += Write-DetailInfo -PageRef "cmusers.ps1" -Mode $Detailed 21 | 22 | @" 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 |

$PageCaption

31 | 32 | $tabset 33 | $content 34 | 35 | $(if ($DebugMode -eq 1) {"

$query

"}) 36 | 37 | 38 | 39 | "@ -------------------------------------------------------------------------------- /poshserver/config.txt: -------------------------------------------------------------------------------- 1 | ; SkatterTools Configuration Settings 2 | APPNAME=DeathFace 3 | ; default theme (there are only two so far) 4 | STTheme=stdark.css 5 | ; enable configmgr features 6 | CMEnabled=TRUE 7 | ; enable active directory features 8 | ADEnabled=TRUE 9 | ; enable security group administration 10 | ADGroupManage=TRUE 11 | ; name of configmgr sql server host 12 | CmDBHost=cm02.contoso.local 13 | ; name of configmgr sms provider host 14 | CmSMSProvider=cm02.contoso.local 15 | ; configmgr site code 16 | CmSiteCode=P02 17 | ; enable collection administration 18 | CmCollectionManage=TRUE 19 | ; enable skattertools object notes (not yet working) 20 | SkNotesEnable=FALSE 21 | SkNotesDBHost= 22 | SkDBDatabase= 23 | SkNotesPath=notes\notes.xml 24 | ; default index tabs on pages 25 | DefaultGroupsTab=all 26 | DefaultUsersTab=all 27 | DefaultComputersTab=all -------------------------------------------------------------------------------- /poshserver/dashboard1.ps1: -------------------------------------------------------------------------------- 1 | $PageTitle = "Dashboard" 2 | $PageCaption = "Dashboard" 3 | 4 | $adcomps = Get-ADsComputers 5 | $adusers = Get-AdsUsers 6 | $adgrps = Get-ADsGroups 7 | 8 | $ados = (Get-ADsComputers | Group-Object -Property OS | Select Name,Count) 9 | $panel3 = ($ados | ConvertTo-Html -Fragment) -replace '','
' 10 | 11 | $content = "
" 12 | $content += "" 13 | $content += "" 14 | $content += "" 15 | $content += "" 16 | $content += "
PANEL1PANEL2
PANEL3PANEL4
" 17 | 18 | $panel1 = "" 19 | $panel1 += "" 20 | $panel1 += "" 21 | $panel1 += "" 22 | $panel1 += "" 23 | $panel1 += "
NameCount
Active Directoy Computers$($adcomps.count)
Active Directory Users$($adusers.count)
Active Directory Groups$($adgrps.count)
" 24 | 25 | $content = $content -replace "PANEL1", $panel1 26 | #$content = $content -replace "PANEL2", $panel2 27 | $content = $content -replace "PANEL3", $panel3 28 | #$content = $content -replace "PANEL4", $panel4 29 | 30 | @" 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 |

$PageCaption

39 | 40 | $content 41 | 42 | 43 | 44 | "@ -------------------------------------------------------------------------------- /poshserver/dbrecovery.ps1: -------------------------------------------------------------------------------- 1 | $Script:PageTitle = "CM SQL Server: Database Recovery Models" 2 | $Script:PageCaption = "CM SQL Server: Database Recovery Models" 3 | $content = "" 4 | $tabset = "" 5 | $outree = $null 6 | $query = $null 7 | $xxx = "" 8 | 9 | try { 10 | $content += (Get-DbaDbRecoveryModel -SqlInstance $CmDbHost -ErrorAction Continue | 11 | ConvertTo-Html -Fragment) -replace '', '
' 12 | 13 | } 14 | catch { 15 | $content = "
Error: $($Error[0].Exception.Message)
" 16 | } 17 | 18 | 19 | @" 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 |

$PageCaption

28 | 29 | $tabset 30 | $content 31 | 32 | 33 | 34 | "@ -------------------------------------------------------------------------------- /poshserver/dbstats.ps1: -------------------------------------------------------------------------------- 1 | $Script:PageTitle = "CM SQL Server Report" 2 | $Script:PageCaption = "CM SQL Server Report" 3 | $content = "" 4 | $tabset = "" 5 | $outree = $null 6 | $query = $null 7 | $xxx = "" 8 | 9 | try { 10 | $content = "

Database State

" 11 | $content += (Get-DbaDbState -SqlInstance $CmDbHost -Database "CM_$CmSiteCode" | ConvertTo-Html -Fragment) -replace '','
' 12 | 13 | $content += "

Maximum Memory Allocation

" 14 | $content += (Get-DbaMaxMemory -SqlInstance $CmDbHost -ErrorAction Continue | ConvertTo-Html -Fragment) -replace '
', '
' 15 | 16 | $content += "

Memory Usage

" 17 | $content += (Get-DbaMemoryUsage -ComputerName $CmDbHost -ErrorAction Continue | ConvertTo-Html -Fragment) -replace '
', '
' 18 | 19 | $content += "

Startup Parameters

" 20 | $content += (Get-DbaStartupParameter -SqlInstance $CmDbHost | ConvertTo-Html -Fragment) -replace '
', '
' 21 | 22 | $content += "

Disk Allocation

" 23 | $content += (Test-DbaDiskAllocation -ComputerName $CmDbHost -ErrorAction Continue | ConvertTo-Html -Fragment) -replace '
','
' 24 | 25 | $content += "

Latency

" 26 | $content += (Get-DbaIoLatency -SqlInstance $CmDbHost -ErrorAction Continue | ConvertTo-Html -Fragment) -replace '
', '
' 27 | 28 | } 29 | catch { 30 | $content = "
Error: $($Error[0].Exception.Message)
" 31 | } 32 | 33 | 34 | @" 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 |

$PageCaption

43 | 44 | $tabset 45 | $content 46 | 47 | 48 | 49 | "@ -------------------------------------------------------------------------------- /poshserver/downloads.ps1: -------------------------------------------------------------------------------- 1 | $PageTitle = "Tools and Downloads" 2 | $content = "" 3 | $menulist = "" 4 | $tabset = "" 5 | $pagelink = Split-Path -Leaf $MyInvocation.MyCommand.Definition 6 | 7 | $content = @" 8 | 9 | 10 | 23 | 31 | 32 | 33 | 44 | 53 | 54 | 55 | 68 | 76 | 77 | 78 | 81 | 82 |
11 |

ConfigMgr Resources

12 | 13 | 21 | 22 |
24 |

Software Updates

25 | 26 | 30 |
34 |

Windows Deployment

35 | 36 | 43 |
45 |

SQL Server

46 | 47 | 51 | 52 |
56 |

Group Policy

57 | 58 | 66 | 67 |
69 |

Other

70 | 71 | 75 |
79 | Want more links added? Tweet them to me! @skatterbrainzz 80 |
83 | "@ 84 | 85 | Show-SkPage -------------------------------------------------------------------------------- /poshserver/footer.ps1: -------------------------------------------------------------------------------- 1 | @" 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | "@ -------------------------------------------------------------------------------- /poshserver/graphics/301.GIF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Skatterbrainz/SkatterTools/6172626e7d3f23f2afed315040810e3f7cd26238/poshserver/graphics/301.GIF -------------------------------------------------------------------------------- /poshserver/graphics/dflogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Skatterbrainz/SkatterTools/6172626e7d3f23f2afed315040810e3f7cd26238/poshserver/graphics/dflogo.png -------------------------------------------------------------------------------- /poshserver/graphics/sdlogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Skatterbrainz/SkatterTools/6172626e7d3f23f2afed315040810e3f7cd26238/poshserver/graphics/sdlogo.png -------------------------------------------------------------------------------- /poshserver/graphics/sktools4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Skatterbrainz/SkatterTools/6172626e7d3f23f2afed315040810e3f7cd26238/poshserver/graphics/sktools4.png -------------------------------------------------------------------------------- /poshserver/graphics/sortasc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Skatterbrainz/SkatterTools/6172626e7d3f23f2afed315040810e3f7cd26238/poshserver/graphics/sortasc.png -------------------------------------------------------------------------------- /poshserver/graphics/sortdesc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Skatterbrainz/SkatterTools/6172626e7d3f23f2afed315040810e3f7cd26238/poshserver/graphics/sortdesc.png -------------------------------------------------------------------------------- /poshserver/graphics/splash3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Skatterbrainz/SkatterTools/6172626e7d3f23f2afed315040810e3f7cd26238/poshserver/graphics/splash3.png -------------------------------------------------------------------------------- /poshserver/help.ps1: -------------------------------------------------------------------------------- 1 | Get-SkParams | Out-Null 2 | 3 | $PageTitle = "Help" 4 | $content = "" 5 | $menulist = "" 6 | $tabset = "" 7 | $pagelink = Split-Path -Leaf $MyInvocation.MyCommand.Definition 8 | 9 | $content += "
" 10 | $content += "Be patient. I'm still working on it. :)
" 11 | 12 | 13 | $content = @" 14 | 15 | 16 | 42 | 43 | 44 | 81 | 82 |
17 |

You Sure do Need Help!

18 | 19 |

If you clicked on a link to this page, you're in trouble. But don't worry, this page 20 | should keep you sufficiently confused and annoyed.

21 | 22 |

So, what the ____ exactly is this $Global:AppName crap anyway?

23 | 24 |

It began with a stupid idea and turned into a dumb project. Okay, that's not entirely true. 25 | But... It actually began from the pieces left from a dozen past web app projects involving ASP, 26 | PHP, Active Directory, SQL Server, Configuration Manager and so on. 27 | The issue has always been "but i don't want to stand up another server to manage 28 | another web app". So I found PoSH Server, a micro-web server that runs PowerShell for the 29 | content engine.

30 | 31 |

That's right! Everything in this site is built from the following: 32 |

    33 |
  • PowerShell
  • 34 |
  • HTML, CSS and some crappy graphics
  • 35 |
  • Coffee. Lots and lots of coffee
  • 36 |
  • More PowerShell. You can never have enough PowerShell
  • 37 |
38 | That's it.

39 | 40 |

Version: $Global:SkToolsVersion

41 |
45 |

Setup and Configuration

46 | 47 |

Note that this is only going to describe how this works as of now. This may change in a future 48 | release, so keep that in mind.

49 | 50 |

Once you've downloaded this garbage and extracted it into a folder somewhere, you should 51 | find a file in that folder named "config.txt". Open that in your favorite text editor. 52 | Modify the settings to suit your needs. After saving the changes, restart the PoSH Server instance.

53 | 54 |

Options and Variables

55 | 56 |
    57 |
  • AppName = The name of this app, which is currently $Global:AppName
  • 58 |
  • STTheme = CSS stylesheet theme to apply. (stdark.css or stlight.css)
  • 59 |
  • CMEnabled = Enable Configuration Manager features (true or false)
  • 60 |
  • ADenabled = Enable Active Directory features (true or false)
  • 61 |
  • ADGroupManage = Enable features to modify AD group memberships
  • 62 |
  • CMCollectionManage = Enable features to modify Collection memberships
  • 63 |
  • CmDBHost = Configuration Manager SQL Server hostname
  • 64 |
  • CmSMSProvider = Configuration Manager SMS Provider hostname
  • 65 |
  • CmSiteCode = Configuration Manager site code
  • 66 |
  • DefaultGroupsTab = Default menubar index tab for Groups
  • 67 |
  • DefaultUsersTab = Default menubar index tab for Users
  • 68 |
  • DefaultComputersTab = Default menubar index tab for Computers/Devices
  • 69 |
70 | 71 |

NOTE: Always keep a copy of your config.txt file somewhere, in case you download a new 72 | update and it whacks your existing copy. Whacks 73 | is a real word. I looked it up. Don't confuse "wax" with "whacks". You can "wax on" and "wax off", but if you 74 | get caught doing a "whacks off" you might end up in jail.

75 | 76 |

If you modify config.txt, you will need to stop and start the PoSH Server process again.

77 | 78 |

Stay tuned. More to come!

79 | 80 |
83 | "@ 84 | 85 | Show-SkPage -------------------------------------------------------------------------------- /poshserver/index.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | SkatterTools 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /poshserver/learning.ps1: -------------------------------------------------------------------------------- 1 | $PageTitle = "Learning Resources" 2 | $PageCaption = "Learning Resources" 3 | 4 | @" 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |

$PageCaption

13 | 14 | 15 | 16 | 31 | 42 | 43 | 44 | 47 | 48 |
17 | 30 | 32 | 41 |
45 | Want more links added? Tweet them to me! @skatterbrainzz 46 |
49 | 50 | 51 | 52 | "@ -------------------------------------------------------------------------------- /poshserver/license.htm: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 |

SkatterTools License Mumbo-Jumbo

8 | 9 |

Blah Blah Blah

10 | 11 |

Yap Yap Yap

12 | 13 |

I only ask that you respect a few basic requests:

14 | 15 | 21 | 22 |

The full license is available online at https://github.com/Skatterbrainz/SkatterTools/blob/master/LICENSE

23 | 24 |

If you're too cheap to afford an Internet connection, or you live in a place where they kill people 25 | who try to access the Internet, I've included the MIT license agreement below. Please be safe out there!

26 | 27 |

MIT License

28 | 29 |

Copyright (c) 2018 Skatterbrainz

Permission is hereby granted, free of charge, to any person obtaining a copy 32 | of this software and associated documentation files (the "Software"), to deal 33 | in the Software without restriction, including without limitation the rights 34 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 35 | copies of the Software, and to permit persons to whom the Software is 36 | furnished to do so, subject to the following conditions:

37 | 38 |

The above copyright notice and this permission notice shall be included in all 39 | copies or substantial portions of the Software.

40 | 41 |

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 42 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 43 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 44 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 45 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 46 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 47 | SOFTWARE.

48 | 49 | 50 | -------------------------------------------------------------------------------- /poshserver/main.ps1: -------------------------------------------------------------------------------- 1 | $PageTitle = "Welcome $PoshUserName !" 2 | 3 | $tabset = "" 4 | $content = "`"`"" 5 | 6 | Show-SkPage -------------------------------------------------------------------------------- /poshserver/notes/notes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | aduser 5 | sample 6 | administrator 7 | 12/5/2018 18:43:02 8 | sample note 9 | 10 | 11 | -------------------------------------------------------------------------------- /poshserver/queries/cmboundaries.sql: -------------------------------------------------------------------------------- 1 | SELECT DISTINCT 2 | dbo.vSMS_Boundary.DisplayName, 3 | dbo.vSMS_Boundary.BoundaryID, 4 | dbo.vSMS_Boundary.Value AS BValue, 5 | CASE 6 | WHEN BoundaryType = 0 THEN 'IP Subnet' 7 | WHEN BoundaryType = 1 THEN 'Active Directory Site' 8 | WHEN BoundaryType = 2 THEN 'IPv6 Prefix' 9 | WHEN BoundaryType = 3 THEN 'IP Address Range' 10 | ELSE 'UnKnown' 11 | END AS BoundaryType, 12 | CASE 13 | WHEN BoundaryFlags = 0 THEN 'Fast' 14 | WHEN BoundaryFlags = 1 THEN 'Slow' 15 | END AS BoundaryFlags, 16 | dbo.vSMS_Boundary.CreatedBy, 17 | dbo.vSMS_Boundary.CreatedOn, 18 | dbo.vSMS_Boundary.ModifiedBy, 19 | dbo.vSMS_Boundary.ModifiedOn, 20 | dbo.vSMS_BoundaryGroupMembers.GroupID, 21 | dbo.vSMS_BoundaryGroup.Name AS BGName 22 | FROM 23 | dbo.vSMS_Boundary INNER JOIN 24 | dbo.vSMS_BoundaryGroupMembers ON 25 | dbo.vSMS_Boundary.BoundaryID = dbo.vSMS_BoundaryGroupMembers.BoundaryID 26 | INNER JOIN 27 | dbo.vSMS_BoundaryGroup ON 28 | dbo.vSMS_BoundaryGroupMembers.GroupID = dbo.vSMS_BoundaryGroup.GroupID -------------------------------------------------------------------------------- /poshserver/queries/cmboundarygroup.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | [Name] as BGName, 3 | DefaultSiteCode, 4 | GroupID, 5 | GroupGUID, 6 | [Description], 7 | Flags, 8 | CreatedBy, 9 | CreatedOn, 10 | ModifiedBy, 11 | ModifiedOn, 12 | MemberCount, 13 | SiteSystemCount, 14 | case 15 | when (Shared = 1) then 'Yes' 16 | else 'No' end as Shared 17 | FROM vSMS_BoundaryGroup -------------------------------------------------------------------------------- /poshserver/queries/cmboundarygroups.sql: -------------------------------------------------------------------------------- 1 | SELECT DISTINCT 2 | Name as BGName, 3 | GroupID, 4 | Description, 5 | Flags, 6 | DefaultSiteCode, 7 | CreatedOn, 8 | MemberCount as Boundaries, 9 | SiteSystemCount as SiteSystems 10 | FROM vSMS_BoundaryGroup -------------------------------------------------------------------------------- /poshserver/queries/cmcerts.sql: -------------------------------------------------------------------------------- 1 | SELECT distinct 2 | IssuedTo, 3 | ServerName, 4 | case 5 | when ([Type]=2) then 'BootMedia' 6 | when ([Type]=4) then 'DistributionPoint' 7 | when ([Type]=5) then 'ISVProxy' 8 | end as CertType, 9 | case 10 | when (KeyType = 1) then 'SelfSigned' 11 | when (KeyType = 2) then 'Issued' 12 | end as KeyType, 13 | ValidFrom, 14 | ValidUntil, 15 | case 16 | when (IsApproved = 1) then 'Yes' 17 | else 'No' end as Approved, 18 | case 19 | when (IsBlocked = 1) then 'Yes' 20 | else 'No' end as Blocked 21 | FROM vSMS_Certificate -------------------------------------------------------------------------------- /poshserver/queries/cmcollection.sql: -------------------------------------------------------------------------------- 1 | SELECT DISTINCT 2 | dbo.v_Collection.Name AS CollectionName, 3 | dbo.v_Collection.CollectionID, 4 | dbo.v_Collection.Comment, 5 | dbo.v_Collection.MemberCount AS Members, 6 | case 7 | when (dbo.v_Collection.CollectionType = 1) then 'User' 8 | when (dbo.v_Collection.CollectionType = 2) then 'Device' 9 | end AS Type, 10 | dbo.v_Collections.CollectionVariablesCount AS Variables, 11 | dbo.v_Collections.LimitToCollectionID AS LimitedTo 12 | FROM 13 | dbo.v_Collections INNER JOIN 14 | dbo.v_Collection ON 15 | dbo.v_Collections.CollectionName = dbo.v_Collection.Name 16 | -------------------------------------------------------------------------------- /poshserver/queries/cmcollectionmembers.sql: -------------------------------------------------------------------------------- 1 | SELECT DISTINCT 2 | [Name], 3 | ResourceID, 4 | case 5 | when (ResourceType=5) then 'Device' 6 | when (ResourceType=2) then 'User' 7 | end as [ResourceType], 8 | Domain, 9 | SiteCode, 10 | case 11 | when (IsDirect=1) then 'Direct' 12 | else 'Query' end as RuleType, 13 | CollectionID 14 | FROM 15 | v_FullCollectionMembership 16 | -------------------------------------------------------------------------------- /poshserver/queries/cmcollectionqueryrules.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | v_CollectionRuleQuery.RuleName, 3 | v_CollectionRuleQuery.QueryID, 4 | v_CollectionRuleQuery.QueryExpression, 5 | v_CollectionRuleQuery.LimitToCollectionID, 6 | v_CollectionRuleQuery.CollectionID, 7 | v_Collection.Name as [CollectionName] 8 | FROM 9 | v_CollectionRuleQuery INNER JOIN 10 | v_Collection ON v_CollectionRuleQuery.CollectionID = v_Collection.CollectionID 11 | ORDER BY 12 | v_CollectionRuleQuery.RuleName -------------------------------------------------------------------------------- /poshserver/queries/cmcollections.sql: -------------------------------------------------------------------------------- 1 | SELECT DISTINCT 2 | dbo.v_Collection.Name as CollectionName, 3 | dbo.v_Collection.CollectionID, dbo.v_Collection.Comment, 4 | dbo.v_Collection.MemberCount as Members, 5 | dbo.v_Collection.CollectionType as [Type], 6 | dbo.v_Collections.CollectionVariablesCount as Variables, 7 | dbo.v_Collections.LimitToCollectionID as LimitedTo, 8 | dbo.v_Collections. 9 | FROM 10 | dbo.v_FullCollectionMembership RIGHT OUTER JOIN dbo.v_Collection ON 11 | dbo.v_FullCollectionMembership.CollectionID = dbo.v_Collection.CollectionID 12 | INNER JOIN dbo.v_Collections ON 13 | dbo.v_Collection.Name = dbo.v_Collections.CollectionName 14 | -------------------------------------------------------------------------------- /poshserver/queries/cmcollectionvariables.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | v_CollectionVariable.Name, 3 | v_CollectionVariable.Value, 4 | case 5 | when (v_CollectionVariable.IsMasked = 1) then 'Yes' else 'No' end as IsMasked, 6 | v_CollectionVariable.CollectionID, 7 | v_Collection.Name AS CollectionName 8 | FROM 9 | v_CollectionVariable INNER JOIN 10 | v_Collection ON v_CollectionVariable.CollectionID = v_Collection.CollectionID -------------------------------------------------------------------------------- /poshserver/queries/cmcomponentstatus.sql: -------------------------------------------------------------------------------- 1 | SELECT DISTINCT 2 | ComponentName, 3 | case 4 | when (Status = 0) then '#1ED66B' 5 | when (Status = 1) then '#CBD61E' 6 | when (Status = 2) then '#D61E37' 7 | end as Status, 8 | case 9 | when (state = 0) then 'Stopped' 10 | when (state = 1) then 'Started' 11 | when (state = 2) then 'Paused' 12 | when (state = 3) then 'Installing' 13 | when (state = 4) then 'Re-installing' 14 | when (state = 5) then 'De-installing' 15 | end as [State], 16 | LastContacted, 17 | MAX([Infos]) as Info, 18 | MAX([Warnings]) as Warning, 19 | MAX([Errors]) as [Error] 20 | FROM 21 | vSMS_ComponentSummarizer 22 | GROUP BY 23 | ComponentName, LastContacted, Status, State -------------------------------------------------------------------------------- /poshserver/queries/cmcompstat.sql: -------------------------------------------------------------------------------- 1 | /* https://docs.microsoft.com/en-us/sccm/develop/reference/core/servers/manage/sms_statusmessage-server-wmi-class */ 2 | select distinct 3 | RecordID, 4 | Component, 5 | MessageID, 6 | case 7 | when (MessageType = 256) then 'Milestone' 8 | when (MessageType = 512) then 'Detail' 9 | when (MessageType = 768) then 'Audit' 10 | when (MessageType = 1024) then 'NTEvent' 11 | end as MessageType, 12 | case 13 | when (ABS(Severity) = 1073741824) then 'Info' 14 | when (ABS(Severity) = 2147483648) then 'Warning' 15 | else 'Error' end as Severity, 16 | MachineName, 17 | ModuleName, 18 | Win32Error, 19 | Time, 20 | SiteCode, 21 | TopLevelSiteCode, 22 | ProcessID, 23 | ThreadID, 24 | case 25 | when (ReportFunction = 0) then 'Report' 26 | when (ReportFunction = 16) then 'BeginTransaction' 27 | when (ReportFunction = 32) then 'CommitSuccessfulTransaction' 28 | when (ReportFunction = 48) then 'CommitFailedTransaction' 29 | when (ReportFunction = 64) then 'RollbackTransaction' 30 | when (ReportFunction = 80) then 'ReportEX' 31 | end as ReportFunction, 32 | SuccessfulTransaction, 33 | case 34 | when (PartOfTransaction = 0) then 'False' 35 | else 'True' end as [Transaction], 36 | case 37 | when (PerClient = 0) then 'False' 38 | else 'True' end as PerClient 39 | from 40 | vStatusMessages 41 | where 42 | (DATEDIFF(HH,vStatusMessages.Time, GETDATE()) < 24) 43 | -------------------------------------------------------------------------------- /poshserver/queries/cmdevice.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | [Name], 3 | ResourceID, 4 | Manufacturer, 5 | Model, 6 | SerialNumber, 7 | OperatingSystem, 8 | OSBuild, 9 | ClientVersion, 10 | LastHwScan, 11 | LastDDR, 12 | LastPolicyRequest, 13 | ADSiteName 14 | FROM ( 15 | SELECT 16 | dbo.v_R_System.ResourceID, 17 | dbo.v_R_System.Name0 as [Name], 18 | dbo.v_GS_COMPUTER_SYSTEM.Manufacturer0 as Manufacturer, 19 | dbo.v_GS_COMPUTER_SYSTEM.Model0 as Model, 20 | dbo.v_GS_SYSTEM_ENCLOSURE.SerialNumber0 as SerialNumber, 21 | dbo.vWorkstationStatus.ClientVersion, 22 | dbo.vWorkstationStatus.LastHardwareScan as LastHwScan, 23 | dbo.vWorkstationStatus.LastPolicyRequest, 24 | dbo.vWorkstationStatus.LastDDR, 25 | dbo.v_R_System.AD_Site_Name0 as ADSiteName, 26 | dbo.v_GS_OPERATING_SYSTEM.Caption0 as OperatingSystem, 27 | dbo.v_GS_OPERATING_SYSTEM.BuildNumber0 as OSBuild 28 | FROM 29 | dbo.v_R_System INNER JOIN 30 | dbo.v_GS_COMPUTER_SYSTEM ON 31 | dbo.v_R_System.ResourceID = dbo.v_GS_COMPUTER_SYSTEM.ResourceID INNER JOIN 32 | dbo.v_GS_SYSTEM_ENCLOSURE ON 33 | dbo.v_R_System.ResourceID = dbo.v_GS_SYSTEM_ENCLOSURE.ResourceID INNER JOIN 34 | dbo.vWorkstationStatus ON 35 | dbo.v_R_System.ResourceID = dbo.vWorkstationStatus.ResourceID INNER JOIN 36 | dbo.v_GS_OPERATING_SYSTEM ON 37 | dbo.v_R_System.ResourceID = dbo.v_GS_OPERATING_SYSTEM.ResourceID 38 | ) AS T1 -------------------------------------------------------------------------------- /poshserver/queries/cmdeviceapps.sql: -------------------------------------------------------------------------------- 1 | SELECT DISTINCT 2 | dbo.v_R_System.Name0, 3 | dbo.v_GS_ADD_REMOVE_PROGRAMS.DisplayName0 AS ProductName, 4 | dbo.v_GS_ADD_REMOVE_PROGRAMS.Publisher0 AS Publisher, 5 | dbo.v_GS_ADD_REMOVE_PROGRAMS.Version0 AS Version 6 | FROM 7 | dbo.v_GS_ADD_REMOVE_PROGRAMS INNER JOIN dbo.v_R_System ON 8 | dbo.v_GS_ADD_REMOVE_PROGRAMS.ResourceID = dbo.v_R_System.ResourceID 9 | -------------------------------------------------------------------------------- /poshserver/queries/cmdevicecollectionmembers.sql: -------------------------------------------------------------------------------- 1 | SELECT DISTINCT 2 | v_FullCollectionMembership.Name AS [ComputerName], 3 | v_FullCollectionMembership.ResourceID, 4 | CASE 5 | WHEN (ResourceType = 5) THEN 'Device' 6 | WHEN (ResourceType = 2) THEN 'User' END AS ResourceType, 7 | v_FullCollectionMembership.Domain, 8 | v_FullCollectionMembership.SiteCode, 9 | CASE 10 | WHEN (IsDirect = 1) THEN 'Direct' 11 | ELSE 'Query' END AS RuleType, 12 | v_FullCollectionMembership.CollectionID, 13 | v_Collection.Name as [CollectionName] 14 | FROM 15 | v_FullCollectionMembership INNER JOIN 16 | v_Collection ON v_FullCollectionMembership.CollectionID = v_Collection.CollectionID -------------------------------------------------------------------------------- /poshserver/queries/cmdevicecollections.sql: -------------------------------------------------------------------------------- 1 | SELECT DISTINCT 2 | dbo.v_Collection.CollectionID, 3 | dbo.v_Collection.Name as CollectionName, 4 | dbo.v_Collection.Comment, 5 | dbo.v_Collection.MemberCount as Members, 6 | case 7 | when (v_Collection.CollectionType = 2) then 'Device' 8 | when (v_Collection.CollectionType = 5) then 'User' 9 | end as [Type], 10 | case 11 | when (v_Collections.CollectionVariablesCount = 1) then 'Yes' 12 | else 'No' end as Variables, 13 | dbo.v_Collections.LimitToCollectionID as LimitedTo 14 | FROM 15 | dbo.v_FullCollectionMembership RIGHT OUTER JOIN dbo.v_Collection ON 16 | dbo.v_FullCollectionMembership.CollectionID = dbo.v_Collection.CollectionID 17 | INNER JOIN dbo.v_Collections ON 18 | dbo.v_Collection.Name = dbo.v_Collections.CollectionName 19 | WHERE 20 | (dbo.v_Collections.CollectionType = 2) -------------------------------------------------------------------------------- /poshserver/queries/cmdevicecolls.sql: -------------------------------------------------------------------------------- 1 | -- collections for which a device belongs to 2 | SELECT DISTINCT 3 | v_FullCollectionMembership.Name as [Name], 4 | v_FullCollectionMembership.CollectionID, 5 | v_Collection.Name as [CollectionName] 6 | FROM 7 | v_FullCollectionMembership INNER JOIN v_Collection ON 8 | v_FullCollectionMembership.CollectionID = v_Collection.CollectionID 9 | ORDER BY 10 | CollectionName -------------------------------------------------------------------------------- /poshserver/queries/cmdevicedrives.sql: -------------------------------------------------------------------------------- 1 | SELECT DISTINCT 2 | v_R_System.Name0 AS Name, 3 | v_GS_LOGICAL_DISK.DeviceID0 as [Drive], 4 | v_GS_LOGICAL_DISK.DriveType0 as [DiskType], 5 | v_GS_LOGICAL_DISK.Description0 as [Description], 6 | v_GS_LOGICAL_DISK.Size0 as [DiskSize], 7 | v_GS_LOGICAL_DISK.FreeSpace0 as [FreeSpace], 8 | case 9 | when (DriveType0 = 3) then (Size0 - FreeSpace0) 10 | else 0 end as Used, 11 | case 12 | when (DriveType0 = 3) then CONVERT(int,(((CAST(Size0 as DECIMAL(9,2)) - FreeSpace0) / Size0)*100)) 13 | else NULL end as PCT 14 | FROM 15 | v_R_System INNER JOIN 16 | v_GS_LOGICAL_DISK ON v_R_System.ResourceID = v_GS_LOGICAL_DISK.ResourceID 17 | ORDER BY 18 | v_GS_LOGICAL_DISK.DeviceID0 -------------------------------------------------------------------------------- /poshserver/queries/cmdevicenetconfigs.sql: -------------------------------------------------------------------------------- 1 | SELECT DISTINCT 2 | v_R_System.Name0 as Name, 3 | v_GS_NETWORK_ADAPTER_CONFIGURATION.ResourceID, 4 | case 5 | when (DHCPEnabled0=1) then 'Yes' else 'No' end as DHCPEnabled, 6 | DHCPServer0 as DHCPServer, 7 | IPAddress0 as IPAddress, 8 | IPSubnet0 as IPSubnect, 9 | MACAddress0 as MAC, 10 | DefaultIPGateway0 as IPGateway, 11 | case 12 | when (IPEnabled0 = 1) then 'Yes' else 'No' end as Enabled 13 | FROM 14 | v_GS_NETWORK_ADAPTER_CONFIGURATION LEFT JOIN 15 | v_R_SYSTEM ON v_GS_NETWORK_ADAPTER_CONFIGURATION.ResourceID = v_R_System.ResourceID 16 | ORDER BY 17 | v_R_System.Name0 -------------------------------------------------------------------------------- /poshserver/queries/cmdevices.sql: -------------------------------------------------------------------------------- 1 | SELECT DISTINCT 2 | dbo.v_R_System.ResourceID, 3 | dbo.v_R_System.Name0 AS Name, 4 | dbo.v_R_System.AD_Site_Name0 AS ADSiteName, 5 | dbo.vWorkstationStatus.LastHardwareScan, 6 | dbo.vWorkstationStatus.LastDDR, 7 | dbo.vWorkstationStatus.LastPolicyRequest, 8 | dbo.vWorkstationStatus.LastMPServerName, 9 | dbo.v_GS_OPERATING_SYSTEM.Caption0 AS OSName, 10 | dbo.v_GS_OPERATING_SYSTEM.BuildNumber0 AS OSBuild, 11 | dbo.v_GS_COMPUTER_SYSTEM.Manufacturer0 AS Manufacturer, 12 | dbo.v_GS_COMPUTER_SYSTEM.Model0 AS Model, 13 | dbo.v_GS_COMPUTER_SYSTEM.TotalPhysicalMemory0 AS TotalMemory, 14 | dbo.v_GS_PROCESSOR.Name0 AS Processor, 15 | dbo.v_GS_SYSTEM_ENCLOSURE.ChassisTypes0 AS ChassisType, 16 | dbo.v_GS_SYSTEM_ENCLOSURE.SerialNumber0 AS SerialNumber 17 | FROM 18 | dbo.v_R_System LEFT OUTER JOIN 19 | dbo.v_GS_SYSTEM_ENCLOSURE ON 20 | dbo.v_R_System.ResourceID = dbo.v_GS_SYSTEM_ENCLOSURE.ResourceID LEFT OUTER JOIN 21 | dbo.v_GS_PROCESSOR ON 22 | dbo.v_R_System.ResourceID = dbo.v_GS_PROCESSOR.ResourceID LEFT OUTER JOIN 23 | dbo.v_GS_COMPUTER_SYSTEM ON 24 | dbo.v_R_System.ResourceID = dbo.v_GS_COMPUTER_SYSTEM.ResourceID LEFT OUTER JOIN 25 | dbo.v_GS_OPERATING_SYSTEM ON 26 | dbo.v_R_System.ResourceID = dbo.v_GS_OPERATING_SYSTEM.ResourceID LEFT OUTER JOIN 27 | dbo.vWorkstationStatus ON 28 | dbo.v_R_System.ResourceID = dbo.vWorkstationStatus.ResourceID -------------------------------------------------------------------------------- /poshserver/queries/cmdiscoveries.sql: -------------------------------------------------------------------------------- 1 | SELECT DISTINCT 2 | ItemType, 3 | Sitenumber, 4 | SourceTable 5 | FROM SC_Properties 6 | WHERE (ItemType LIKE '%Discover%') -------------------------------------------------------------------------------- /poshserver/queries/cmdiscovery.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | ItemType, 3 | ID, 4 | Sitenumber, 5 | [Name], 6 | Value1, 7 | Value2, 8 | Value3, 9 | SourceTable 10 | FROM SC_Properties -------------------------------------------------------------------------------- /poshserver/queries/cmdp.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | DPID, 3 | ServerName, 4 | Description, 5 | NALPath, 6 | ShareName, 7 | SMSSiteCode as SiteCode, 8 | case when (IsPXE=1) then 'Yes' else 'No' end as PXE, 9 | case when (SccmPXE=1) then 'Yes' else 'No' end as SCCMPXE, 10 | case when (IsActive=1) then 'Yes' else 'No' end as Active, 11 | case when (IsPeerDP=1) then 'Yes' else 'No' end as PeerDP, 12 | case when (IsPullDP=1) then 'Yes' else 'No' end as PullDP, 13 | case when (IsPullDPInstalled=1) then 'Yes' else 'No' end as PullDPInstalled, 14 | case when (IsFileStreaming=1) then 'Yes' else 'No' end as FileStreaming, 15 | case when (IsBITS=1) then 'Yes' else 'No' end as BITS, 16 | case when (IsMulticast=1) then 'Yes' else 'No' end as MultiCast, 17 | case when (IsProtected=1) then 'Yes' else 'No' end as Protected, 18 | RemoveWDS, 19 | case when (AnonymousEnabled=1) then 'Yes' else 'No' end as AnonEnabled, 20 | case when (TokenAuthEnabled=1) then 'Yes' else 'No' end as TokenAuth, 21 | case 22 | when (SslState=0) then 'HTTP' 23 | when (SslState=1) then 'HTTPS' 24 | when (SslState=2) then 'N/A' 25 | when (SslState=3) then 'Always HTTPS' 26 | when (SslState=4) then 'Always HTTP' 27 | else 'Unknown' end as SSL, 28 | DPType, 29 | case when (PreStagingAllowed=1) then 'Yes' else 'No' end as PreStaging, 30 | DPDrive, 31 | MinFreeSpace, 32 | Type, 33 | Action, 34 | State, 35 | DPFlags, 36 | DPCRC, 37 | ResponseDelay, 38 | case 39 | when (UdaSetting=0) then 'Disabled' 40 | when (UdaSetting=1) then 'Allow user device affinity with manual approval' 41 | when (UdaSetting=2) then 'Allow user device affinity woth automatic approval' 42 | end as UDA, 43 | case 44 | when (BindPolicy=0) then 'Respond on All Network Interfaces' 45 | when (BindPolicy=1) then 'Respond on Specific Network Interfaces' 46 | end as BindPolicy, 47 | SupportUnknownMachines, 48 | IdentityGUID, 49 | BindExcept, 50 | case 51 | when (CertificateType=0) then 'Self-Signed' 52 | else 'Imported' end as CertType, 53 | Account, 54 | Priority, 55 | TransferRate, 56 | ISVString, 57 | Flags, 58 | MaintenanceMode, 59 | RoleCapabilities 60 | FROM 61 | v_DistributionPoints -------------------------------------------------------------------------------- /poshserver/queries/cmdps.sql: -------------------------------------------------------------------------------- 1 | SELECT DISTINCT 2 | DPID, 3 | ServerName as [DPName], 4 | [Description], 5 | SMSSiteCode, 6 | IsPXE, 7 | SccmPXE, 8 | RemoveWDS, 9 | DPType, 10 | [Type] 11 | FROM 12 | v_DistributionPoints -------------------------------------------------------------------------------- /poshserver/queries/cmforests.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | ForestID, 3 | SMSSiteCode, 4 | SMSSiteName, 5 | LastDiscoveryTime, 6 | LastDiscoveryStatus, 7 | LastPublishingTime, 8 | case 9 | when (PublishingStatus = 1) then 'Published' 10 | else '' end as PublishingStatus, 11 | case 12 | when (DiscoveryEnabled = 1) then 'Yes' 13 | else 'No' end as DiscoveryEnabled, 14 | case 15 | when (PublishingEnabled = 1) then 'Yes' 16 | else 'No' end as PublishingEnabled 17 | FROM 18 | vActiveDirectoryForestDiscoveryStatus 19 | -------------------------------------------------------------------------------- /poshserver/queries/cmpackage.sql: -------------------------------------------------------------------------------- 1 | select 2 | PackageID, 3 | Name, 4 | Version, 5 | Manufacturer, 6 | PackageType, 7 | Case 8 | When PackageType = 0 Then 'Software Distribution Package' 9 | When PackageType = 3 Then 'Driver Package' 10 | When PackageType = 4 Then 'Task Sequence Package' 11 | When PackageType = 5 Then 'Software Update Package' 12 | When PackageType = 6 Then 'Device Settings Package' 13 | When PackageType = 7 Then 'Virtual Package' 14 | When PackageType = 8 Then 'Application' 15 | When PackageType = 257 Then 'OS Image Package' 16 | When PackageType = 258 Then 'Boot Image Package' 17 | When PackageType = 259 Then 'OS Upgrade Package' 18 | WHEN PackageType = 260 Then 'VHD Package' 19 | End as PkgType, 20 | Description, 21 | PkgSourcePath, 22 | SourceVersion, 23 | SourceDate, 24 | SourceSite, 25 | LastRefreshTime 26 | from dbo.v_Package 27 | -------------------------------------------------------------------------------- /poshserver/queries/cmpackages.sql: -------------------------------------------------------------------------------- 1 | select distinct 2 | PackageID, 3 | Name as PkgName, 4 | Case 5 | When (PackageType = 0) Then 'Software Distribution Package' 6 | When (PackageType = 3) Then 'Driver Package' 7 | When (PackageType = 4) Then 'Task Sequence Package' 8 | When (PackageType = 5) Then 'Software Update Package' 9 | When (PackageType = 6) Then 'Device Settings Package' 10 | When (PackageType = 7) Then 'Virtual Package' 11 | When (PackageType = 8) Then 'Application' 12 | When (PackageType = 257) Then 'OS Image Package' 13 | When (PackageType = 258) Then 'Boot Image Package' 14 | When (PackageType = 259) Then 'OS Upgrade Package' 15 | WHEN (PackageType = 260) Then 'VHD Package' 16 | End as PkgType, 17 | PackageType, 18 | Description, 19 | SourceVersion as Version 20 | from dbo.v_Package -------------------------------------------------------------------------------- /poshserver/queries/cmqueries.sql: -------------------------------------------------------------------------------- 1 | SELECT DISTINCT 2 | Name as QueryName, 3 | QueryID, 4 | Comments, 5 | TargetClassName, 6 | LimitToCollectionID 7 | FROM v_Query -------------------------------------------------------------------------------- /poshserver/queries/cmquery.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | Name as QueryName, 3 | Comments, 4 | QueryKey, 5 | Architecture, 6 | Lifetime, 7 | QryFmtKey, 8 | QueryType, 9 | CollectionID, 10 | WQL, 11 | SQL 12 | FROM Queries 13 | -------------------------------------------------------------------------------- /poshserver/queries/cmscript.sql: -------------------------------------------------------------------------------- 1 | select distinct 2 | ScriptName, 3 | ScriptVersion, 4 | ScriptGuid, 5 | Author, 6 | ScriptType, 7 | Feature, 8 | ApprovalState, 9 | CASE 10 | when (ApprovalState = 0) then 'Pending' 11 | when (ApprovalState = 1) then 'Denied' 12 | when (ApprovalState = 3) then 'Approved' 13 | else 'Unknown' 14 | end as Approval, 15 | Approver, 16 | '(It looks like Chinese writing, so I cant display it yet)' as [Script], 17 | ScriptHashAlgorithm, 18 | ScriptHash, 19 | LastUpdateTime, 20 | Comment 21 | FROM vSMS_Scripts -------------------------------------------------------------------------------- /poshserver/queries/cmsitestatus.sql: -------------------------------------------------------------------------------- 1 | select distinct 2 | case 3 | when (Status = 0) then '#1ED66B' 4 | when (Status = 1) then '#CBD61E' 5 | when (Status = 2) then '#D61E37' 6 | end as SiteStatus, 7 | Role, 8 | SiteCode, 9 | case 10 | when (AvailabilityState = 0) then 'Online' 11 | when (AvailabilityState = 1) then '1' 12 | when (AvailabilityState = 2) then '2' 13 | when (AvailabilityState = 3) then 'Offline' 14 | when (AvailabilityState = 4) then '4' 15 | end as Availability, 16 | SiteSystem, 17 | TimeReported 18 | FROM v_SiteSystemSummarizer -------------------------------------------------------------------------------- /poshserver/queries/cmtasks.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | TaskName, 3 | --TaskType, 4 | case 5 | when (IsEnabled=1) then 'Yes' else 'No' end as [Enabled], 6 | NumRefreshDays, 7 | DaysOfWeek, 8 | BeginTime, 9 | LatestBeginTime, 10 | BackupLocation, 11 | DeleteOlderThan 12 | FROM 13 | vSMS_SC_SQL_Task -------------------------------------------------------------------------------- /poshserver/queries/cmuser.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | dbo.v_R_User.User_Name0 as [UserName], 3 | dbo.v_R_User.Unique_User_Name0 AS UserDNSName, 4 | dbo.v_R_User.Full_User_Name0 AS FullName, 5 | dbo.v_R_User.Windows_NT_Domain0 AS UserDomain, 6 | dbo.v_R_User.ResourceID, 7 | dbo.v_R_User.Department, 8 | dbo.v_R_User.Title, 9 | dbo.v_R_User.Mail0 as Email, 10 | dbo.v_R_User.User_Principal_Name0 AS UPN, 11 | dbo.v_R_User.Distinguished_Name0 AS UserDN, 12 | dbo.v_R_User.SID0 AS SID, 13 | u2.Unique_User_Name0 AS Mgr 14 | FROM 15 | dbo.v_R_User LEFT OUTER JOIN 16 | dbo.v_R_User AS u2 ON dbo.v_R_User.manager = u2.Distinguished_Name0 17 | -------------------------------------------------------------------------------- /poshserver/queries/cmusercollectionmembers.sql: -------------------------------------------------------------------------------- 1 | SELECT DISTINCT 2 | v_R_User.User_Name0 AS UserName, 3 | v_FullCollectionMembership.Name AS UserFullName, 4 | v_FullCollectionMembership.ResourceID, 5 | v_FullCollectionMembership.Domain, 6 | v_FullCollectionMembership.SiteCode, 7 | case 8 | when (IsDirect = 1) then 'Direct' 9 | else 'Query' end as RuleType, 10 | v_FullCollectionMembership.CollectionID, 11 | v_Collection.Name AS CollectionName 12 | FROM 13 | v_FullCollectionMembership INNER JOIN v_Collection ON 14 | v_FullCollectionMembership.CollectionID = v_Collection.CollectionID 15 | INNER JOIN v_R_User ON 16 | v_FullCollectionMembership.ResourceID = v_R_User.ResourceID 17 | -------------------------------------------------------------------------------- /poshserver/queries/cmusercollections.sql: -------------------------------------------------------------------------------- 1 | SELECT DISTINCT 2 | dbo.v_Collection.CollectionID, 3 | dbo.v_Collection.Name as CollectionName, 4 | dbo.v_Collection.Comment, 5 | dbo.v_Collection.MemberCount as Members, 6 | case 7 | when (v_Collection.CollectionType = 2) then 'Device' 8 | when (v_Collection.CollectionType = 5) then 'User' 9 | end as [Type], 10 | case 11 | when (v_Collections.CollectionVariablesCount = 1) then 'Yes' 12 | else 'No' end as Variables, 13 | dbo.v_Collections.LimitToCollectionID as LimitedTo 14 | FROM 15 | dbo.v_FullCollectionMembership RIGHT OUTER JOIN dbo.v_Collection ON 16 | dbo.v_FullCollectionMembership.CollectionID = dbo.v_Collection.CollectionID 17 | INNER JOIN dbo.v_Collections ON 18 | dbo.v_Collection.Name = dbo.v_Collections.CollectionName 19 | WHERE 20 | (dbo.v_Collections.CollectionType = 1) -------------------------------------------------------------------------------- /poshserver/queries/cmuserdevices.sql: -------------------------------------------------------------------------------- 1 | SELECT DISTINCT 2 | dbo.v_R_System.Name0 AS ComputerName, 3 | dbo.v_GS_USER_PROFILE.LocalPath0 AS ProfilePath, 4 | dbo.v_GS_USER_PROFILE.TimeStamp, 5 | dbo.v_GS_USER_PROFILE.ResourceID, 6 | dbo.v_R_System.AD_Site_Name0 AS ADSite, 7 | dbo.v_R_User.User_Name0 AS UserName 8 | FROM 9 | dbo.v_GS_USER_PROFILE INNER JOIN 10 | dbo.v_R_User ON 11 | dbo.v_GS_USER_PROFILE.SID0 = dbo.v_R_User.SID0 INNER JOIN 12 | dbo.v_R_System ON 13 | dbo.v_GS_USER_PROFILE.ResourceID = dbo.v_R_System.ResourceID -------------------------------------------------------------------------------- /poshserver/queries/cmusers.sql: -------------------------------------------------------------------------------- 1 | select distinct 2 | ResourceID, 3 | User_Name0 as UserName, 4 | AADUserID, 5 | Windows_NT_Domain0 as Domain, 6 | User_Principal_Name0 as UPN, 7 | Department, 8 | Title 9 | from v_R_User 10 | -------------------------------------------------------------------------------- /poshserver/reload.ps1: -------------------------------------------------------------------------------- 1 | $PageCaption = "Reload SkatterTools" 2 | $content = "
" 3 | $content += "
Please wait, this is going to be really cool, I promise!...
" 4 | $TargetLink = "index.htm" 5 | 6 | $Global:SkToolsLoaded = $null 7 | . $HomeDirectory\config.ps1 8 | 9 | @" 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |

$PageCaption

19 | 20 | $content 21 | 22 | 23 | 24 | "@ -------------------------------------------------------------------------------- /poshserver/reports/Devices - Counts by AD Site Name.sql: -------------------------------------------------------------------------------- 1 | SELECT DISTINCT 2 | COALESCE(AD_Site_Name0, 'Default') AS ADSiteName, 3 | COUNT(*) AS Computers 4 | FROM 5 | dbo.v_R_System 6 | GROUP BY 7 | AD_SITE_Name0 8 | ORDER BY 9 | ADSite -------------------------------------------------------------------------------- /poshserver/reports/Devices - Counts by BIOS Version.sql: -------------------------------------------------------------------------------- 1 | SELECT DISTINCT 2 | BIOSVersion0 AS [BIOSVersion], 3 | Version0 AS [Version], 4 | InstallDate0 AS [InstallDate], 5 | COUNT(*) AS Clients 6 | FROM 7 | v_GS_PC_BIOS 8 | GROUP BY 9 | BIOSVersion0, 10 | InstallDate0, 11 | Version0 -------------------------------------------------------------------------------- /poshserver/reports/Devices - Counts by DHCP Server.sql: -------------------------------------------------------------------------------- 1 | SELECT DISTINCT 2 | DHCPServer0 AS DHCP_Server, 3 | COUNT(DISTINCT ResourceID) AS Clients 4 | FROM 5 | dbo.v_GS_NETWORK_ADAPTER_CONFIGURATION 6 | WHERE 7 | DHCPServer0 IS NOT NULL AND LTRIM(DHCPServer0)<>'' 8 | GROUP BY DHCPServer0 -------------------------------------------------------------------------------- /poshserver/reports/Devices - Counts by IP Gateway.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | CASE 3 | when (DefaultIPGateway0 IS NULL) then 'None' 4 | else DefaultIPGateway0 end as Gateway, 5 | COUNT(*) AS Clients 6 | FROM 7 | v_GS_NETWORK_ADAPTER_CONFIGURATION 8 | WHERE 9 | v_GS_NETWORK_ADAPTER_CONFIGURATION.IPEnabled0 = 1 10 | GROUP BY 11 | DefaultIPGateway0 12 | ORDER BY 13 | DefaultIPGateway0 -------------------------------------------------------------------------------- /poshserver/reports/Devices - Counts by Operating System.sql: -------------------------------------------------------------------------------- 1 | SELECT DISTINCT 2 | Caption0 AS Name, 3 | BuildNumber0 AS Build, 4 | CSDVersion0 AS SvcPack, 5 | OSArchitecture0 AS Arch, 6 | OSLanguage0 AS Lang, 7 | COUNT(*) AS Clients 8 | FROM 9 | dbo.v_GS_OPERATING_SYSTEM 10 | GROUP BY 11 | Caption0, 12 | BuildNumber0, 13 | CSDVersion0, 14 | OSArchitecture0, 15 | OSLanguage0 16 | ORDER BY 17 | Caption0, BuildNumber0 -------------------------------------------------------------------------------- /poshserver/reports/Devices - Counts by Total Memory.sql: -------------------------------------------------------------------------------- 1 | SELECT DISTINCT 2 | TotalPhysicalMemory0 AS TotalMemory, 3 | COUNT(*) AS Clients 4 | FROM 5 | dbo.v_GS_X86_PC_MEMORY 6 | GROUP BY 7 | TotalPhysicalMemory0 8 | ORDER BY 9 | TotalPhysicalMemory0 -------------------------------------------------------------------------------- /poshserver/reports/Devices - Counts by User Login.sql: -------------------------------------------------------------------------------- 1 | SELECT DISTINCT 2 | TOP 50 3 | UserName0 as [UserName], 4 | COUNT(*) as [Clients] 5 | FROM 6 | v_GS_COMPUTER_SYSTEM 7 | GROUP BY 8 | UserName0 9 | ORDER BY 10 | Clients DESC -------------------------------------------------------------------------------- /poshserver/reports/Devices - Hardware Models.sql: -------------------------------------------------------------------------------- 1 | SELECT DISTINCT 2 | Manufacturer0 AS Manufacturer, 3 | Model0 AS Model, 4 | COUNT(*) AS Clients 5 | FROM 6 | dbo.v_GS_COMPUTER_SYSTEM 7 | GROUP BY 8 | Manufacturer0, 9 | Model0 10 | ORDER BY 11 | Manufacturer0, 12 | Model0 -------------------------------------------------------------------------------- /poshserver/reports/Devices - Last 20 Discovered.sql: -------------------------------------------------------------------------------- 1 | SELECT TOP 20 2 | dbo.v_R_System.ResourceID, 3 | dbo.v_R_System.Name0 AS ComputerName, 4 | dbo.v_R_System.AD_Site_Name0 AS ADSiteName, 5 | dbo.v_R_System.Client_Version0 AS ClientVer, 6 | dbo.v_R_System.User_Name0 AS UserName, 7 | dbo.v_GS_OPERATING_SYSTEM.Caption0 AS Windows, 8 | dbo.v_GS_COMPUTER_SYSTEM.Model0 AS Model 9 | FROM 10 | dbo.v_R_System LEFT OUTER JOIN 11 | dbo.v_GS_COMPUTER_SYSTEM ON dbo.v_R_System.ResourceID = dbo.v_GS_COMPUTER_SYSTEM.ResourceID 12 | LEFT OUTER JOIN 13 | dbo.v_GS_OPERATING_SYSTEM ON dbo.v_R_System.ResourceID = dbo.v_GS_OPERATING_SYSTEM.ResourceID 14 | ORDER BY 15 | ResourceID DESC -------------------------------------------------------------------------------- /poshserver/reports/Site - Package Distribution Status Summary.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | dbo.v_ContDistStatSummary.PkgID, 3 | dbo.v_Package.Name AS PackageName, 4 | dbo.v_ContDistStatSummary.LastStatusTime as [LastStatus], 5 | dbo.v_ContDistStatSummary.TargeteddDPCount as [DPCount], 6 | dbo.v_ContDistStatSummary.NumberInstalled as [Installed], 7 | dbo.v_ContDistStatSummary.NumberInProgress as [InProgress], 8 | dbo.v_ContDistStatSummary.NumberErrors as [Errors] 9 | FROM 10 | dbo.v_ContDistStatSummary INNER JOIN 11 | dbo.v_Package ON dbo.v_ContDistStatSummary.PkgID = dbo.v_Package.PackageID -------------------------------------------------------------------------------- /poshserver/reports/Software - Counts by Products Installation.sql: -------------------------------------------------------------------------------- 1 | SELECT DISTINCT 2 | dbo.v_GS_ADD_REMOVE_PROGRAMS.DisplayName0 as ProductName, 3 | dbo.v_GS_ADD_REMOVE_PROGRAMS.Publisher0 as Publisher, 4 | dbo.v_GS_ADD_REMOVE_PROGRAMS.Version0 as [Version], 5 | COUNT(*) AS Installs 6 | FROM 7 | dbo.v_R_System INNER JOIN 8 | dbo.v_GS_ADD_REMOVE_PROGRAMS ON 9 | dbo.v_R_System.ResourceID = dbo.v_GS_ADD_REMOVE_PROGRAMS.ResourceID 10 | GROUP BY 11 | DisplayName0, 12 | Publisher0, 13 | Version0 14 | ORDER BY Installs DESC -------------------------------------------------------------------------------- /poshserver/reports/Software - Google Chrome Installations.sql: -------------------------------------------------------------------------------- 1 | SELECT DISTINCT 2 | dbo.v_R_System.Name0 AS ComputerName, 3 | dbo.v_GS_INSTALLED_SOFTWARE_CATEGORIZED.ResourceID, 4 | dbo.v_GS_INSTALLED_SOFTWARE_CATEGORIZED.ProductName0 AS ProductName, 5 | dbo.v_GS_INSTALLED_SOFTWARE_CATEGORIZED.ARPDisplayName0 AS DisplayName, 6 | dbo.v_GS_INSTALLED_SOFTWARE_CATEGORIZED.ProductVersion0 AS Version, 7 | dbo.v_GS_INSTALLED_SOFTWARE_CATEGORIZED.Publisher0 AS Publisher, 8 | dbo.v_GS_INSTALLED_SOFTWARE_CATEGORIZED.ProductCode0 AS ProductCode 9 | FROM 10 | dbo.v_GS_INSTALLED_SOFTWARE_CATEGORIZED INNER JOIN 11 | dbo.v_R_System ON dbo.v_GS_INSTALLED_SOFTWARE_CATEGORIZED.ResourceID = dbo.v_R_System.ResourceID 12 | WHERE 13 | (dbo.v_GS_INSTALLED_SOFTWARE_CATEGORIZED.ProductName0 LIKE 'Google Chrome%') 14 | ORDER BY 15 | ComputerName -------------------------------------------------------------------------------- /poshserver/reports/Software - Microsoft Visio Installations.sql: -------------------------------------------------------------------------------- 1 | SELECT DISTINCT 2 | SYS.Name0 AS ComputerName, 3 | ARP.DisplayName0 AS ProductName, 4 | ARP.Version0 AS Version, 5 | ARP.InstallDate0 AS InstallDate, 6 | SYS.AD_Site_Name0 AS ADSite, 7 | dbo.v_GS_COMPUTER_SYSTEM.Model0 AS Model, 8 | dbo.v_GS_OPERATING_SYSTEM.Caption0 AS OSName, 9 | dbo.v_GS_OPERATING_SYSTEM.BuildNumber0 AS OSBuild, 10 | dbo.v_GS_PHYSICAL_MEMORY.Capacity0 AS Memory 11 | FROM 12 | dbo.v_R_System AS SYS INNER JOIN 13 | dbo.v_FullCollectionMembership AS FCM ON FCM.ResourceID = SYS.ResourceID INNER JOIN 14 | dbo.v_Add_Remove_Programs AS ARP ON SYS.ResourceID = ARP.ResourceID INNER JOIN 15 | dbo.v_GS_COMPUTER_SYSTEM ON SYS.ResourceID = dbo.v_GS_COMPUTER_SYSTEM.ResourceID INNER JOIN 16 | dbo.v_GS_OPERATING_SYSTEM ON SYS.ResourceID = dbo.v_GS_OPERATING_SYSTEM.ResourceID INNER JOIN 17 | dbo.v_GS_PHYSICAL_MEMORY ON SYS.ResourceID = dbo.v_GS_PHYSICAL_MEMORY.ResourceID 18 | WHERE 19 | (ARP.DisplayName0 LIKE '%Visio Standard%' 20 | OR 21 | ARP.DisplayName0 LIKE '%Visio Professional%' 22 | ) 23 | AND 24 | (ARP.InstallDate0 IS NOT NULL) 25 | ORDER BY 26 | ProductName, Version -------------------------------------------------------------------------------- /poshserver/reports/Software - Office Products Detailed.sql: -------------------------------------------------------------------------------- 1 | SELECT DISTINCT 2 | SYS.Name0 AS ComputerName, 3 | ARP.DisplayName0 AS ProductName, 4 | ARP.Version0 AS Version, 5 | dbo.v_GS_OPERATING_SYSTEM.Caption0 AS OperatingSystem, 6 | dbo.v_GS_OPERATING_SYSTEM.BuildNumber0 AS Build, 7 | SYS.User_Name0 AS LastUser, 8 | dbo.v_R_User.User_Name0 AS MainUser, 9 | SYS.AD_Site_Name0 AS ADSite 10 | FROM 11 | dbo.v_R_User INNER JOIN 12 | dbo.v_UsersPrimaryMachines ON 13 | dbo.v_R_User.ResourceID = dbo.v_UsersPrimaryMachines.UserResourceID 14 | RIGHT OUTER JOIN 15 | dbo.v_R_System AS SYS INNER JOIN 16 | dbo.v_FullCollectionMembership AS FCM ON FCM.ResourceID = SYS.ResourceID INNER JOIN 17 | dbo.v_Add_Remove_Programs AS ARP ON 18 | SYS.ResourceID = ARP.ResourceID ON 19 | dbo.v_UsersPrimaryMachines.MachineID = SYS.ResourceID LEFT OUTER JOIN 20 | dbo.v_GS_OPERATING_SYSTEM ON SYS.ResourceID = dbo.v_GS_OPERATING_SYSTEM.ResourceID 21 | WHERE 22 | (ARP.DisplayName0 LIKE '%Microsoft % Standard%') OR 23 | (ARP.DisplayName0 LIKE 'Microsoft % Professional%') OR 24 | (ARP.DisplayName0 LIKE 'Microsoft % Enterprise %') OR 25 | (ARP.DisplayName0 = 'Microsoft Office 365 ProPlus - en-us') 26 | ORDER BY 27 | ComputerName -------------------------------------------------------------------------------- /poshserver/reports/Software - OneDrive Sync Client Versions.sql: -------------------------------------------------------------------------------- 1 | SELECT DISTINCT 2 | dbo.v_GS_SoftwareFile.FileName, 3 | dbo.v_GS_SoftwareFile.FileVersion, 4 | COUNT(*) AS Installs 5 | FROM 6 | dbo.v_GS_SoftwareFile 7 | WHERE 8 | (dbo.v_GS_SoftwareFile.FileName = 'OneDrive.exe') 9 | GROUP BY 10 | dbo.v_GS_SoftwareFile.FileName, 11 | dbo.v_GS_SoftwareFile.FileVersion 12 | ORDER BY 13 | dbo.v_GS_SoftwareFile.FileVersion -------------------------------------------------------------------------------- /poshserver/reports/Software - OneDrive Sync Clients.sql: -------------------------------------------------------------------------------- 1 | SELECT DISTINCT 2 | v_R_System.Name0 AS [ComputerName], 3 | v_GS_INSTALLED_EXECUTABLE.ResourceID, 4 | v_GS_INSTALLED_EXECUTABLE.ExecutableName0 AS [ExeName], 5 | v_GS_INSTALLED_EXECUTABLE.FileSize0 AS [FileSize], 6 | v_GS_INSTALLED_EXECUTABLE.FileVersion0 AS [FileVersion], 7 | v_GS_INSTALLED_EXECUTABLE.InstalledFilePath0 AS [InstallPath], 8 | v_GS_INSTALLED_EXECUTABLE.ProductCode0 AS [ProductCode], 9 | v_GS_INSTALLED_EXECUTABLE.ProductVersion0 AS [ProductVersion], 10 | v_GS_INSTALLED_EXECUTABLE.Publisher0 AS [Publisher] 11 | FROM 12 | v_GS_INSTALLED_EXECUTABLE INNER JOIN 13 | v_R_System ON v_GS_INSTALLED_EXECUTABLE.ResourceID = v_R_System.ResourceID 14 | WHERE 15 | (v_GS_INSTALLED_EXECUTABLE.ExecutableName0 IN ('OneDrive.exe', 'OneDriveSetup.exe','Groove.exe')) 16 | ORDER BY 17 | v_R_System.Name0 -------------------------------------------------------------------------------- /poshserver/reports/Software - Windows Update Client Versions.sql: -------------------------------------------------------------------------------- 1 | SELECT DISTINCT 2 | Version0 AS [Version], 3 | COUNT(*) AS Clients 4 | FROM 5 | dbo.v_GS_WINDOWSUPDATEAGENTVERSION 6 | GROUP BY 7 | Version0 8 | ORDER BY 9 | [Version] -------------------------------------------------------------------------------- /poshserver/reports/Software - Windows Update Clients.sql: -------------------------------------------------------------------------------- 1 | SELECT DISTINCT 2 | v_R_System.Name0 as [ComputerName], 3 | v_R_System.ResourceID, 4 | v_GS_WINDOWSUPDATEAGENTVERSION.Version0 AS Version 5 | FROM 6 | v_GS_WINDOWSUPDATEAGENTVERSION INNER JOIN 7 | v_R_System ON v_GS_WINDOWSUPDATEAGENTVERSION.ResourceID = v_R_System.ResourceID 8 | GROUP BY 9 | v_GS_WINDOWSUPDATEAGENTVERSION.Version0, 10 | v_R_System.ResourceID, dbo.v_R_System.Name0 11 | ORDER BY 12 | v_R_System.Name0 13 | -------------------------------------------------------------------------------- /poshserver/reports/Software Updates - ADR Summary.sql: -------------------------------------------------------------------------------- 1 | SELECT DISTINCT 2 | AutoDeploymentID, 3 | Name as RuleName, 4 | Description, 5 | AutoDeploymentEnabled, 6 | LastRunTime 7 | FROM 8 | vSMS_AutoDeployments -------------------------------------------------------------------------------- /poshserver/search.ps1: -------------------------------------------------------------------------------- 1 | $PageTitle = "Search" 2 | $PageCaption = "Search" 3 | 4 | $SearchScoping = $PoshQuery.g 5 | $chk1 = "false" 6 | $chk2 = "false" 7 | if ($SearchScoping -eq 'cm') { 8 | $chk1 = "checked" 9 | } 10 | if ($SearchScoping -eq 'ad') { 11 | $chk2 = "checked" 12 | } 13 | 14 | $content = "" 15 | 16 | if ($CMEnabled -ne 'false') { 17 | $chklist = ('cmdevices:v_r_system:name0','cmusers:v_r_user:user_name0','cmdevcolls:v_collection:name:collectiontype:2','cmusercolls:v_collection:name:collectiontype:1','cmproducts:v_gs_installed_software_categorized:productname0','cmfiles:v_gs_softwarefile:filename','cmts:v_TaskSequencePackage:name') 18 | $chknames = ('Devices','Users','Device Collections','User Collections','Software Products','Software Files','Task Sequences') 19 | for ($i = 0; $i -lt $chklist.Count; $i++) { 20 | $content += " ConfigMgr $($chknames[$i])
" 21 | } 22 | } 23 | 24 | if ($ADEnabled -ne 'false') { 25 | $chklist = ('adusers','adgroups','adcomputers') 26 | $chknames = ('Users','Groups','Computers') 27 | for ($i = 0; $i -lt $chklist.Count; $i++) { 28 | $content += " Active Directory $($chknames[$i])
" 29 | } 30 | } 31 | 32 | @" 33 | 34 | 35 | 36 | 42 | 43 | 44 | 45 | 46 |

$PageCaption

47 | 48 |
49 | 50 | 51 | 54 | 64 | 65 | 66 | 69 | 80 | 81 | 82 | 86 | 87 |
52 | Search Phrase ($SearchScoping) 53 | 55 | 56 | 63 |
67 | Search Targets 68 | 70 | 71 | 72 | 75 | 77 | 78 |
73 | $content 74 | 76 |
79 |
83 | 84 | 85 |
88 |
89 | 90 | 91 | 92 | "@ -------------------------------------------------------------------------------- /poshserver/showfiles.ps1: -------------------------------------------------------------------------------- 1 | $SearchField = Get-PageParam -TagName 'f' -Default "" 2 | $SearchValue = Get-PageParam -TagName 'v' -Default "" 3 | $SearchType = Get-PageParam -TagName 'x' -Default "equals" 4 | $SortField = Get-PageParam -TagName 's' -Default "Name" 5 | $SortOrder = Get-PageParam -TagName 'so' -Default "asc" 6 | $TabSelected = Get-PageParam -TagName 'tab' -Default 'all' 7 | $Detailed = Get-PageParam -TagName 'zz' -Default "" 8 | $CustomName = Get-PageParam -TagName 'n' -Default "" 9 | $NestedLevel = Get-PageParam -TagName 'nl' -Default "" 10 | $IsFiltered = $False 11 | $PageTitle = "Files: $SearchValue" 12 | $PageCaption = "Files: $SearchValue" 13 | $content = "" 14 | $tabset = "" 15 | $outree = $null 16 | $query = $null 17 | $xxx = "" 18 | 19 | $content = "" 20 | try { 21 | if ($NestedLevel -gt 0) { 22 | $uplink = ($SearchValue -split '\\') 23 | $uplink = "\\$($uplink[2..$($uplink.length -2)] -join '\')" 24 | $uplink = "Go Back" 25 | $content += "" 26 | } 27 | if (Test-Path $SearchValue) { 28 | $subs = Get-ChildItem -Path $SearchValue -Directory -ErrorAction SilentlyContinue 29 | foreach ($sub in $subs) { 30 | $fpath = $sub.FullName 31 | $fname = $sub.Name 32 | $flink = "$fname" 33 | $content += "" 34 | } 35 | } 36 | else { 37 | $content += "" 38 | } 39 | $resolved = $true 40 | } 41 | catch { 42 | $content += "" 43 | $resolved = $false 44 | } 45 | finally { 46 | $content += "
$uplink
$flink
no folders were found in $SearchValue
$($Error[0].Exception.Message)
" 47 | } 48 | 49 | if ($resolved -eq $true) { 50 | $content += "

Files in: $SearchValue

" 51 | $content += "" 52 | try { 53 | $fount = 0 54 | $files = Get-ChildItem -Path $SearchValue -File -ErrorAction SilentlyContinue 55 | foreach ($file in $files) { 56 | $fpath = $file.FullName 57 | $fname = $file.Name 58 | $flink = "$fname" 59 | $content += "" 60 | $fcount++ 61 | } 62 | if ($fcount -gt 0) { 63 | $content += "" 64 | } 65 | else { 66 | $content += "" 67 | } 68 | } 69 | catch { 70 | $content += "" 71 | } 72 | finally { 73 | $content += "
$flink
$fcount files were found
No files were found in this location
$($Error[0].Exception.Message)
" 74 | } 75 | } 76 | 77 | @" 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 |

$PageCaption

86 | 87 | $tabset 88 | $content 89 | 90 | 91 | 92 | "@ -------------------------------------------------------------------------------- /poshserver/skreport.ps1: -------------------------------------------------------------------------------- 1 | $Script:SearchField = Get-PageParam -TagName 'f' -Default "" 2 | $Script:SearchValue = Get-PageParam -TagName 'v' -Default "" 3 | $Script:SearchType = Get-PageParam -TagName 'x' -Default "equals" 4 | $Script:SortField = Get-PageParam -TagName 's' -Default "" 5 | $Script:Detailed = Get-PageParam -TagName 'zz' -Default "" 6 | $Script:TabSelected = Get-PageParam -TagName 'tab' -Default "" 7 | $Script:CustomName = Get-PageParam -TagName 'n' -Default "" 8 | $Caption = $Script:CustomName -replace '.sql','' 9 | 10 | $Script:PageTitle = "Custom Report: $Caption" 11 | $Script:PageCaption = "Custom Report: $Caption" 12 | $Script:SortField = "" 13 | $content = "" 14 | $tabset = "" 15 | $query = "" 16 | 17 | try { 18 | $rpath = $(Join-Path -Path $PSScriptRoot -ChildPath "reports") 19 | $rfile = $(Join-Path -Path $rpath -ChildPath $Script:CustomName) 20 | if (Test-Path $rfile) { 21 | $content = Get-SkQueryTable3 -QueryFile $rfile -PageLink "skreport.ps1" -NoUnFilter -NoCaption 22 | } 23 | else { 24 | throw "$rfile not found" 25 | } 26 | } 27 | catch { 28 | $content = "
Error: $($Error[0].Exception.Message)
" 29 | } 30 | 31 | $content += Write-DetailInfo -PageRef "skreport.ps1" -Mode $Script:Detailed 32 | 33 | @" 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 |

$PageCaption

42 | 43 | $tabset 44 | $content 45 | 46 | 47 | 48 | "@ -------------------------------------------------------------------------------- /poshserver/skreports.ps1: -------------------------------------------------------------------------------- 1 | $SearchField = Get-PageParam -TagName 'f' -Default "" 2 | $SearchValue = Get-PageParam -TagName 'v' -Default "" 3 | $SearchType = Get-PageParam -TagName 'x' -Default "equals" 4 | $SortField = Get-PageParam -TagName 's' -Default "" 5 | $Detailed = Get-PageParam -TagName 'zz' -Default "" 6 | $TabSelected = Get-PageParam -TagName 'tab' -Default "" 7 | $CustomName = Get-PageParam -TagName 'n' -Default "" 8 | 9 | $PageTitle = "Custom Reports" 10 | $PageCaption = "Custom Reports" 11 | $SortField = "" 12 | $content = "" 13 | $tabset = "" 14 | 15 | try { 16 | $rpath = $(Join-Path -Path $PSScriptRoot -ChildPath "reports") 17 | $rfiles = Get-ChildItem -Path $rpath -Filter "*.sql" | Sort-Object Name 18 | $content = "" 19 | $rowcount = $rfiles.Count 20 | $rfiles | %{$content += ""} 21 | $content += "" 22 | $content += "
Report Name
$($_.Name -replace '.sql','')
$rowcount reports
" 23 | } 24 | catch {} 25 | 26 | $content += Write-DetailInfo -PageRef "skreports.ps1" -Mode $Detailed 27 | 28 | @" 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 |

$PageCaption

37 | 38 | $tabset 39 | $content 40 | 41 | 42 | 43 | "@ -------------------------------------------------------------------------------- /poshserver/sktools.ps1: -------------------------------------------------------------------------------- 1 | # SkatterTools Site Configuration 2 | 3 | $Global:SkToolsVersion = "1812.27.02" 4 | 5 | $configFile = Join-Path -Path $HomeDirectory -ChildPath "config.txt" 6 | if (!(Test-Path $configFile)) { 7 | Write-Warning "Config.txt was not found. Shit just got real." 8 | break 9 | } 10 | $cdata = Get-Content $configFile | Where-Object{$_ -notlike ';*'} 11 | foreach ($line in $cdata) { 12 | $varset = $line -split '=' 13 | if ($varset.Count -gt 1) { 14 | Set-Variable -Name $varset[0] -Value $($varset[1]).Trim() -Scope Global | Out-Null 15 | } 16 | } 17 | 18 | foreach ($m in @('sqlserver','dbatools','carbon')) { 19 | if (Get-Module -Name $m) { 20 | #Write-Host "importing powershell module: $m" -ForegroundColor Cyan 21 | Import-Module -Name $m 22 | } 23 | } 24 | 25 | if ($Global:SkToolsLoaded -ne 1) { 26 | try { 27 | Get-ChildItem (Join-Path -Path $HomeDirectory -ChildPath "lib") -Filter "*.ps1" -ErrorAction Stop | ForEach-Object { . $_.FullName } 28 | $Global:SkToolsLoaded = 1 29 | $Global:LastLoadTime = Get-Date 30 | } 31 | catch { 32 | Write-Error "OMFG - something smells really bad in here?!" 33 | break 34 | } 35 | } 36 | --------------------------------------------------------------------------------