commit 71764cd10f0e7a814768fbfc07536a95a8143e41 Author: Andrew Amason Date: Mon Apr 21 14:21:38 2025 -0400 Intune Initial Scripts Backup diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5698c7f --- /dev/null +++ b/.gitignore @@ -0,0 +1,38 @@ +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +!.vscode/*.code-snippets + +# Local History for Visual Studio Code +.history/ + +# Built Visual Studio Code Extensions +*.vsix + +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..4673315 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,31 @@ +{ + "yaml.customTags": [ + "!And", + "!And sequence", + "!If", + "!If sequence", + "!Not", + "!Not sequence", + "!Equals", + "!Equals sequence", + "!Or", + "!Or sequence", + "!FindInMap", + "!FindInMap sequence", + "!Base64", + "!Join", + "!Join sequence", + "!Cidr", + "!Ref", + "!Sub", + "!Sub sequence", + "!GetAtt", + "!GetAZs", + "!ImportValue", + "!ImportValue sequence", + "!Select", + "!Select sequence", + "!Split", + "!Split sequence" + ] +} \ No newline at end of file diff --git a/Install-Docker-Desktop.ps1 b/Install-Docker-Desktop.ps1 new file mode 100644 index 0000000..8dfb020 --- /dev/null +++ b/Install-Docker-Desktop.ps1 @@ -0,0 +1,159 @@ +set-executionpolicy -scope CurrentUser -executionPolicy Bypass -Force +If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) +{ + # Relaunch as an elevated process: + Start-Process powershell.exe "-File",('"{0}"' -f $MyInvocation.MyCommand.Path) -Verb RunAs + exit +} + +$ProgressPreference = 'SilentlyContinue' + + Function GenerateFolder($path) { + $global:foldPath = $null + foreach($foldername in $path.split("\")) { + $global:foldPath += ($foldername+"\") + if (!(Test-Path $global:foldPath)){ + New-Item -ItemType Directory -Path $global:foldPath + # Write-Host "$global:foldPath Folder Created Successfully" + } + } +} + +function getStatus +{ + try { + # First we create the request. + $HTTP_Request = [System.Net.WebRequest]::Create('http://localhost') + + # We then get a response from the site. + $HTTP_Response = $HTTP_Request.GetResponse() + + # We then get the HTTP code as an integer. + return [int]$HTTP_Response.StatusCode + } catch [System.Net.WebException] { + + } +} + +GenerateFolder "~/AppData/Roaming/Docker/" + +Write-Host "Checking if Hyper-V is enabled." +$hyperv = Get-WindowsOptionalFeature -FeatureName Microsoft-Hyper-V-All -Online + +# Check if Hyper-V is enabled +if($hyperv.State -eq "Enabled") { + Write-Host "Hyper-V is enabled." + + $wsl = Get-WindowsOptionalFeature -FeatureName Microsoft-Windows-Subsystem-Linux -Online + + if($wsl.State -eq "Enabled") { + + Write-Host "WSL is enabled." + + if ([Environment]::Is64BitOperatingSystem) + { + Write-Host "System is x64. Need to update Linux kernel..." + if (-not (Test-Path wsl_update_x64.msi)) + { + Write-Host "Downloading Linux kernel update package..." + Invoke-WebRequest -OutFile wsl_update_x64.msi https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi + } + Write-Host "Installing Linux kernel update package..." + Start-Process msiexec.exe -Wait -ArgumentList '/I wsl_update_x64.msi /quiet' + Write-Host "Linux kernel update package installed." + } + + Write-Host "WSL is enabled. Setting it to WSL2" + wsl --set-default-version 2 + + # disable distro install + # no need to install distro as docker runs on its own distro + <# + if (-not (Test-Path Ubuntu.zip)) + { + Write-Host "Downloading wsl-ubuntu-1804..." + Invoke-WebRequest -Uri https://aka.ms/wsl-ubuntu-1804 -OutFile Ubuntu.zip -UseBasicParsing + Expand-Archive Ubuntu.zip 'C:\Ubuntu' + + Write-Host "A pop up widow will open shortly..." + Write-Host "Once prompted provide user name, password and confirm password..." + Write-Host "This does not have to be your windows user name and password. You can provide any of your prefered username and a password." + Write-Host "Onec the Linux prompt is shown type exit and press enter." + + Start-Process c:\Ubuntu\ubuntu1804.exe -Wait + } + + wsl -l -v + wsl --set-version Ubuntu-18.04 2 + wsl -l -v + #> + + if (-not (Test-Path DockerInstaller.exe)) + { + Write-Host "Installing Docker." + + + Write-Host "Downloading the Docker exe" + Invoke-WebRequest -Uri https://desktop.docker.com/win/stable/Docker%20Desktop%20Installer.exe -OutFile DockerInstaller.exe -UseBasicParsing + Write-Host "Download Completed" + + start-process .\DockerInstaller.exe "install --quiet" -Wait -NoNewWindow + cd "C:\Program Files\Docker\Docker\" + Write-Host "Installing Docker..." + $ProgressPreference = 'SilentlyContinue' + & '.\Docker Desktop.exe' + $env:Path += ";C:\Program Files\Docker\Docker\Resources\bin" + $env:Path += ";C:\Program Files\Docker\Docker\Resources" + Write-Host "Docker Installed successfully" + Write-Host "You must reboot the sytem to continue. After reboot re-run the script." + Restart-Computer -Confirm + } + Write-Host "Starting docker..." + $ErrorActionPreference = 'SilentlyContinue'; + do { $var1 = docker ps 2>$null } while (-Not $var1) + $ErrorActionPreference = 'Stop'; + $env:Path += ";C:\Program Files\Docker\Docker\Resources\bin" + $env:Path += ";C:\Program Files\Docker\Docker\Resources" + Write-Host "Docker Started successfully" + + + } + else { + Write-Host "WSL is disabled." + Write-Host "Enabling WSL2 feature now" + + & cmd /c 'dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart' + & cmd /c 'dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart' + Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform + Start-Sleep 30 + Write-Host "WSL is enabled now reboot the system and re-run the script to continue the installation." + } + + + + +} else { + Write-Host "Hyper-V is disabled." + Write-Host "Enabling Hyper-V feature now" + Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All + Start-Sleep 30 + Write-Host "Hyper-V is enabled now reboot the system and re-run the script to continue the installation." +} + + + +<# +REFERENCES USED FOR WRITING THIS SCRIPT + +https://adamtheautomator.com/windows-subsystem-for-linux/#:~:text=To%20start%20using%20WSL%2C%20open,exe%20provides%20when%20starting%20up. +https://superuser.com/questions/1271682/is-there-a-way-of-installing-ubuntu-windows-subsystem-for-linux-on-win10-v170 +https://stackoverflow.com/questions/61396435/how-do-i-check-the-os-architecture32-or-64-bit-using-powershell +https://renenyffenegger.ch/notes/Windows/Subsystem-for-Linux/index +https://docs.docker.com/docker-for-windows/wsl/ +https://docs.microsoft.com/en-us/windows/wsl/install-win10 +https://superuser.com/questions/1271682/is-there-a-way-of-installing-ubuntu-windows-subsystem-for-linux-on-win10-v170 + +https://wiki.ubuntu.com/WSL + +https://winaero.com/export-import-wsl-linux-distro-windows-10/ +#> \ No newline at end of file diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..8f316e4 --- /dev/null +++ b/README.txt @@ -0,0 +1 @@ +Please update the purpose of this repo... \ No newline at end of file diff --git a/Restart-SyncCycle.ps1 b/Restart-SyncCycle.ps1 new file mode 100644 index 0000000..ef30872 --- /dev/null +++ b/Restart-SyncCycle.ps1 @@ -0,0 +1,120 @@ +Function Restart-SCCMSyncCycle { + <# + .Synopsis + Remotely restarts sccm service cycles. + + + .DESCRIPTION + This function restarts all sccm policies on a remote client so that the client can immediately get any pending software updates or inventory. + + + .NOTES + Name: Restart-SCCMSyncCycle + Author: theSysadminChannel + Version: 1 + DateCreated: 2017-02-09 + + + .LINK + https://thesysadminchannel.com/remotely-restart-sccmsynccycle-using-powershell - + + + .PARAMETER ComputerName + The computer to which connectivity will be checked + + + .EXAMPLE + Restart-SCCMSyncCycle -Computername Pactest-1 + + Description: + Will restart all sccm services on a remote machine. + + .EXAMPLE + Restart-SCCMSyncCycle -ComputerName pactest-1, pactest-2, pactest-3 + + Description: + Will generate a list of installed programs on pactest-1, pactest-2 and pactest-3 + + #> + + + [CmdletBinding()] + param( + [Parameter( + ValueFromPipeline=$true, + ValueFromPipelineByPropertyName=$true, + Position=0)] + [string[]] $ComputerName = $env:COMPUTERNAME + + ) + + Foreach ($Computer in $ComputerName ) { + try { + + Write-Host "=====================================================================" + Write-Output "$Computer : Machine Policy Evaluation Cycle" + Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000022}" -ErrorAction Stop | select -ExpandProperty PSComputerName | Out-Null + + + Write-Output "$Computer : Application Deployment Evaluation Cycle" + Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000121}" | select -ExpandProperty PSComputerName | Out-Null + + + Write-Output "$Computer : Discovery Data Collection Cycle" + Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000003}" | select -ExpandProperty PSComputerName | Out-Null + + + Write-Output "$Computer : File Collection Cycle" + Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000010}" | select -ExpandProperty PSComputerName | Out-Null + + + Write-Output "$Computer : Hardware Inventory Cycle" + Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000001}" | select -ExpandProperty PSComputerName | Out-Null + + + Write-Output "$Computer : Machine Policy Retrieval Cycle" + Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000021}" | select -ExpandProperty PSComputerName | Out-Null + + + Write-Output "$Computer : Software Inventory Cycle" + Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000002}" | select -ExpandProperty PSComputerName | Out-Null + + + Write-Output "$Computer : Software Metering Usage Report Cycle" + Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000031}" | select -ExpandProperty PSComputerName | Out-Null + + + Write-Output "$Computer : Software Update Deployment Evaluation Cycle" + Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000114}" | select -ExpandProperty PSComputerName | Out-Null + + + #Write-Output "$Computer : Software Update Scan Cycle" + #Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000113}" | select -ExpandProperty PSComputerName | Out-Null + + + Write-Output "$Computer : State Message Refresh" + Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000111}" | select -ExpandProperty PSComputerName | Out-Null + + + #Write-Output "$Computer : User Policy Retrieval Cycle" + #Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000026}" | select -ExpandProperty PSComputerName | Out-Null + + + #Write-Output "$Computer : User Policy Evaluation Cycle" + #Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000027}" | select -ExpandProperty PSComputerName | Out-Null + + + Write-Output "$Computer : Windows Installers Source List Update Cycle" + Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000032}" | select -ExpandProperty PSComputerName | Out-Null + + sleep 1 + } + + catch { + Write-Host $Computer.toUpper() "is not online" -ForegroundColor:Red + Write-Host + Write-Host + + } + } + } \ No newline at end of file diff --git a/dump/6PM - unknown.txt b/dump/6PM - unknown.txt new file mode 100644 index 0000000..c62d48d Binary files /dev/null and b/dump/6PM - unknown.txt differ diff --git a/dump/9pm-Error.txt b/dump/9pm-Error.txt new file mode 100644 index 0000000..9a2dda2 Binary files /dev/null and b/dump/9pm-Error.txt differ diff --git a/dump/Add-to-Local-Admins-Group.ps1 b/dump/Add-to-Local-Admins-Group.ps1 new file mode 100644 index 0000000..e253b80 --- /dev/null +++ b/dump/Add-to-Local-Admins-Group.ps1 @@ -0,0 +1,5 @@ +$Acct = "ccx/sccm" +$Ws = "l201131" + +Invoke-Command $Ws { Param($Acct,$Ws) ([ADSI]"WinNT://$Ws/administrators,group").psbase.Invoke("Add",([ADSI]"WinNT://$Acct").path)} -ArgumentList $Acct,$Ws + diff --git a/dump/CCXQ - Shared.txt b/dump/CCXQ - Shared.txt new file mode 100644 index 0000000..630d0f6 --- /dev/null +++ b/dump/CCXQ - Shared.txt @@ -0,0 +1,73 @@ +Q1NCRAFILE001 +QRSH111 +QIIS005 +QRDS002 +QMHB003 +QMHB004 +QRDS001 +QPGP001 +QMHB001 +QMFT001 +QRSH101 +QSCH012 +QDRF001 +QFNP008 +Q2NCRAFILE001 +Q3NCRAFILE001 +QMHB002 +QSIS001 +QSRS001 +QSRS004 +QFNP007 +QSQL029 +QSQL030 +Q5NCRAFILE001 +QSQL006 +QADF001 +QTABL001 +Q4NCRAFILE001 +QFNP009 +QSCH011 +QSQL028 +QAPP021 +QSCH014 +QFNP001 +QSCH013 +PQRSH001 +QVST012 +QVST011 +QSIS003 +QSQL001 +QBTS001 +QWTS004 +QWTS005 +QWTS006 +QWTS001 +QAPP005 +QIIS002 +QDWH001 +QIIS004 +QAPP001 +QSIS002 +QWTS010 +QIIS001 +QBIZ121 +QBIZ131 +QBIZ132 +QBIZ122 +PQRDS001 +QFNP003 +Q4SQL024 +QVST021 +QVST022 +QAPP003 +QEDI113 +QEDI112 +QEDI111 +QRSH112 +QEDI152 +QEDI153 +QEDI151 +QUTL012 +QCMX001 +QNCRASPOWA01 \ No newline at end of file diff --git a/dump/CMClient.psm1 b/dump/CMClient.psm1 new file mode 100644 index 0000000..4d34838 --- /dev/null +++ b/dump/CMClient.psm1 @@ -0,0 +1,644 @@ +<# + =========================================================================== + Created with: SAPIEN Technologies, Inc., PowerShell Studio 2014 v4.1.58 + Created on: 6/9/2014 1:57 PM + Created by: Adam Bertram + Filename: CMClient.psm1 + ------------------------------------------------------------------------- + Module Name: CMClient + =========================================================================== +#> +#region Invoke-CMClientAction +<# +.SYNOPSIS + This is a helper function that initiates many ConfigMgr client actions. +.DESCRIPTION + +.PARAMETER Computername + The system you'd like to initate the action on. +.PARAMETER AsJob + A switch parameter that initates a job in the background +.PARAMETER ClientAction + The client action to initiate. +.EXAMPLE + PS C:\> Invoke-CMClientAction -Computername 'Value1' -AsJob + This example shows how to call the Invoke-CMClientAction function with named parameters. +.NOTES +#> +function Invoke-CMClientAction { + [CmdletBinding()] + param + ( + [Parameter(Mandatory = $true)] + [string]$Computername, + [Parameter(Mandatory = $true)] + [ValidateSet('MachinePolicy', + 'DiscoveryData', + 'ComplianceEvaluation', + 'AppDeployment', + 'HardwareInventory', + 'UpdateDeployment', + 'UpdateScan', + 'SoftwareInventory')] + [string]$ClientAction, + [Parameter()] + [switch]$AsJob + ) + + Begin { + try { + $ScheduleIDMappings = @{ + 'MachinePolicy' = '{00000000-0000-0000-0000-000000000021}'; + 'DiscoveryData' = '{00000000-0000-0000-0000-000000000003}'; + 'ComplianceEvaluation' = '{00000000-0000-0000-0000-000000000071}'; + 'AppDeployment' = '{00000000-0000-0000-0000-000000000121}'; + 'HardwareInventory' = '{00000000-0000-0000-0000-000000000001}'; + 'UpdateDeployment' = '{00000000-0000-0000-0000-000000000108}'; + 'UpdateScan' = '{00000000-0000-0000-0000-000000000113}'; + 'SoftwareInventory' = '{00000000-0000-0000-0000-000000000002}'; + } + $ScheduleID = $ScheduleIDMappings[$ClientAction] + } catch { + Write-Error $_.Exception.Message + } + + } + Process { + try { + ## Args1 represents the computername and $args[1] represents the scheduleID + $ActionScriptBlock = { + [void] ([wmiclass] "\\$($args[0])\root\ccm:SMS_Client").TriggerSchedule($args[1]); + if (!$?) { + throw "Failed to initiate a $ClientAction on $($args[0])" + } + } + + if ($AsJob.IsPresent) { + $Params = @{ + 'Computername' = $Computername; + 'OriginatingFunction' = $ClientAction; + 'ScriptBlock' = $ActionScriptBlock; + 'ScheduleID' = $ScheduleID + } + Initialize-CMClientJob @Params + } else { + Invoke-Command -ScriptBlock $ActionScriptBlock -ArgumentList $Computername,$ScheduleID + } + } catch { + Write-Error $_.Exception.Message + } + + } + End { + + } +} +#endregion + +#region Initialize-CMClientJob +<# +.SYNOPSIS + This is a helper function that starts and manages background jobs for the all + functions in this module. +.DESCRIPTION + +.PARAMETER OriginatingFunction + The function where the job request came from. This is used to keep track of + which background jobs were started by which function. +.PARAMETER ScriptBlock + This is the scriptblock that is passed to the system. +.PARAMETER Computername + The computer name that the function is connecting to. This is used to keep track + of the functions initiated on computers. +.PARAMETER ScheduleID + This is the schedule ID to designate which client action to initiate. This is needed + because it has to be sent to the background job scriptblock. +.EXAMPLE + +.NOTES +#> +function Initialize-CMClientJob { + [CmdletBinding()] + param + ( + [Parameter(Mandatory = $true)] + [string]$OriginatingFunction, + [Parameter(Mandatory = $true)] + [scriptblock]$ScriptBlock, + [Parameter(Mandatory = $true)] + [string]$Computername, + [Parameter(Mandatory = $true)] + [string]$ScheduleID + ) + + Begin { + ## The total number of jobs that can be concurrently running + $MaxJobThreads = 75 + ## How long to wait when the max job threads has been met to start another job + $JobWaitSecs = 1 + } + Process { + try { + Write-Verbose "Starting job `"$ComputerName - $OriginatingFunction`"..." + Start-Job -ScriptBlock $ScriptBlock -Name "$ComputerName - $OriginatingFunction" -ArgumentList $Computername, $ScheduleID | Out-Null + While ((Get-Job -state running).count -ge $MaxJobThreads) { + Write-Verbose "Maximum job threshold has been met. Waiting $JobWaitSecs second(s) to try again..."; + Start-Sleep -Seconds $JobWaitSecs + } + } catch { + Write-Error $_.Exception.Message + } + } + End { + + } +} +#endregion + +#region Invoke-CMClientMachinePolicyDownload +<# +.SYNOPSIS + This function invokes a machine policy download on a ConfigMgr client +.DESCRIPTION + +.PARAMETER Computername + The name of the system you'd like to invoke the machine policy download on +.PARAMETER AsJob + Specify this parameter if you'd like to run this as a background job. +.EXAMPLE + PS C:\> Invoke-CMClientMachinePolicyDownload -Computername 'Value1' -AsJob +.NOTES + +#> +function Invoke-CMClientMachinePolicyDownload { + [CmdletBinding()] + param + ( + [Parameter(Mandatory = $true, + ValueFromPipeline = $true, + ValueFromPipelineByPropertyName = $true)] + [alias('Name')] + [string]$Computername, + [Parameter()] + [switch]$AsJob + ) + + Begin { + + } + Process { + $Params = @{ + 'Computername' = $Computername; + 'ClientAction' = 'MachinePolicy'; + 'AsJob' = $AsJob.IsPresent + } + Invoke-CMClientAction @Params + } + End { + + } +} +#endregion + +#region Invoke-CMClientDiscoveryDataCycle +<# +.SYNOPSIS + This function invokes a DDR cycle on a ConfigMgr client +.DESCRIPTION + +.PARAMETER Computername + The name of the system you'd like to invoke the action on +.PARAMETER AsJob + Specify this parameter if you'd like to run this as a background job. +.EXAMPLE + PS C:\> Invoke-CMClientDiscoveryDataCycle -Computername 'Value1' -AsJob +.NOTES + +#> +function Invoke-CMClientDiscoveryDataCycle { + [CmdletBinding()] + param + ( + [Parameter(Mandatory = $true, + ValueFromPipeline = $true, + ValueFromPipelineByPropertyName = $true)] + [string]$Computername, + [Parameter()] + [switch]$AsJob + ) + + Begin { + + } + Process { + $Params = @{ + 'Computername' = $Computername; + 'ClientAction' = 'DiscoveryData'; + 'AsJob' = $AsJob.IsPresent + } + Invoke-CMClientAction @Params + } + End { + + } +} +#endregion + +#region Invoke-CMClientComplianceEvaluation +<# +.SYNOPSIS + This function invokes a compliance evaluation on a ConfigMgr client +.DESCRIPTION + +.PARAMETER Computername + The name of the system you'd like to invoke the action on +.PARAMETER AsJob + Specify this parameter if you'd like to run this as a background job. +.EXAMPLE + PS C:\> Invoke-CMClientComplianceEvaluation -Computername 'Value1' -AsJob +.NOTES + +#> +function Invoke-CMClientComplianceEvaluation { + [CmdletBinding()] + param + ( + [Parameter(Mandatory = $true, + ValueFromPipeline = $true, + ValueFromPipelineByPropertyName = $true)] + [string]$Computername, + [Parameter()] + [switch]$AsJob + ) + + Begin { + + } + Process { + $Params = @{ + 'Computername' = $Computername; + 'ClientAction' = 'ComplianceEvaluation'; + 'AsJob' = $AsJob.IsPresent + } + Invoke-CMClientAction @Params + } + End { + + } +} +#endregion + +#region Invoke-CMClientApplicationDeploymentEvaluation +<# +.SYNOPSIS + This function invokes an application deployment eval on a ConfigMgr client +.DESCRIPTION + +.PARAMETER Computername + The name of the system you'd like to invoke the action on +.PARAMETER AsJob + Specify this parameter if you'd like to run this as a background job. +.EXAMPLE + PS C:\> Invoke-CMClientApplicationDeploymentEvaluation -Computername 'Value1' -AsJob +.NOTES + +#> +function Invoke-CMClientApplicationDeploymentEvaluation { + [CmdletBinding()] + param + ( + [Parameter(Mandatory = $true, + ValueFromPipeline = $true, + ValueFromPipelineByPropertyName = $true)] + [string]$Computername, + [Parameter()] + [switch]$AsJob + ) + + Begin { + + } + Process { + $Params = @{ + 'Computername' = $Computername; + 'ClientAction' = 'AppDeployment'; + 'AsJob' = $AsJob.IsPresent + } + Invoke-CMClientAction @Params + } + End { + + } +} +#endregion + +#region Invoke-CMClientHardwareInventory +<# +.SYNOPSIS + This function invokes a hardware inventory cycle on a ConfigMgr client +.DESCRIPTION + +.PARAMETER Computername + The name of the system you'd like to invoke the action on +.PARAMETER AsJob + Specify this parameter if you'd like to run this as a background job. +.EXAMPLE + PS C:\> Invoke-CMClientHardwareInventory -Computername 'Value1' -AsJob +.NOTES + +#> +function Invoke-CMClientHardwareInventory { + [CmdletBinding()] + param + ( + [Parameter(Mandatory = $true, + ValueFromPipeline = $true, + ValueFromPipelineByPropertyName = $true)] + [string]$Computername, + [Parameter()] + [switch]$AsJob + ) + + Begin { + + } + Process { + $Params = @{ + 'Computername' = $Computername; + 'ClientAction' = 'HardwareInventory'; + 'AsJob' = $AsJob.IsPresent + } + Invoke-CMClientAction @Params + } + End { + + } +} +#endregion + +#region Invoke-CMClientUpdateDeploymentEvaluation +<# +.SYNOPSIS + This function invokes an update deployment eval on a ConfigMgr client +.DESCRIPTION + +.PARAMETER Computername + The name of the system you'd like to invoke the action on +.PARAMETER AsJob + Specify this parameter if you'd like to run this as a background job. +.EXAMPLE + PS C:\> Invoke-CMClientUpdateDeploymentEvaluation -Computername 'Value1' -AsJob +.NOTES + +#> +function Invoke-CMClientUpdateDeploymentEvaluation { + [CmdletBinding()] + param + ( + [Parameter(Mandatory = $true, + ValueFromPipeline = $true, + ValueFromPipelineByPropertyName = $true)] + [string]$Computername, + [Parameter()] + [switch]$AsJob + ) + + Begin { + + } + Process { + $Params = @{ + 'Computername' = $Computername; + 'ClientAction' = 'UpdateDeployment'; + 'AsJob' = $AsJob.IsPresent + } + Invoke-CMClientAction @Params + } + End { + + } +} +#endregion + +#region Invoke-CMClientUpdateScan +<# +.SYNOPSIS + This function invokes an update scan eval on a ConfigMgr client +.DESCRIPTION + +.PARAMETER Computername + The name of the system you'd like to invoke the action on +.PARAMETER AsJob + Specify this parameter if you'd like to run this as a background job. +.EXAMPLE + PS C:\> Invoke-CMClientUpdateScan -Computername 'Value1' -AsJob +.NOTES + +#> +function Invoke-CMClientUpdateScan { + [CmdletBinding()] + param + ( + [Parameter(Mandatory = $true, + ValueFromPipeline = $true, + ValueFromPipelineByPropertyName = $true)] + [string]$Computername, + [Parameter()] + [switch]$AsJob + ) + + Begin { + + } + Process { + $Params = @{ + 'Computername' = $Computername; + 'ClientAction' = 'UpdateScan'; + 'AsJob' = $AsJob.IsPresent + } + Invoke-CMClientAction @Params + } + End { + + } +} +#endregion + +#region Invoke-CMClientSoftwareInventory +<# +.SYNOPSIS + This function invokes a software inventory scan on a ConfigMgr client +.DESCRIPTION + +.PARAMETER Computername + The name of the system you'd like to invoke the action on +.PARAMETER AsJob + Specify this parameter if you'd like to run this as a background job. +.EXAMPLE + PS C:\> Invoke-CMClientSoftwareInventory -Computername 'Value1' -AsJob +.NOTES + +#> +function Invoke-CMClientSoftwareInventory { + [CmdletBinding()] + param + ( + [Parameter(Mandatory = $true, + ValueFromPipeline = $true, + ValueFromPipelineByPropertyName = $true)] + [string]$Computername, + [Parameter()] + [switch]$AsJob + ) + + Begin { + + } + Process { + $Params = @{ + 'Computername' = $Computername; + 'ClientAction' = 'SoftwareInventory'; + 'AsJob' = $AsJob.IsPresent + } + Invoke-CMClientAction @Params + } + End { + + } +} +#endregion + +## Modify these function as advanced functions +<# +Function Set-CMClientBusinessHours ($ComputerName, $StartTime = 3, $EndTime = 7, $WorkingDays) { + ## The first digit is the start time (7am), the second digit is the end time (7pm) and the third digit is the days of the week. + ## The days of the week are calculated using the table below, so Monday – Friday is calculated as 2+4+8+16+32 = 62. + ## Sunday - 1, Monday - 2, Tuesday - 4, Wednesday - 8, Thursday - 16, Friday - 32, Saturday - 64 + + try { + Write-Debug "Initiating the $($MyInvocation.MyCommand.Name) function..."; + + $cmClientUserSettings = [WmiClass]"\\$ComputerName\ROOT\ccm\ClientSDK:CCM_ClientUXSettings" + $businessHours = $cmClientUserSettings.PSBase.GetMethodParameters("SetBusinessHours") + $businessHours.StartTime = $StartTime + $businessHours.EndTime = $EndTime + $businessHours.WorkingDays = $WorkingDays + + $result = $cmClientUserSettings.PSBase.InvokeMethod("SetBusinessHours", $businessHours, $Null) + + if ($result.ReturnValue -eq 0) { + $mResult = $true + } else { + $mResult = $false; + } + + return $mResult + + } catch [System.Exception] { + Write-Error $_.Exception.Message; + }##endtry +}##endfunction + +Function Get-CMClientBusinessHours ($ComputerName) { + ## The first digit is the start time (7am), the second digit is the end time (7pm) and the third digit is the days of the week. + ## The days of the week are calculated using the table below, so Monday – Friday is calculated as 2+4+8+16+32 = 62. + ## Sunday - 1, Monday - 2, Tuesday - 4, Wednesday - 8, Thursday - 16, Friday - 32, Saturday - 64 + + try { + Write-Debug "Initiating the $($MyInvocation.MyCommand.Name) function..."; + + $cmClientUserSettings = [WmiClass]"\\$ComputerName\ROOT\ccm\ClientSDK:CCM_ClientUXSettings" + $businessHours = $cmClientUserSettings.GetBusinessHours() + $businessHoursCI = [string]$businessHours.StartTime + "," + [string]$businessHours.EndTime + "," + [string]$businessHours.WorkingDays + + return $businessHoursCI + + } catch [System.Exception] { + Write-Error $_.Exception.Message; + }##endtry +}##endfunction + +Function Disable-CMClientBusinessHours ($ComputerName) { + try { + ## Change the "automatic install or uninstall required software and restart the computer only outside of the specified business hours + + return $mResult + + } catch [System.Exception] { + Write-Error $_.Exception.Message; + }##endtry +}##endfunction + +Function Get-SccmApplicationState ($ComputerName,$Name = $null,[switch]$IncludeDetails) { + try { + Write-Debug "Initiating the $($MyInvocation.MyCommand.Name) function..."; + + $eval_states = @{0 = 'No state information is available'; + 1 = 'Application is enforced to desired/resolved state'; + 2 = 'Application is not required on the client'; + 3 = 'Application is available for enforcement (install or uninstall based on resolved state). Content may/may not have been downloaded'; + 4 = 'Application last failed to enforce (install/uninstall)'; + 5 = 'Application is currently waiting for content download to complete'; + 6 = 'Application is currently waiting for content download to complete'; + 7 = 'Application is currently waiting for its dependencies to download'; + 8 = 'Application is currently waiting for a service (maintenance) window'; + 9 = 'Application is currently waiting for a previously pending reboot'; + 10 = 'Application is currently waiting for serialized enforcement'; + 11 = 'Application is currently enforcing dependencies'; + 12 = 'Application is currently enforcing'; + 13 = 'Application install/uninstall enforced and soft reboot is pending'; + 14 = 'Application installed/uninstalled and hard reboot is pending'; + 15 = 'Update is available but pending installation'; + 16 = 'Application failed to evaluate'; + 17 = 'Application is currently waiting for an active user session to enforce'; + 18 = 'Application is currently waiting for all users to logoff'; + 19 = 'Application is currently waiting for a user logon'; + 20 = 'Application in progress, waiting for retry'; + 21 = 'Application is waiting for presentation mode to be switched off'; + 22 = 'Application is pre-downloading content (downloading outside of install job)'; + 23 = 'Application is pre-downloading dependent content (downloading outside of install job)'; + 24 = 'Application download failed (downloading during install job)'; + 25 = 'Application pre-downloading failed (downloading outside of install job)'; + 26 = 'Download success (downloading during install job)'; + 27 = 'Post-enforce evaluation'; + 28 = 'Waiting for network connectivity'; + } + + if ($Name -and $IncludeDetails.IsPresent) { + $aApps = Request-Wmi -ComputerName $ComputerName -Namespace 'root\ccm\clientsdk' -Query "SELECT * FROM CCM_Application WHERE FullName = '$Name'" + } elseif ($Name -and !$IncludeDetails.IsPresent) { + $aApps = Request-Wmi -ComputerName $ComputerName -Namespace 'root\ccm\clientsdk' -Query "SELECT * FROM CCM_Application WHERE FullName = '$Name'" | Select-Object PSComputerName,FullName,InstallState,ErrorCode,EvaluationState,@{label='StartTime';expression={$_.ConvertToDateTime($_.StartTime)}} + } elseif (!$Name -and $IncludeDetails.IsPresent) { + $aApps = Request-Wmi -ComputerName $ComputerName -Namespace 'root\ccm\clientsdk' -Query "SELECT * FROM CCM_Application" + } elseif (!$Name -and !$IncludeDetails.IsPresent) { + $aApps = Request-Wmi -ComputerName $ComputerName -Namespace 'root\ccm\clientsdk' -Query "SELECT * FROM CCM_Application" | Select-Object PSComputerName,FullName,InstallState,ErrorCode,EvaluationState,@{label='StartTime';expression={$_.ConvertToDateTime($_.StartTime)}} + } + + if (!$aApps) { + $mResult = "$($MyInvocation.MyCommand.Name): WMI query failed"; + } else { + $mResult = $aApps | Sort-Object FullName; + }##endif + + return $mResult; + + } catch [System.Exception] { + Write-Error $_.Exception.Message; + }##endtry +}##endfunction + +Function Get-CMClientUpdateDeploymentState() { + +} +#> + +Export-ModuleMember Invoke-CMClientUpdateScan # +Export-ModuleMember Invoke-CMClientUpdateDeploymentEvaluation # +Export-ModuleMember Invoke-CMClientHardwareInventory +Export-ModuleMember Invoke-CMClientApplicationDeploymentEvaluation +Export-ModuleMember Invoke-CMClientComplianceEvaluation +Export-ModuleMember Invoke-CMClientDiscoveryDataCycle +Export-ModuleMember Invoke-CMClientMachinePolicyDownload # + + + diff --git a/dump/CMClientDeviceCollectionMembership.ps1 b/dump/CMClientDeviceCollectionMembership.ps1 new file mode 100644 index 0000000..ebef369 --- /dev/null +++ b/dump/CMClientDeviceCollectionMembership.ps1 @@ -0,0 +1,70 @@ +<# +2 .SYNOPSIS +3 Get the collection membership of a configuration manager client device or computer. +4 +5 .DESCRIPTION +6 Get the collection membership of a configuration manager client device or computer. +7 This function will query System Center Configuration manager for a given computer name +8 and return the collections for which it is a member. +9 +10 .PARAMETER ComputerName +11 Provide a computer name. +12 +13 .PARAMETER SiteServer +14 Specify the name or FQDN of your SCCM site server. By default it gathers the site server +15 from the computer from which the function is called. +16 +17 .PARAMETER SiteCode +18 Specify the site code of your SCCM environment. By default it gathers the site code +19 from the computer from which the function is called. +20 +21 .PARAMETER Credential +22 Provide a credential object for accessing the site server. +23 +24 .EXAMPLE +25 Get-CMClientDeviceCollectionMembership +26 +27 Gets the collection membership of the local host. +28 +29 .EXAMPLE +30 Get-CMClientDeviceCollectionMembership -Computer DESKTOP01 +31 +32 Gets the collection membership of DESKTOP01 +33 +34 .EXAMPLE +35 Get-CMClientDeviceCollectionMembership -Computer DESKTOP01 -Summary +36 +37 Gets the collection membership of DESKTOP01 in a summary format. +38 +39 .NOTES +40 Created by: Jason Wasser @wasserja +41 Modified: 6/8/2017 10:49:50 AM +42 #> +function Get-CMClientDeviceCollectionMembership { + [CmdletBinding()] + param ( + [string]$ComputerName = $env:COMPUTERNAME, + [string]$SiteServer = (Get-WmiObject -Namespace root\ccm -ClassName SMS_Authority).CurrentManagementPoint, + [string]$SiteCode = (Get-WmiObject -Namespace root\ccm -ClassName SMS_Authority).Name.Split(':')[1], + [switch]$Summary, + [System.Management.Automation.PSCredential]$Credential = [System.Management.Automation.PSCredential]::Empty + ) + + + begin {} + process { + Write-Verbose -Message "Gathering collection membership of $ComputerName from Site Server $SiteServer using Site Code $SiteCode." + $Collections = Get-WmiObject -ComputerName $SiteServer -Namespace root/SMS/site_$SiteCode -Credential $Credential -Query "SELECT SMS_Collection.* FROM SMS_FullCollectionMembership, SMS_Collection where name = '$ComputerName' and SMS_FullCollectionMembership.CollectionID = SMS_Collection.CollectionID" + if ($Summary) { + $Collections | Select-Object -Property Name,CollectionID + } + else { + $Collections + } + + } + end {} + } + + # Get-CMClientDeviceCollectionMembership -ComputerName w2012a | Select name,LimitToCollectionName + diff --git a/dump/CMUpdateReset.exe b/dump/CMUpdateReset.exe new file mode 100644 index 0000000..fd44c13 Binary files /dev/null and b/dump/CMUpdateReset.exe differ diff --git a/dump/Clean Software Update Packages in ConfigMgr with PowerShell System Center ConfigMgr.website b/dump/Clean Software Update Packages in ConfigMgr with PowerShell System Center ConfigMgr.website new file mode 100644 index 0000000..4a99254 --- /dev/null +++ b/dump/Clean Software Update Packages in ConfigMgr with PowerShell System Center ConfigMgr.website @@ -0,0 +1,14 @@ +[{000214A0-0000-0000-C000-000000000046}] +Prop3=19,11 +Prop4=31,Clean Software Update Packages in ConfigMgr with PowerShell | | System Center ConfigMgr +[InternetShortcut] +IDList= +URL=https://www.scconfigmgr.com/2017/08/17/clean-software-update-packages-in-configmgr-with-powershell/ +IconFile=https://i0.wp.com/www.scconfigmgr.com/wp-content/uploads/2017/03/cropped-SCConfigMgrLOGO_Symbol_Transparent.png?fit=32%2C32&ssl=1 +IconIndex=1 +[{A7AF692E-098D-4C08-A225-D433CA835ED0}] +Prop5=3,0 +Prop9=19,0 +Prop2=65,2C0000000000000001000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1D0100003D000000CD050000AF030000FC +[{9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3}] +Prop5=8,Microsoft.Website.F65A605E.1C4ACA4F diff --git a/dump/Collection-Members.ps1 b/dump/Collection-Members.ps1 new file mode 100644 index 0000000..4ffe1cc --- /dev/null +++ b/dump/Collection-Members.ps1 @@ -0,0 +1,97 @@ +<# + +Import-Module 'C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1' +New-PSDrive -Name SCCM-Drive -PSProvider "AdminUI.PS.Provider\CMSite" -Root "PNCRASCCM001.ccx.carecentrix.com" -Description "SCCM Site" + +#> + + + + +# $DeviceCollection_Name = "Nabil - Test Collection" + + +<# + + + $DeviceCollection_Name = "All - Inventory - Supporting Infrastructure" + + $DeviceCollection_Name = "Stage 2. ADR - QA Servers" + + $DeviceCollection_Name = "Stage 3. ADR - PRD Servers - Set 2" + $DeviceCollection_Name = "Stage 3. ADR - PRD Servers - Set 1" + + $DeviceCollection_Name = "Stage 1. ADR - DEV Servers - Set 1" + +#### $DeviceCollection_Name_ALL = "All - Inventory - Infrastructure Servers", + "All - Inventory - Supporting Infrastructure", + "All - Inventory - Database", + "All - Inventory - Application Servers" + + + + + + +#> +<# + CD sccm-drive: + + $DeviceCollection_MemberCount = Get-CMDeviceCollection -Name $DeviceCollection_Name | select Name,MemberCount + $DeviceCollection_ServerNames = Get-CMCollectionMember -CollectionName $DeviceCollection_Name | select Name,IsClient #| Export-Csv "E:\SCCM-Files\SCCM-Scripts\Files\$DeviceCollection_Name.csv" -NoTypeInformation + $ServerName = $DeviceCollection_ServerNames.Name + $ServerName.count + + Set-Location c: + +#> + #$DeviceCollection_Name = "" + + CD sccm-drive: + + $DeviceCollection_MemberCount = Get-CMDeviceCollection -Name $DeviceCollection_Name | select Name,MemberCount + $DeviceCollection_ServerNames = Get-CMCollectionMember -CollectionName $DeviceCollection_Name | select Name,IsClient #| Export-Csv "E:\SCCM-Files\SCCM-Scripts\Files\$DeviceCollection_Name.csv" -NoTypeInformation + $ServerName = $DeviceCollection_ServerNames.Name + $ServerName.count + + Set-Location c: + + + + #$No_Client = $DeviceCollection_ServerNames | ? { $_.IsClient -eq $false } + #$No_Client.count + + # Test-Connection -ComputerName $No_Client.name -Count 1 + + + $Script:ALL_Patch_Servers = @() + $Script:Temp = @() + + Function ALL_Patching_Servers { + Param($Coll_Name) + CD sccm-drive: + + + $Script:Temp = Get-CMCollectionMember -CollectionName $Coll_Name #| select Name,IsClient + + $Temp | % { + $Obj = New-Object -TypeName PSObject + $Obj | Add-Member -MemberType NoteProperty -Name Server -Value $_.Name + $Obj | Add-Member -MemberType NoteProperty -Name ClientInstalled -Value $_.IsClient + $Obj | Add-Member -MemberType NoteProperty -Name CollectionName -Value $Coll_Name + #$Obj | Add-Member -MemberType NoteProperty -Name CollectionMemberCount -Value {(Get-CMCollectionMember -Name $Coll_Name).MemberCount} + + $Obj + $Script:ALL_Patch_Servers += $Obj + }#end% + + }#endFunction + + #$DeviceCollection_Name_ALL | % { ALL_Patching_Servers -Coll_Name $_ } + + $DeviceCollection_Name | % { ALL_Patching_Servers -Coll_Name $_ | sort Server} + +Set-Location c: + + + diff --git a/dump/ConfigMgr Client Action Module.URL b/dump/ConfigMgr Client Action Module.URL new file mode 100644 index 0000000..f720218 --- /dev/null +++ b/dump/ConfigMgr Client Action Module.URL @@ -0,0 +1,6 @@ +[InternetShortcut] +URL=https://gallery.technet.microsoft.com/systemcenter/ConfigMgr-Client-Action-16a364a5 +IDList= +HotKey=0 +IconFile=C:\Users\nnazmat\AppData\Local\Mozilla\Firefox\Profiles\20v5hisb.default-release\shortcutCache\nnqCGd961WQk9_zngRurQg==.ico +IconIndex=0 diff --git a/dump/Decline-SupersededUpdatesWithExclusionPeriod.ps1.ps1 b/dump/Decline-SupersededUpdatesWithExclusionPeriod.ps1.ps1 new file mode 100644 index 0000000..fa88dd7 --- /dev/null +++ b/dump/Decline-SupersededUpdatesWithExclusionPeriod.ps1.ps1 @@ -0,0 +1,235 @@ +# =============================================== +# Script to decline superseeded updates in WSUS. +# =============================================== +# It's recommended to run the script with the -SkipDecline switch to see how many superseded updates are in WSUS and to TAKE A BACKUP OF THE SUSDB before declining the updates. +# Parameters: + +# $UpdateServer = Specify WSUS Server Name +# $UseSSL = Specify whether WSUS Server is configured to use SSL +# $Port = Specify WSUS Server Port +# $SkipDecline = Specify this to do a test run and get a summary of how many superseded updates we have +# $DeclineLastLevelOnly = Specify whether to decline all superseded updates or only last level superseded updates +# $ExclusionPeriod = Specify the number of days between today and the release date for which the superseded updates must not be declined. Eg, if you want to keep superseded updates published within the last 2 months, specify a value of 60 (days) + + +# Supersedence chain could have multiple updates. +# For example, Update1 supersedes Update2. Update2 supersedes Update3. In this scenario, the Last Level in the supersedence chain is Update3. +# To decline only the last level updates in the supersedence chain, specify the DeclineLastLevelOnly switch + +# Usage: +# ======= + +# To do a test run against WSUS Server without SSL +# Decline-SupersededUpdates.ps1 -UpdateServer SERVERNAME -Port 8530 -SkipDecline + +# To do a test run against WSUS Server using SSL +# Decline-SupersededUpdates.ps1 -UpdateServer SERVERNAME -UseSSL -Port 8531 -SkipDecline + +# To decline all superseded updates on the WSUS Server using SSL +# Decline-SupersededUpdates.ps1 -UpdateServer SERVERNAME -UseSSL -Port 8531 + +# To decline only Last Level superseded updates on the WSUS Server using SSL +# Decline-SupersededUpdates.ps1 -UpdateServer SERVERNAME -UseSSL -Port 8531 -DeclineLastLevelOnly + +# To decline all superseded updates on the WSUS Server using SSL but keep superseded updates published within the last 2 months (60 days) +# Decline-SupersededUpdates.ps1 -UpdateServer SERVERNAME -UseSSL -Port 8531 -ExclusionPeriod 60 + + + +[CmdletBinding()] +Param( + [Parameter(Mandatory=$True,Position=1)] + [string] $UpdateServer, + + [Parameter(Mandatory=$False)] + [switch] $UseSSL, + + [Parameter(Mandatory=$True, Position=2)] + $Port, + + [switch] $SkipDecline, + + [switch] $DeclineLastLevelOnly, + + [Parameter(Mandatory=$False)] + [int] $ExclusionPeriod = 0 +) + +Write-Host "" + +if ($SkipDecline -and $DeclineLastLevelOnly) { + Write-Host "Using SkipDecline and DeclineLastLevelOnly switches together is not allowed." + Write-Host "" + return +} + +$outPath = Split-Path $script:MyInvocation.MyCommand.Path +$outSupersededList = Join-Path $outPath "SupersededUpdates.csv" +$outSupersededListBackup = Join-Path $outPath "SupersededUpdatesBackup.csv" +"UpdateID, RevisionNumber, Title, KBArticle, SecurityBulletin, LastLevel" | Out-File $outSupersededList + +try { + + if ($UseSSL) { + Write-Host "Connecting to WSUS server $UpdateServer on Port $Port using SSL... " -NoNewLine + } Else { + Write-Host "Connecting to WSUS server $UpdateServer on Port $Port... " -NoNewLine + } + + [reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration") | out-null + $wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::GetUpdateServer($UpdateServer, $UseSSL, $Port); +} +catch [System.Exception] +{ + Write-Host "Failed to connect." + Write-Host "Error:" $_.Exception.Message + Write-Host "Please make sure that WSUS Admin Console is installed on this machine" + Write-Host "" + $wsus = $null +} + +if ($wsus -eq $null) { return } + +Write-Host "Connected." + +$countAllUpdates = 0 +$countSupersededAll = 0 +$countSupersededLastLevel = 0 +$countSupersededExclusionPeriod = 0 +$countSupersededLastLevelExclusionPeriod = 0 +$countDeclined = 0 + +Write-Host "Getting a list of all updates... " -NoNewLine + +try { + $allUpdates = $wsus.GetUpdates() +} + +catch [System.Exception] +{ + Write-Host "Failed to get updates." + Write-Host "Error:" $_.Exception.Message + Write-Host "If this operation timed out, please decline the superseded updates from the WSUS Console manually." + Write-Host "" + return +} + +Write-Host "Done" + +Write-Host "Parsing the list of updates... " -NoNewLine +foreach($update in $allUpdates) { + + $countAllUpdates++ + + if ($update.IsDeclined) { + $countDeclined++ + } + + if (!$update.IsDeclined -and $update.IsSuperseded) { + $countSupersededAll++ + + if (!$update.HasSupersededUpdates) { + $countSupersededLastLevel++ + } + + if ($update.CreationDate -lt (get-date).AddDays(-$ExclusionPeriod)) { + $countSupersededExclusionPeriod++ + if (!$update.HasSupersededUpdates) { + $countSupersededLastLevelExclusionPeriod++ + } + } + + "$($update.Id.UpdateId.Guid), $($update.Id.RevisionNumber), $($update.Title), $($update.KnowledgeBaseArticles), $($update.SecurityBulletins), $($update.HasSupersededUpdates)" | Out-File $outSupersededList -Append + + } +} + +Write-Host "Done." +Write-Host "List of superseded updates: $outSupersededList" + +Write-Host "" +Write-Host "Summary:" +Write-Host "========" + +Write-Host "All Updates =" $countAllUpdates +Write-Host "Any except Declined =" ($countAllUpdates - $countDeclined) +Write-Host "All Superseded Updates =" $countSupersededAll +Write-Host " Superseded Updates (Intermediate) =" ($countSupersededAll - $countSupersededLastLevel) +Write-Host " Superseded Updates (Last Level) =" $countSupersededLastLevel +Write-Host " Superseded Updates (Older than $ExclusionPeriod days) =" $countSupersededExclusionPeriod +Write-Host " Superseded Updates (Last Level Older than $ExclusionPeriod days) =" $countSupersededLastLevelExclusionPeriod +Write-Host "" + +$i = 0 +if (!$SkipDecline) { + + Write-Host "SkipDecline flag is set to $SkipDecline. Continuing with declining updates" + $updatesDeclined = 0 + + if ($DeclineLastLevelOnly) { + Write-Host " DeclineLastLevel is set to True. Only declining last level superseded updates." + + foreach ($update in $allUpdates) { + + if (!$update.IsDeclined -and $update.IsSuperseded -and !$update.HasSupersededUpdates) { + if ($update.CreationDate -lt (get-date).AddDays(-$ExclusionPeriod)) { + $i++ + $percentComplete = "{0:N2}" -f (($updatesDeclined/$countSupersededLastLevelExclusionPeriod) * 100) + Write-Progress -Activity "Declining Updates" -Status "Declining update #$i/$countSupersededLastLevelExclusionPeriod - $($update.Id.UpdateId.Guid)" -PercentComplete $percentComplete -CurrentOperation "$($percentComplete)% complete" + + try + { + $update.Decline() + $updatesDeclined++ + } + catch [System.Exception] + { + Write-Host "Failed to decline update $($update.Id.UpdateId.Guid). Error:" $_.Exception.Message + } + } + } + } + } + else { + Write-Host " DeclineLastLevel is set to False. Declining all superseded updates." + + foreach ($update in $allUpdates) { + + if (!$update.IsDeclined -and $update.IsSuperseded) { + if ($update.CreationDate -lt (get-date).AddDays(-$ExclusionPeriod)) { + + $i++ + $percentComplete = "{0:N2}" -f (($updatesDeclined/$countSupersededAll) * 100) + Write-Progress -Activity "Declining Updates" -Status "Declining update #$i/$countSupersededAll - $($update.Id.UpdateId.Guid)" -PercentComplete $percentComplete -CurrentOperation "$($percentComplete)% complete" + try + { + $update.Decline() + $updatesDeclined++ + } + catch [System.Exception] + { + Write-Host "Failed to decline update $($update.Id.UpdateId.Guid). Error:" $_.Exception.Message + } + } + } + } + + } + + Write-Host " Declined $updatesDeclined updates." + if ($updatesDeclined -ne 0) { + Copy-Item -Path $outSupersededList -Destination $outSupersededListBackup -Force + Write-Host " Backed up list of superseded updates to $outSupersededListBackup" + } + +} +else { + Write-Host "SkipDecline flag is set to $SkipDecline. Skipped declining updates" +} + + + + +Write-Host "" +Write-Host "Done" +Write-Host "" \ No newline at end of file diff --git a/dump/Dev-Servers-Ping.txt b/dump/Dev-Servers-Ping.txt new file mode 100644 index 0000000..d644839 Binary files /dev/null and b/dump/Dev-Servers-Ping.txt differ diff --git a/dump/Files/9PM - Production Patching-NoInstall.csv b/dump/Files/9PM - Production Patching-NoInstall.csv new file mode 100644 index 0000000..0d1819b --- /dev/null +++ b/dump/Files/9PM - Production Patching-NoInstall.csv @@ -0,0 +1,60 @@ +"Server","InstalledOn","LastHF","InstalledBy","Description" +"KSOVEPOPS001","8/20/2017 12:00:00 AM","Q2758694","Server Administration and Management","Security update for MSXML4 SP3 (KB2758694)" +"PSQL023","10/13/2019 12:00:00 AM","KB4520005","NT AUTHORITY\SYSTEM","Security Update" +"PSQL022","10/13/2019 12:00:00 AM","KB4520005","NT AUTHORITY\SYSTEM","Security Update" +"PSEC002","1/26/2020 12:00:00 AM","KB4534251","CCX\clroth-ccxadmin","Security Update" +"PSQL023B","1/26/2020 12:00:00 AM","KB4534324","NT AUTHORITY\SYSTEM","Update" +"PNCRAFILE005","1/26/2020 12:00:00 AM","KB4534271","NT AUTHORITY\SYSTEM","Security Update" +"PFNP014","1/26/2020 12:00:00 AM","KB4534324","NT AUTHORITY\SYSTEM","Update" +"PRSH058","1/26/2020 12:00:00 AM","KB4534324","NT AUTHORITY\SYSTEM","Update" +"PSPT001","1/26/2020 12:00:00 AM","KB4534251","CCX\NNAZMAT-CCXADMIN","Security Update" +"PRSH003","2/14/2020 12:00:00 AM","KB4537821","NT AUTHORITY\SYSTEM","Security Update" +"PRSH002","2/14/2020 12:00:00 AM","KB4537821","NT AUTHORITY\SYSTEM","Security Update" +"PRSH152","2/16/2020 12:00:00 AM","KB4537767","NT AUTHORITY\SYSTEM","Security Update" +"PBIZ124","2/16/2020 12:00:00 AM","KB4537821","NT AUTHORITY\SYSTEM","Security Update" +"PSQL016","2/16/2020 12:00:00 AM","KB4537821","CCX\jmbukov-ccxadmin","Security Update" +"PFNP011","2/16/2020 12:00:00 AM","KB4537821","CCX\kmboatr-ccxadmin","Security Update" +"PIIS003","2/16/2020 12:00:00 AM","KB4539601","CCX\abamaso-ccxadmin","Update" +"PSQL026","2/16/2020 12:00:00 AM","KB4520724","CCX\jmbukov-ccxadmin","Security Update" +"PSQL011","2/16/2020 12:00:00 AM","KB4539601","CCX\abamaso-ccxadmin","Update" +"PFNP005","2/16/2020 12:00:00 AM","KB2632503","PFNP005\Administrator","Update" +"PFNP013","2/16/2020 12:00:00 AM","KB4537764","NT AUTHORITY\SYSTEM","Security Update" +"PGAW001","2/16/2020 12:00:00 AM","KB4537821","CCX\rrpante-ccxadmin","Security Update" +"PSQL007","2/16/2020 12:00:00 AM","KB4538483","CCX\dapalme-ccxadmin","Security Update" +"PEXP001","2/16/2020 12:00:00 AM","KB4538483","CCX\clroth-ccxadmin","Security Update" +"PMHB002","2/16/2020 12:00:00 AM","KB4537821","NT AUTHORITY\SYSTEM","Security Update" +"PVSS012","2/16/2020 12:00:00 AM","KB4537821","CCX\rrpante-ccxadmin","Security Update" +"PSNW001","2/16/2020 12:00:00 AM","KB4537821","CCX\SSTHOMA6-CCXAdmin","Security Update" +"PSHP002","2/16/2020 12:00:00 AM","KB4534310","CCX\kmboatr-ccxadmin","Security Update" +"PKEY001","2/16/2020 12:00:00 AM","KB4538483","CCX\SSTHOMA6-CCXAdmin","Security Update" +"PIIS005","2/16/2020 12:00:00 AM","KB4538483","CCX\baboyle-ccxadmin","Security Update" +"PSQL006","2/16/2020 12:00:00 AM","KB4538483","CCX\rrpante-ccxadmin","Security Update" +"PSRS003","2/16/2020 12:00:00 AM","KB4538483","CCX\rrpante-ccxadmin","Security Update" +"PRSH055","2/16/2020 12:00:00 AM","KB4537821","CCX\dapalme-ccxadmin","Security Update" +"PTABL001","2/16/2020 12:00:00 AM","KB4537821","CCX\SSTHOMA6-CCXAdmin","Security Update" +"PQRDS001","2/16/2020 12:00:00 AM","KB4537821","NT AUTHORITY\SYSTEM","Security Update" +"PSRS001","2/16/2020 12:00:00 AM","KB2841134","CCX\baboyle-ccxadmin","Update" +"PNCRAFILE001","2/16/2020 12:00:00 AM","KB4537764","NT AUTHORITY\SYSTEM","Security Update" +"PARM001","2/16/2020 12:00:00 AM","KB4538483","CCX\abamaso-ccxadmin","Security Update" +"PBIZ122","2/16/2020 12:00:00 AM","KB4537821","NT AUTHORITY\SYSTEM","Security Update" +"PBIZ123","2/16/2020 12:00:00 AM","KB4537821","NT AUTHORITY\SYSTEM","Security Update" +"PSLK001","2/16/2020 12:00:00 AM","KB4537821","CCX\clroth-ccxadmin","Security Update" +"PADF001","2/16/2020 12:00:00 AM","KB4538483","CCX\SSTHOMA6-CCXAdmin","Security Update" +"PRSH059","2/16/2020 12:00:00 AM","KB4537821","NT AUTHORITY\SYSTEM","Security Update" +"PBIZ126","2/16/2020 12:00:00 AM","KB4537821","NT AUTHORITY\SYSTEM","Security Update" +"PWTS040","2/16/2020 12:00:00 AM","KB2849696","CCX\rrpante-ccxadmin","Update" +"PBIZ125","2/16/2020 12:00:00 AM","KB4537821","NT AUTHORITY\SYSTEM","Security Update" +"PRSH008","2/16/2020 12:00:00 AM","KB4537821","NT AUTHORITY\SYSTEM","Security Update" +"PBIZ121","2/16/2020 12:00:00 AM","KB4537821","NT AUTHORITY\SYSTEM","Security Update" +"PRSH024","2/16/2020 12:00:00 AM","KB4537821","NT AUTHORITY\SYSTEM","Security Update" +"PRSH010","2/16/2020 12:00:00 AM","KB4486105","NT AUTHORITY\SYSTEM","Update" +"PRSH005","2/16/2020 12:00:00 AM","KB4537821","NT AUTHORITY\SYSTEM","Security Update" +"PRSH015","2/16/2020 12:00:00 AM","KB4537821","NT AUTHORITY\SYSTEM","Security Update" +"PIIS007","2/16/2020 12:00:00 AM","KB4538483","CCX\clroth-ccxadmin","Security Update" +"PRSH021","2/16/2020 12:00:00 AM","KB4537821","NT AUTHORITY\SYSTEM","Security Update" +"PRSH020","2/16/2020 12:00:00 AM","KB4537821","NT AUTHORITY\SYSTEM","Security Update" +"PRSH018","2/16/2020 12:00:00 AM","KB4537821","NT AUTHORITY\SYSTEM","Security Update" +"PNCRAFILE003","2/16/2020 12:00:00 AM","KB4537764","NT AUTHORITY\SYSTEM","Security Update" +"PDOC001","2/16/2020 12:00:00 AM","KB4537821","CCX\rrpante-ccxadmin","Security Update" +"PRSH013","2/16/2020 12:00:00 AM","KB4537821","NT AUTHORITY\SYSTEM","Security Update" +"PSPT002","2/16/2020 12:00:00 AM","KB4534310","CCX\kmboatr-ccxadmin","Security Update" \ No newline at end of file diff --git a/dump/Files/9PM - Production Patching.csv b/dump/Files/9PM - Production Patching.csv new file mode 100644 index 0000000..ad6d9cf --- /dev/null +++ b/dump/Files/9PM - Production Patching.csv @@ -0,0 +1,164 @@ +"Name","IsClient" +"PQRSH001","True" +"PRSH027","True" +"PRSH019","True" +"PRSH011","True" +"PRSH020","True" +"PRSH021","True" +"PAAD001","True" +"PRSH023","True" +"PRSH010","True" +"PRSH024","True" +"PRSH008","True" +"PRSH001","True" +"PRSH006","True" +"PRSH000","True" +"PRSH009","True" +"PRSH005","True" +"PRSH003","True" +"PRSH004","True" +"PRSH002","True" +"PRSH007","True" +"PRSH022","True" +"PRSH014","True" +"PRSH012","True" +"PRSH016","True" +"PRSH015","True" +"PRSH018","True" +"PRSH017","True" +"PRSH013","True" +"PRSH028","True" +"PRSH052","True" +"PRSH025","True" +"PRSH029","True" +"PRSH026","True" +"PSSP001","True" +"PRSH172","True" +"PWTS040","True" +"PFNP009","True" +"PSPT002","True" +"PDOC001","True" +"PEDI114","True" +"PRSH054","True" +"PRSH051","True" +"PWHD003","True" +"PRSH174","True" +"PBIZ125","True" +"PBIZ121","True" +"PFNP010","True" +"PRSH171","True" +"PIIS007","True" +"PNCRAFILE003","True" +"PSUF002","True" +"PPCH001","True" +"PRSH059","True" +"PBIZ112","True" +"PPCS001","True" +"PARM001","True" +"PSKY001","True" +"PSQL022B","True" +"PTTS011","True" +"PFNP006","True" +"PIIS003","True" +"PEXP001","True" +"PFNP013","True" +"PSQL013","True" +"PALM001","True" +"PGAW001","True" +"PWHD004","True" +"PSPT001","True" +"PNCRAFILE007","True" +"PSUF001","True" +"PEDI111","True" +"PSQL011","True" +"PEZP001","True" +"PNCRANTRX001","True" +"PEDI112","True" +"PDWH001","True" +"PSQL015","True" +"PADF003","True" +"PSQL007","True" +"PFNP005","True" +"PSQL026","True" +"PBIZ126","True" +"PADF002","True" +"PFNP011","True" +"PFNP002","True" +"POWA001","True" +"PSQL030A","True" +"PSQL029A","True" +"PSQL016","True" +"PRSH176","True" +"PRSH056","True" +"PRSH057","True" +"PBIZ124","True" +"PSQL010","True" +"PBIZ111","True" +"PFNP008","True" +"PSSP003","True" +"PRSH152","True" +"PMHB002","True" +"PTABL001","True" +"PCCR001","True" +"PEDI116","True" +"PSNW001","True" +"PSLK001","True" +"PRSH161","True" +"PSKY003","True" +"PBIZ123","True" +"FLT2PTTS011","True" +"PRSH175","True" +"PRSH151","True" +"PSQL030B","True" +"PMHB001","True" +"PVST001","True" +"PIQV001","True" +"PSQL009","True" +"PFNP015","True" +"PSQL025","True" +"PRSH173","True" +"PBIZ122","True" +"PPDQ001","True" +"PVST002","True" +"PRSH053","True" +"PSEC002","True" +"PSQL029B","True" +"PVSS012","True" +"PSQL021","True" +"PFNP012","True" +"PNCRAFILE001","True" +"PSQL028A","True" +"PSRS001","True" +"PNCRAFILE005","True" +"PSIS002","True" +"FLT2PSQL021","True" +"PFNP007","True" +"PVSS011","True" +"PFNP003","True" +"PEDI113","True" +"PADF001","True" +"PQRDS001","True" +"PSQL022","True" +"PRSH050","True" +"PRSH055","True" +"PRSH058","True" +"PRSH162","True" +"PIWC012","True" +"PEDI115","True" +"PJMP001","True" +"PDWH002","True" +"PSRS003","True" +"PSQL006","True" +"PSQL028B","True" +"PIIS005","True" +"PKEY001","True" +"PSHP002","True" +"KSOVEPOPS001","False" +"PSQL001","False" +"PFNP001","False" +"PCPR001","False" +"PBLD001","False" +"PCVV001","False" +"PSQL023","False" +"PSQL023B","False" +"PFNP014","False" diff --git a/dump/Files/All-patching-collections.csv b/dump/Files/All-patching-collections.csv new file mode 100644 index 0000000..93aadbc --- /dev/null +++ b/dump/Files/All-patching-collections.csv @@ -0,0 +1,213 @@ +"Server","ClientInstalled","CollectionName" +"PIAP002","True","_6PM - Production Patching" +"PKEY003","True","_6PM - Production Patching" +"PNCRAVERIDX002","True","_6PM - Production Patching" +"PNCRAVERIDX005","True","_6PM - Production Patching" +"PNCRAVERDA001","True","_6PM - Production Patching" +"PNCRAVERVLT002","True","_6PM - Production Patching" +"PNCRAVERIDX004","True","_6PM - Production Patching" +"PNCRAVERIDX001","True","_6PM - Production Patching" +"PNCRAVERIDX003","True","_6PM - Production Patching" +"PSEV013","True","_6PM - Production Patching" +"PSEV011","True","_6PM - Production Patching" +"NYMEPALT001","True","_6PM - Production Patching" +"AZPHPALT001","True","_6PM - Production Patching" +"PSEV012","True","_6PM - Production Patching" +"PADM001","True","_6PM - Production Patching" +"PSEV014","True","_6PM - Production Patching" +"KSOPPALT001","True","_6PM - Production Patching" +"PUTL005","True","_6PM - Production Patching" +"PSEV010","True","_6PM - Production Patching" +"PIAP001","True","_6PM - Production Patching" +"PKEY002","True","_6PM - Production Patching" +"PNCRAVERVLT003","True","_6PM - Production Patching" +"PSEV024","True","_6PM - Production Patching" +"PSNX001","True","_6PM - Production Patching" +"PSEV022","True","_6PM - Production Patching" +"PNCRAWINAUTO001","True","_6PM - Production Patching" +"PUTL011","True","_6PM - Production Patching" +"PSSP004","True","_6PM - Production Patching" +"PVRS012","True","_6PM - Production Patching" +"PCAC002","True","_6PM - Production Patching" +"PDRF001","True","_6PM - Production Patching" +"PIAM001","True","_6PM - Production Patching" +"PAPCAV001","True","_6PM - Production Patching" +"PSSP002","True","_6PM - Production Patching" +"CTHAPALT001","True","_6PM - Production Patching" +"PSEV015","True","_6PM - Production Patching" +"PUTL006","True","_6PM - Production Patching" +"PDEP001","True","_6PM - Production Patching" +"PCAC001","True","_6PM - Production Patching" +"PSSP001","True","_6PM - Production Patching" +"PAPCAC002","True","_6PM - Production Patching" +"PIAC001","True","_6PM - Production Patching" +"PIWM002","True","_6PM - Production Patching" +"PMON006","True","_6PM - Production Patching" +"PMON002","True","_6PM - Production Patching" +"PAPJNKSSLA201","True","_6PM - Production Patching" +"PVRS011","True","_6PM - Production Patching" +"PAPSEP001","True","_6PM - Production Patching" +"CTHAPDMC001","True","_6PM - Production Patching" +"AZPHPDMC001","True","_6PM - Production Patching" +"PPKI004","True","_6PM - Production Patching" +"PMON007","True","_6PM - Production Patching" +"PAPJNKSSLA202","True","_6PM - Production Patching" +"PUTL012","True","_6PM - Production Patching" +"PICO001","True","_6PM - Production Patching" +"PFNP009","True","_11PM - Production Patching - File Servers" +"PFNP010","True","_11PM - Production Patching - File Servers" +"PNCRAFILE003","True","_11PM - Production Patching - File Servers" +"PFNP006","True","_11PM - Production Patching - File Servers" +"PFNP013","True","_11PM - Production Patching - File Servers" +"PNCRAFILE007","True","_11PM - Production Patching - File Servers" +"PFNP011","True","_11PM - Production Patching - File Servers" +"PFNP002","True","_11PM - Production Patching - File Servers" +"PFNP008","True","_11PM - Production Patching - File Servers" +"PFNP015","True","_11PM - Production Patching - File Servers" +"PFNP016","True","_11PM - Production Patching - File Servers" +"PFNP017","True","_11PM - Production Patching - File Servers" +"PFNP012","True","_11PM - Production Patching - File Servers" +"PFNP018","True","_11PM - Production Patching - File Servers" +"PNCRAFILE001","True","_11PM - Production Patching - File Servers" +"PFNP019","True","_11PM - Production Patching - File Servers" +"PNCRAFILE005","True","_11PM - Production Patching - File Servers" +"PFNP007","True","_11PM - Production Patching - File Servers" +"PFNP014","False","_11PM - Production Patching - File Servers" +"PFAX021","True","_11PM - Production Patching" +"PFAX022","True","_11PM - Production Patching" +"PRSH030","True","_11PM - Production Patching" +"PRDS001","True","_11PM - Production Patching" +"PRSH038","True","_11PM - Production Patching" +"PRSH039","True","_11PM - Production Patching" +"PRSH033","True","_11PM - Production Patching" +"PRSH031","True","_11PM - Production Patching" +"PRSH035","True","_11PM - Production Patching" +"PRSH032","True","_11PM - Production Patching" +"PDFS001","True","_11PM - Production Patching" +"PDFS003","True","_11PM - Production Patching" +"PIAM002","True","_11PM - Production Patching" +"PRDS002","True","_11PM - Production Patching" +"PRSH037","True","_11PM - Production Patching" +"PRSH034","True","_11PM - Production Patching" +"PNCRAMSMQ001","True","_11PM - Production Patching" +"PRSH036","True","_11PM - Production Patching" +"PIWM001","True","_11PM - Production Patching" +"PAPP011","True","_11PM - Production Patching" +"PDFS002","True","_11PM - Production Patching" +"PRSH040","True","_11PM - Production Patching" +"PAPP001","True","_11PM - Production Patching" +"PQRSH001","True","_9PM - Production Patching" +"PRSH027","True","_9PM - Production Patching" +"PRSH019","True","_9PM - Production Patching" +"PRSH011","True","_9PM - Production Patching" +"PRSH020","True","_9PM - Production Patching" +"PRSH021","True","_9PM - Production Patching" +"PAAD001","True","_9PM - Production Patching" +"PRSH023","True","_9PM - Production Patching" +"PRSH010","True","_9PM - Production Patching" +"PRSH024","True","_9PM - Production Patching" +"PRSH008","True","_9PM - Production Patching" +"PRSH001","True","_9PM - Production Patching" +"PRSH006","True","_9PM - Production Patching" +"PRSH000","True","_9PM - Production Patching" +"PRSH009","True","_9PM - Production Patching" +"PRSH005","True","_9PM - Production Patching" +"PRSH003","True","_9PM - Production Patching" +"PRSH004","True","_9PM - Production Patching" +"PRSH002","True","_9PM - Production Patching" +"PRSH007","True","_9PM - Production Patching" +"PRSH022","True","_9PM - Production Patching" +"PRSH012","True","_9PM - Production Patching" +"PRSH016","True","_9PM - Production Patching" +"PRSH015","True","_9PM - Production Patching" +"PRSH018","True","_9PM - Production Patching" +"PRSH017","True","_9PM - Production Patching" +"PRSH013","True","_9PM - Production Patching" +"PRSH028","True","_9PM - Production Patching" +"PRSH052","True","_9PM - Production Patching" +"PRSH025","True","_9PM - Production Patching" +"PRSH029","True","_9PM - Production Patching" +"PRSH026","True","_9PM - Production Patching" +"PSSP001","True","_9PM - Production Patching" +"PRSH172","True","_9PM - Production Patching" +"PDOC001","True","_9PM - Production Patching" +"PEDI114","True","_9PM - Production Patching" +"PRSH054","True","_9PM - Production Patching" +"PRSH051","True","_9PM - Production Patching" +"PWHD003","True","_9PM - Production Patching" +"PRSH174","True","_9PM - Production Patching" +"PBIZ125","True","_9PM - Production Patching" +"PBIZ121","True","_9PM - Production Patching" +"PRSH171","True","_9PM - Production Patching" +"PSUF002","True","_9PM - Production Patching" +"PPCH001","True","_9PM - Production Patching" +"PRSH059","True","_9PM - Production Patching" +"PBIZ112","True","_9PM - Production Patching" +"PPCS001","True","_9PM - Production Patching" +"PSKY001","True","_9PM - Production Patching" +"PSQL022B","True","_9PM - Production Patching" +"PSQL013","True","_9PM - Production Patching" +"PALM001","True","_9PM - Production Patching" +"PGAW001","True","_9PM - Production Patching" +"PWHD004","True","_9PM - Production Patching" +"PSUF001","True","_9PM - Production Patching" +"PEDI111","True","_9PM - Production Patching" +"PEZP001","True","_9PM - Production Patching" +"PNCRANTRX001","True","_9PM - Production Patching" +"PEDI112","True","_9PM - Production Patching" +"PSQL015","True","_9PM - Production Patching" +"PADF003","True","_9PM - Production Patching" +"PSQL026","True","_9PM - Production Patching" +"PBIZ126","True","_9PM - Production Patching" +"PADF002","True","_9PM - Production Patching" +"POWA001","True","_9PM - Production Patching" +"PSQL030A","True","_9PM - Production Patching" +"PSQL029A","True","_9PM - Production Patching" +"PSQL016","True","_9PM - Production Patching" +"PRSH176","True","_9PM - Production Patching" +"PRSH056","True","_9PM - Production Patching" +"PRSH057","True","_9PM - Production Patching" +"PBIZ124","True","_9PM - Production Patching" +"PSQL010","True","_9PM - Production Patching" +"PBIZ111","True","_9PM - Production Patching" +"PSSP003","True","_9PM - Production Patching" +"PRSH152","True","_9PM - Production Patching" +"PMHB002","True","_9PM - Production Patching" +"PTABL001","True","_9PM - Production Patching" +"PCCR001","True","_9PM - Production Patching" +"PEDI116","True","_9PM - Production Patching" +"PSNW001","True","_9PM - Production Patching" +"PSLK001","True","_9PM - Production Patching" +"PRSH161","True","_9PM - Production Patching" +"PSKY003","True","_9PM - Production Patching" +"PBIZ123","True","_9PM - Production Patching" +"PRSH175","True","_9PM - Production Patching" +"PRSH151","True","_9PM - Production Patching" +"PSQL030B","True","_9PM - Production Patching" +"PMHB001","True","_9PM - Production Patching" +"PVST001","True","_9PM - Production Patching" +"PIQV001","True","_9PM - Production Patching" +"PSQL009","True","_9PM - Production Patching" +"PSQL025","True","_9PM - Production Patching" +"PRSH173","True","_9PM - Production Patching" +"PBIZ122","True","_9PM - Production Patching" +"PPDQ001","True","_9PM - Production Patching" +"PVST002","True","_9PM - Production Patching" +"PRSH053","True","_9PM - Production Patching" +"PSQL029B","True","_9PM - Production Patching" +"PVSS012","True","_9PM - Production Patching" +"PSQL021","True","_9PM - Production Patching" +"PSQL028A","True","_9PM - Production Patching" +"PSIS002","True","_9PM - Production Patching" +"FLT2PSQL021","True","_9PM - Production Patching" +"PVSS011","True","_9PM - Production Patching" +"PEDI113","True","_9PM - Production Patching" +"PQRDS001","True","_9PM - Production Patching" +"PSQL022","True","_9PM - Production Patching" +"PRSH050","True","_9PM - Production Patching" +"PRSH055","True","_9PM - Production Patching" +"PRSH058","True","_9PM - Production Patching" +"PRSH162","True","_9PM - Production Patching" +"PEDI115","True","_9PM - Production Patching" +"PJMP001","True","_9PM - Production Patching" +"PSQL028B","True","_9PM - Production Patching" diff --git a/dump/Files/DEV-App-Servers-1-2020.txt b/dump/Files/DEV-App-Servers-1-2020.txt new file mode 100644 index 0000000..e5a8bb0 --- /dev/null +++ b/dump/Files/DEV-App-Servers-1-2020.txt @@ -0,0 +1,32 @@ +DAPP012 +DFNP009 +DVCO001 +DAPP006 +DWHD003 +DFNP001 +DBIT901 +DWAM002 +DCTI001 +DFNP020 +DFNP002 +DAPP011 +DCPR001 +DVB6001 +DWHD001 +DPGP001 +DEDI001 +DDWH001 +DUTL012 +DFNP014 +DIAP001 +DGAW001 +DAPVRNS001 +DAPCAV001 +DAPCAC001 +DAPCAC002 +DFAX011 +DAPSEP001 +DDOC001 +DBTS001 +DWAM001 +DMHB001 \ No newline at end of file diff --git a/dump/Files/DEV-Application-Servers-Collection.txt b/dump/Files/DEV-Application-Servers-Collection.txt new file mode 100644 index 0000000..b7217c0 Binary files /dev/null and b/dump/Files/DEV-Application-Servers-Collection.txt differ diff --git a/dump/Files/DEV-Patching-Application-Servers-Status-1-2020.csv b/dump/Files/DEV-Patching-Application-Servers-Status-1-2020.csv new file mode 100644 index 0000000..da7d612 --- /dev/null +++ b/dump/Files/DEV-Patching-Application-Servers-Status-1-2020.csv @@ -0,0 +1,54 @@ +DeviceName CollectionName StatusTime Status +---------- -------------- ---------- ------ +DAPP012 DEV-Patching-Application-Servers 1/27/2020 3:09:05 PM InProgress +DFNP009 DEV-Patching-Application-Servers 1/24/2020 4:34:27 PM InProgress +DVCO001 DEV-Patching-Application-Servers 1/27/2020 2:58:17 PM InProgress +DAPP006 DEV-Patching-Application-Servers 1/29/2020 8:01:37 PM InProgress +DWHD003 DEV-Patching-Application-Servers 1/24/2020 4:14:43 PM InProgress +DFNP001 DEV-Patching-Application-Servers 1/24/2020 4:32:24 PM InProgress +DBIT901 DEV-Patching-Application-Servers 1/24/2020 4:15:29 PM InProgress +DWAM002 DEV-Patching-Application-Servers 1/27/2020 2:20:13 PM InProgress +DCTI001 DEV-Patching-Application-Servers 1/24/2020 4:13:11 PM InProgress +DFNP020 DEV-Patching-Application-Servers 1/24/2020 4:12:41 PM InProgress +DFNP002 DEV-Patching-Application-Servers 1/24/2020 5:34:08 PM InProgress +DAPP011 DEV-Patching-Application-Servers 3/24/2020 11:03:27 PM InProgress +DCPR001 DEV-Patching-Application-Servers 1/24/2020 5:07:06 PM InProgress +DVB6001 DEV-Patching-Application-Servers 1/27/2020 6:16:47 PM InProgress +DWHD001 DEV-Patching-Application-Servers 1/29/2020 7:43:59 PM Success +DPGP001 DEV-Patching-Application-Servers 1/29/2020 6:41:40 PM Success +DEDI001 DEV-Patching-Application-Servers 1/27/2020 3:23:54 PM Success +DDWH001 DEV-Patching-Application-Servers 1/27/2020 2:59:06 PM Success +DUTL012 DEV-Patching-Application-Servers 2/11/2020 11:25:39 PM Success +DFNP014 DEV-Patching-Application-Servers 1/24/2020 4:51:33 PM Success +DIAP001 DEV-Patching-Application-Servers 1/24/2020 3:45:21 PM Success +DGAW001 DEV-Patching-Application-Servers 1/29/2020 6:45:43 PM Success +DAPVRNS001 DEV-Patching-Application-Servers 3/20/2020 8:53:59 AM Success +DAPCAV001 DEV-Patching-Application-Servers 1/29/2020 5:26:57 PM Success +DAPCAC001 DEV-Patching-Application-Servers 2/6/2020 9:56:05 AM Success +DAPCAC002 DEV-Patching-Application-Servers 1/29/2020 5:46:44 PM Success +DFAX011 DEV-Patching-Application-Servers 1/29/2020 6:02:48 PM Success +DAPSEP001 DEV-Patching-Application-Servers 1/29/2020 5:35:25 PM Success +DDOC001 DEV-Patching-Application-Servers 3/2/2020 9:49:41 AM Success +DBTS001 DEV-Patching-Application-Servers 3/26/2020 11:47:08 AM Success +DWAM001 DEV-Patching-Application-Servers 3/28/2020 12:06:01 AM Unknown +DMHB001 DEV-Patching-Application-Servers 3/28/2020 12:06:01 AM Unknown + + + + + + + + + + + + + + + + + + + + diff --git a/dump/Files/DEV-Patching-Application-Servers.csv b/dump/Files/DEV-Patching-Application-Servers.csv new file mode 100644 index 0000000..5a323cf --- /dev/null +++ b/dump/Files/DEV-Patching-Application-Servers.csv @@ -0,0 +1,33 @@ +"Name","IsClient" +"DFNP014","True" +"DAPSEP001","True" +"DFAX011","True" +"DAPCAC002","True" +"DAPCAC001","True" +"DFNP002","True" +"DAPCAV001","True" +"DAPVRNS001","True" +"DCPR001","True" +"DGAW001","True" +"DWAM002","True" +"DIAP001","True" +"DFNP001","True" +"DWHD003","True" +"DAPP006","True" +"DAPP012","True" +"DDOC001","True" +"DCTI001","True" +"DVB6001","True" +"DFNP009","True" +"DVCO001","True" +"DBIT901","True" +"DFNP020","True" +"DWHD001","True" +"DPGP001","True" +"DEDI001","True" +"DAPP011","True" +"DMHB001","True" +"DDWH001","True" +"DUTL012","True" +"DWAM001","True" +"DBTS001","True" diff --git a/dump/Files/Patches-In-SUG.csv b/dump/Files/Patches-In-SUG.csv new file mode 100644 index 0000000..200feca --- /dev/null +++ b/dump/Files/Patches-In-SUG.csv @@ -0,0 +1,258 @@ +"UpdateGroup","ArticleID","BulletinID","Title" +"Server 2008 Required Updates","2500170","MS11-066","Security Update for Microsoft Chart Controls for Microsoft .NET Framework 3.5 Service Pack 1 (KB2500170)" +"Server 2008 Required Updates","3208481","MS16-144","Security Update for Windows Server 2008 for x64-based Systems (KB3208481)" +"Server 2008 Required Updates","4014652","","Security Update for Windows Server 2008 for x64-based Systems (KB4014652)" +"Server 2008 Required Updates","4014794","","Security Update for Windows Server 2008 for x64-based Systems (KB4014794)" +"Server 2008 Required Updates","4015067","","Security Update for Windows Server 2008 for x64-based Systems (KB4015067)" +"Server 2008 Required Updates","4018927","","Security Update for Windows Server 2008 for x64-based Systems (KB4018927)" +"Server 2008 Required Updates","4034744","","Security Update for Windows Server 2008 for x64-based Systems (KB4034744)" +"Server 2008 Required Updates","3170455","","Security Update for Windows Server 2008 for x64-based Systems (KB3170455)" +"Server 2008 Required Updates","4089229","","2018-03 Security Update for Windows Server 2008 for x64-based Systems (KB4089229)" +"Server 2008 Required Updates","4093227","","2018-06 Security Update for Windows Server 2008 for x64-based Systems (KB4093227)" +"Server 2008 Required Updates","4130956","","2018-06 Security Update for Windows Server 2008 for x64-based Systems (KB4130956)" +"Server 2008 Required Updates","4291391","","2018-07 Security Update for Windows Server 2008 for x64-based Systems (KB4291391)" +"Server 2008 Required Updates","4339503","","2018-07 Security Update for Windows Server 2008 for x64-based Systems (KB4339503)" +"Server 2008 Required Updates","4340007","","2018-07 Security Only Update for .NET Framework 2.0, 3.0, 4.5.2, 4.6 for Windows Server 2008 SP2 for x64 (KB4340007)" +"Server 2008 Required Updates","4338380","","2018-08 Security Update for Windows Server 2008 for x64-based Systems (KB4338380)" +"Server 2008 Required Updates","4340939","","2018-08 Security Update for Windows Server 2008 for x64-based Systems (KB4340939)" +"Server 2008 Required Updates","4341832","","2018-08 Security Update for Windows Server 2008 for x64-based Systems (KB4341832)" +"Server 2008 Required Updates","4345682","","2018-08 Security Only Update for .NET Framework 2.0, 3.0, 4.5.2, 4.6 for Windows Server 2008 SP2 for x64 (KB4345682)" +"Server 2008 Required Updates","4457984","","2018-09 Security Only Quality Update for Windows Server 2008 for x64-based Systems (KB4457984)" +"Server 2008 Required Updates","4463104","","2018-10 Security Only Quality Update for Windows Server 2008 for x64-based Systems (KB4463104)" +"Server 2008 Required Updates","4467700","","2018-11 Security Only Quality Update for Windows Server 2008 for x64-based Systems (KB4467700)" +"Server 2008 Required Updates","4471319","","2018-12 Security Only Quality Update for Windows Server 2008 for x64-based Systems (KB4471319)" +"Server 2008 Required Updates","4471984","","2018-12 Security Only Update for .NET Framework 3.5 SP1, 4.5.2, 4.6 for Windows Server 2008 SP2 for x64 (KB4471984)" +"Server 2008 Required Updates","4480957","","2019-01 Security Only Quality Update for Windows Server 2008 for x64-based Systems (KB4480957)" +"Server 2008 Required Updates","4487124","","2019-02 Security Only Update for .NET Framework 2.0, 3.0, 4.5.2, 4.6 for Windows Server 2008 SP2 for x64 (KB4487124)" +"Server 2008 Required Updates","4487019","","2019-02 Security Only Quality Update for Windows Server 2008 for x64-based Systems (KB4487019)" +"Server 2008 Required Updates","4489876","","2019-03 Security Only Quality Update for Windows Server 2008 for x64-based Systems (KB4489876)" +"Server 2008 Required Updates","4493730","","Security Update for Windows Server 2008 for x64-based Systems (KB4493730)" +"Server 2008 Required Updates","4493458","","2019-04 Security Only Quality Update for Windows Server 2008 for x64-based Systems (KB4493458)" +"Server 2008 Required Updates","4498964","","2019-05 Security Only Update for .NET Framework 2.0, 3.0, 4.5.2, 4.6 on Windows Server 2008 SP2 for x64 (KB4498964)" +"Server 2008 Required Updates","4499180","","2019-05 Security Only Quality Update for Windows Server 2008 for x64-based Systems (KB4499180)" +"Server 2008 Required Updates","4503287","","2019-06 Security Only Quality Update for Windows Server 2008 for x64-based Systems (KB4503287)" +"Server 2008 Required Updates","4507461","","2019-07 Security Only Quality Update for Windows Server 2008 for x64-based Systems (KB4507461)" +"Server 2008 Required Updates","4507414","","2019-07 Security Only Update for .NET Framework 2.0, 3.0, 4.5.2, 4.6 for Windows Server 2008 SP2 for x64 (KB4507414)" +"Server 2008 Required Updates","4512491","","2019-08 Security Only Quality Update for Windows Server 2008 for x64-based Systems (KB4512491)" +"Server 2008 Required Updates","4516051","","2019-09 Security Only Quality Update for Windows Server 2008 for x64-based Systems (KB4516051)" +"Server 2008 Required Updates","4520009","","2019-10 Security Only Quality Update for Windows Server 2008 for x64-based Systems (KB4520009)" +"Server 2008 Required Updates","4474419","","2019-09 Security Update for Windows Server 2008 for x64-based Systems (KB4474419)" +"Server 2008 Required Updates","4525239","","2019-11 Security Only Quality Update for Windows Server 2008 for x64-based Systems (KB4525239)" +"Server 2008 Required Updates","4530719","","2019-12 Security Only Quality Update for Windows Server 2008 for x64-based Systems (KB4530719)" +"Server 2008 Required Updates","4534979","","2020-01 Security Only Update for .NET Framework 2.0, 3.0, 4.5.2, 4.6 for Windows Server 2008 SP2 for x64 (KB4534979)" +"Server 2008 Required Updates","4534312","","2020-01 Security Only Quality Update for Windows Server 2008 for x64-based Systems (KB4534312)" +"Server 2008 Required Updates","960568","","BITS 4.0 for Windows Server 2008 x64 Edition (KB960568)" +"Server 2008 Required Updates","4132941","","Update for Windows Server 2008 x64 Edition (KB4132941)" +"Server 2008 Required Updates","4486459","","2019-02 Update for Windows Server 2008 for x64-based Systems (KB4486459)" +"Server 2008 Required Updates","4490128","","2019-03 Update for Windows Server 2008 for x64-based Systems (KB4490128)" +"Server 2008 Required Updates","4489489","","Update for .NET Framework 2.0, 3.0, 4.5.2, 4.6 for Windows Server 2008 SP2 for x64 (KB4489489)" +"Server 2008 Required Updates","4507704","","2019-07 Update for Windows Server 2008 for x64-based Systems (KB4507704)" +"Server 2008 Required Updates","4501226","","2019-05 Update for Windows Server 2008 for x64-based Systems (KB4501226)" +"Server 2008 Required Updates","4519108","","2019-10 Update for Windows Server 2008 for x64-based Systems (KB4519108)" +"Server 2008 Required Updates","4537822","","2020-02 Security Only Quality Update for Windows Server 2008 for x64-based Systems (KB4537822)" +"Server 2008 Required Updates","4556406","","2020-05 Security Only Update for .NET Framework 2.0, 3.0, 4.5.2, 4.6 for Windows Server 2008 SP2 for x64 (KB4556406)" +"Server 2008 Required Updates","4575904","","2020-07 Extended Security Updates (ESU) Licensing Preparation Package for Windows Server 2008 for x64-based Systems (KB4575904)" +"Server 2008 Required Updates","4570503","","2020-08 Security Only Update for .NET Framework 2.0, 3.0, 4.5.2, 4.6 for Windows Server 2008 SP2 for x64 (KB4570503)" +"Server 2008 Required Updates","4580470","","2020-10 Security Only Update for .NET Framework 2.0, 3.0, 4.5.2, 4.6 for Windows Server 2008 SP2 for x64 (KB4580470)" +"Server 2008 Required Updates","4566469","","2020-10 Security Only Update for .NET Framework 2.0, 3.0, 4.5.2, 4.6 for Windows Server 2008 SP2 for x64 (KB4566469)" +"Server 2008 Required Updates","4586086","","2020-11 Security and Quality Rollup for .NET Framework 2.0, 3.0, 4.5.2, 4.6 for Windows Server 2008 SP2 for x64 (KB4586086)" +"Server 2008 R2 Requred Patches","2894844","","Security Update for Microsoft .NET Framework 3.5.1 on Windows 7 and Windows Server 2008 R2 SP1 for x64-based Systems (KB2894844)" +"Server 2008 R2 Requred Patches","4576490","","2020-09 Security Only Update for .NET Framework 4.8 for Windows Server 2008 R2 for x64 (KB4576490)" +"Server 2008 R2 Requred Patches","2823180","","Update for Windows Server 2008 R2 x64 Edition (KB2823180)" +"Server 2008 R2 Requred Patches","4507411","","2019-07 Security Only Update for .NET Framework 3.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8 for Windows 7 and Server 2008 R2 for x64 (KB4507411)" +"Server 2008 R2 Requred Patches","4580387","","2020-10 Security Only Quality Update for Windows Server 2008 R2 for x64-based Systems (KB4580387)" +"Server 2008 R2 Requred Patches","4556403","","2020-05 Security Only Update for .NET Framework 3.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8 for Windows Server 2008 R2 for x64 (KB4556403)" +"Server 2008 R2 Requred Patches","2972100","MS14-057","Security Update for Microsoft .NET Framework 3.5.1 on Windows 7 and Windows Server 2008 R2 SP1 for x64-based Systems (KB2972100)" +"Server 2008 R2 Requred Patches","4099637","","2018-05 Security Only Update for .NET Framework 3.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1 on Windows 7 and Server 2008 R2 for x64 (KB4099637)" +"Server 2008 R2 Requred Patches","4490628","","2019-03 Servicing Stack Update for Windows Server 2008 R2 for x64-based Systems (KB4490628)" +"Server 2008 R2 Requred Patches","4586083","","2020-11 Security and Quality Rollup for .NET Framework 3.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8 for Windows Server 2008 R2 for x64 (KB4586083)" +"Server 2008 R2 Requred Patches","2992611","MS14-066","Security Update for Windows Server 2008 R2 x64 Edition (KB2992611)" +"Server 2008 R2 Requred Patches","4019108","","May, 2017 Security Only Update for .NET Framework 3.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2 on Windows 7 and Windows Server 2008 R2 for x64 (KB4019108)" +"Server 2008 R2 Requred Patches","4467106","","2018-11 Security Only Quality Update for Windows Server 2008 R2 for x64-based Systems (KB4467106)" +"Server 2008 R2 Requred Patches","4503269","","2019-06 Security Only Quality Update for Windows Server 2008 R2 for x64-based Systems (KB4503269)" +"Server 2008 R2 Requred Patches","2742599","MS13-004","Security Update for Microsoft .NET Framework 3.5.1 on Windows 7 and Windows Server 2008 R2 SP1 for x64-based Systems (KB2742599)" +"Server 2008 R2 Requred Patches","2789645","MS13-015","Security Update for Microsoft .NET Framework 3.5.1 on Windows 7 and Windows Server 2008 R2 SP1 for x64-based Systems (KB2789645)" +"Server 2008 R2 Requred Patches","4099950","","2018-04 Update for Windows Server 2008 R2 for x64-based Systems (KB4099950)" +"Server 2008 R2 Requred Patches","4033342","","Microsoft .NET Framework 4.7.1 for Windows 7 and Windows Server 2008 R2 for x64 (KB4033342)" +"Server 2008 R2 Requred Patches","3072305","MS15-080","Security Update for Microsoft .NET Framework 3.5.1 on Windows 7 SP1 and Windows Server 2008 R2 SP1 for x64 (KB3072305)" +"Server 2008 R2 Requred Patches","4486459","","2019-02 Update for Windows Server 2008 R2 for x64-based Systems (KB4486459)" +"Server 2008 R2 Requred Patches","4541500","","2020-03 Security Only Quality Update for Windows Server 2008 R2 for x64-based Systems (KB4541500)" +"Server 2008 R2 Requred Patches","4340004","","2018-07 Security Only Update for .NET Framework 3.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2 for Windows 7 and Server 2008 R2 for x64 (KB4340004)" +"Server 2008 R2 Requred Patches","3186497","","Microsoft .NET Framework 4.7 for Windows 7 and Windows Server 2008 R2 for x64 (KB3186497)" +"Server 2008 R2 Requred Patches","4580467","","2020-10 Security Only Update for .NET Framework 3.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8 for Windows Server 2008 R2 for x64 (KB4580467)" +"Server 2008 R2 Requred Patches","4501226","","2019-05 Update for Windows Server 2008 R2 for x64-based Systems (KB4501226)" +"Server 2008 R2 Requred Patches","4471328","","2018-12 Security Only Quality Update for Windows Server 2008 R2 for x64-based Systems (KB4471328)" +"Server 2008 R2 Requred Patches","4507456","","2019-07 Security Only Quality Update for Windows Server 2008 R2 for x64-based Systems (KB4507456)" +"Server 2008 R2 Requred Patches","2836942","","Update for Microsoft .NET Framework 3.5.1 on Windows 7 and Windows Server 2008 R2 SP1 for x64-based Systems (KB2836942)" +"Server 2008 R2 Requred Patches","2604115","MS12-035","Security Update for Microsoft .NET Framework 3.5.1 on Windows 7 and Windows Server 2008 R2 SP1 for x64-based Systems (KB2604115)" +"Server 2008 R2 Requred Patches","4343899","","2018-08 Security Only Quality Update for Windows Server 2008 R2 for x64-based Systems (KB4343899)" +"Server 2008 R2 Requred Patches","4525233","","2019-11 Security Only Quality Update for Windows Server 2008 R2 for x64-based Systems (KB4525233)" +"Server 2008 R2 Requred Patches","2931356","MS14-026","Security Update for Microsoft .NET Framework 3.5.1 on Windows 7 and Windows Server 2008 R2 SP1 for x64-based Systems (KB2931356)" +"Server 2008 R2 Requred Patches","4503548","","Microsoft .NET Framework 4.8 for Windows Server 2008 R2 for x64 (KB4503548)" +"Server 2008 R2 Requred Patches","3023215","MS15-048","Security Update for Microsoft .NET Framework 3.5.1 on Windows 7 and Windows Server 2008 R2 SP1 for x64-based Systems (KB3023215)" +"Server 2008 R2 Requred Patches","4462915","","2018-10 Security Only Quality Update for Windows Server 2008 R2 for x64-based Systems (KB4462915)" +"Server 2008 R2 Requred Patches","4493448","","2019-04 Security Only Quality Update for Windows Server 2008 R2 for x64-based Systems (KB4493448)" +"Server 2008 R2 Requred Patches","4489486","","Update for .NET Framework 3.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2 for Windows 7 and Server 2008 R2 for x64 (KB4489486)" +"Server 2008 R2 Requred Patches","2729452","MS12-074","Security Update for Microsoft .NET Framework 3.5.1 on Windows 7 and Windows Server 2008 R2 SP1 for x64-based Systems (KB2729452)" +"Server 2008 R2 Requred Patches","3031432","MS15-015","Security Update for Windows Server 2008 R2 x64 Edition (KB3031432)" +"Server 2008 R2 Requred Patches","4497410","","Microsoft .NET Framework 4.8 Language Packs for Windows 7 and Server 2008 R2 (KB4497410)" +"Server 2008 R2 Requred Patches","2500170","MS11-066","Security Update for Microsoft Chart Controls for Microsoft .NET Framework 3.5 Service Pack 1 (KB2500170)" +"Server 2008 R2 Requred Patches","4499175","","2019-05 Security Only Quality Update for Windows Server 2008 R2 for x64-based Systems (KB4499175)" +"Server 2008 R2 Requred Patches","4592510","","2020-12 Servicing Stack Update for Windows Server 2008 R2 for x64-based Systems (KB4592510)" +"Server 2008 R2 Requred Patches","3102429","","Update for Windows Server 2008 R2 x64 Edition (KB3102429)" +"Server 2008 R2 Requred Patches","4575903","","2020-07 Extended Security Updates (ESU) Licensing Preparation Package for Windows Server 2008 R2 for x64-based Systems (KB4575903)" +"Server 2008 R2 Requred Patches","4561669","","2020-06 Security Only Quality Update for Windows Server 2008 R2 for x64-based Systems (KB4561669)" +"Server 2008 R2 Requred Patches","4487121","","2019-02 Security Only Update for .NET Framework 3.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2 for Windows 7 and Server 2008 R2 for x64 (KB4487121)" +"Server 2008 R2 Requred Patches","4345679","","2018-08 Security Only Update for .NET Framework 3.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2 for Windows 7 and Server 2008 R2 for x64 (KB4345679)" +"Server 2008 R2 Requred Patches","2968294","MS14-057","Security Update for Microsoft .NET Framework 3.5.1 on Windows 7 and Windows Server 2008 R2 SP1 for x64-based Systems (KB2968294)" +"Server 2008 R2 Requred Patches","4471981","","2018-12 Security Only Update for .NET Framework 3.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2 for Windows 7 and Server 2008 R2 for x64 (KB4471981)" +"Server 2008 R2 Requred Patches","3074543","MS15-101","Security Update for Microsoft .NET Framework 3.5.1 on Windows 7 and Windows Server 2008 R2 SP1 for x64-based Systems (KB3074543)" +"Server 2008 R2 Requred Patches","4519108","","2019-10 Update for Windows Server 2008 R2 for x64-based Systems (KB4519108)" +"Server 2008 R2 Requred Patches","2840631","MS13-052","Security Update for Microsoft .NET Framework 3.5.1 on Windows 7 and Windows Server 2008 R2 SP1 for x64-based Systems (KB2840631)" +"Server 2008 R2 Requred Patches","4534314","","2020-01 Security Only Quality Update for Windows Server 2008 R2 for x64-based Systems (KB4534314)" +"Server 2008 R2 Requred Patches","4041090","","2017-09 Security Only Update for .NET Framework 3.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 on Windows 7 and Server 2008 R2 for x64 (KB4041090)" +"Server 2008 R2 Requred Patches","2736422","MS13-007","Security Update for Microsoft .NET Framework 3.5.1 on Windows 7 and Windows Server 2008 R2 SP1 for x64-based Systems (KB2736422)" +"Server 2008 R2 Requred Patches","3097989","MS15-118","Security Update for Microsoft .NET Framework 3.5.1 on Windows 7 and Windows Server 2008 R2 SP1 for x64-based Systems (KB3097989)" +"Server 2008 R2 Requred Patches","2937610","MS14-046","Security Update for Microsoft .NET Framework 3.5.1 on Windows 7 and Windows Server 2008 R2 SP1 for x64-based Systems (KB2937610)" +"Server 2008 R2 Requred Patches","3127220","MS16-019","Security Update for Microsoft .NET Framework 3.5.1 on Windows 7 and Windows Server 2008 R2 SP1 for x64 (KB3127220)" +"Server 2008 R2 Requred Patches","4571719","","2020-08 Security Only Quality Update for Windows Server 2008 R2 for x64-based Systems (KB4571719)" +"Server 2008 R2 Requred Patches","4480960","","2019-01 Security Only Quality Update for Windows Server 2008 R2 for x64-based Systems (KB4480960)" +"Server 2008 R2 Requred Patches","4474419","","2019-09 Security Update for Windows Server 2008 R2 for x64-based Systems (KB4474419)" +"Server 2008 R2 Requred Patches","4557900","","2020-05 Update for Windows Server 2008 R2 for x64-based Systems (KB4557900)" +"Server 2008 R2 Requred Patches","4550965","","2020-04 Security Only Quality Update for Windows Server 2008 R2 for x64-based Systems (KB4550965)" +"Server 2008 R2 Requred Patches","4566371","","2020-09 Update for Windows Server 2008 R2 for x64-based Systems (KB4566371)" +"Server 2008 R2 Requred Patches","3037574","MS15-041","Security Update for Microsoft .NET Framework 3.5.1 on Windows 7 and Windows Server 2008 R2 SP1 for x64-based Systems (KB3037574)" +"Server 2008 R2 Requred Patches","4520003","","2019-10 Security Only Quality Update for Windows Server 2008 R2 for x64-based Systems (KB4520003)" +"Server 2008 R2 Requred Patches","4014985","","April, 2017 Security Only Update for .NET Framework 3.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2 on Windows 7 and Windows Server 2008 R2 for x64 (KB4014985)" +"Server 2008 R2 Requred Patches","2911501","MS14-009","Security Update for Microsoft .NET Framework 3.5.1 on Windows 7 and Windows Server 2008 R2 SP1 for x64-based Systems (KB2911501)" +"Server 2008 R2 Requred Patches","4507704","","2019-07 Update for Windows Server 2008 R2 for x64-based Systems (KB4507704)" +"Server 2008 R2 Requred Patches","4054530","","Microsoft .NET Framework 4.7.2 for Windows Server 2008 R2 for x64 (KB4054530)" +"Server 2008 R2 Requred Patches","4570500","","2020-08 Security Only Update for .NET Framework 3.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8 for Windows Server 2008 R2 for x64 (KB4570500)" +"Server 2008 R2 Requred Patches","4586768","","2020-11 Cumulative Security Update for Internet Explorer 11 for Windows Server 2008 R2 for x64-based systems (KB4586768)" +"Server 2008 R2 Requred Patches","2861698","MS13-082","Security Update for Microsoft .NET Framework 3.5.1 on Windows 7 and Windows Server 2008 R2 SP1 for x64-based Systems (KB2861698)" +"Server 2008 R2 Requred Patches","4578623","","2020-10 Update for Windows Server 2008 R2 for x64-based Systems (KB4578623)" +"Server 2008 R2 Requred Patches","4592471","","2020-12 Security Monthly Quality Rollup for Windows Server 2008 R2 for x64-based Systems (KB4592471)" +"Server 2008 R2 Requred Patches","4586805","","2020-11 Security Only Quality Update for Windows Server 2008 R2 for x64-based Systems (KB4586805)" +"Server 2008 R2 Requred Patches","4338823","","2018-07 Security Only Quality Update for Windows Server 2008 R2 for x64-based Systems (KB4338823)" +"Server 2008 R2 Requred Patches","4566466","","2020-10 Security Only Update for .NET Framework 3.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8 for Windows Server 2008 R2 for x64 (KB4566466)" +"Server 2008 R2 Requred Patches","4537813","","2020-02 Security Only Quality Update for Windows Server 2008 R2 for x64-based Systems (KB4537813)" +"Server 2008 R2 Requred Patches","4490128","","2019-03 Update for Windows Server 2008 R2 for x64-based Systems (KB4490128)" +"Server 2008 R2 Requred Patches","4592503","","2020-12 Security Only Quality Update for Windows Server 2008 R2 for x64-based Systems (KB4592503)" +"Server 2008 R2 Requred Patches","4534976","","2020-01 Security Only Update for .NET Framework 3.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8 for Windows 7 and Server 2008 R2 for x64 (KB4534976)" +"Server 2008 R2 Requred Patches","4577053","","2020-09 Security Only Quality Update for Windows Server 2008 R2 for x64-based Systems (KB4577053)" +"Server 2008 R2 Requred Patches","4530692","","2019-12 Security Only Quality Update for Windows Server 2008 R2 for x64-based Systems (KB4530692)" +"Server 2008 R2 Requred Patches","2943357","MS14-046","Security Update for Microsoft .NET Framework 3.5.1 on Windows 7 and Windows Server 2008 R2 SP1 for x64-based Systems (KB2943357)" +"Server 2008 R2 Requred Patches","4489885","","2019-03 Security Only Quality Update for Windows Server 2008 R2 for x64-based Systems (KB4489885)" +"Server 2008 R2 Requred Patches","2836943","","Update for Microsoft .NET Framework 3.5.1 on Windows 7 and Windows Server 2008 R2 SP1 for x64-based Systems (KB2836943)" +"Server 2008 R2 Requred Patches","4556843","","2020-05 Security Only Quality Update for Windows Server 2008 R2 for x64-based Systems (KB4556843)" +"Server 2008 R2 Requred Patches","4486564","","2019-02 Security Only Quality Update for Windows Server 2008 R2 for x64-based Systems (KB4486564)" +"Server 2008 R2 Requred Patches","4498961","","2019-05 Security Only Update for .NET Framework 3.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8 for Windows 7 and Server 2008 R2 for x64 (KB4498961)" +"Server 2008 R2 Requred Patches","4565539","","2020-07 Security Only Quality Update for Windows Server 2008 R2 for x64-based Systems (KB4565539)" +"Server 2008 R2 Requred Patches","4055269","","2018-01 Security Only Update for .NET Framework 3.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1 on Windows 7 and Server 2008 R2 for x64 (KB4055269)" +"Server 2008 R2 Requred Patches","4457145","","2018-09 Security Only Quality Update for Windows Server 2008 R2 for x64-based Systems (KB4457145)" +"Server 2016 Required Patches","4576750","","2020-09 Servicing Stack Update for Windows Server 2016 for x64-based Systems (KB4576750)" +"Server 2016 Required Patches","4580325","","2020-10 Security Update for Adobe Flash Player for Windows Server 2016 for x64-based Systems (KB4580325)" +"Server 2016 Required Patches","890830","","Windows Malicious Software Removal Tool x64 - v5.84 (KB890830)" +"Server 2016 Required Patches","4593226","","2020-12 Cumulative Update for Windows Server 2016 for x64-based Systems (KB4593226)" +"Server 2019 Required Patches","4566516","","2020-07 Cumulative Update for .NET Framework 3.5, 4.7.2 and 4.8 for Windows Server 2019 for x64 (KB4566516)" +"Server 2019 Required Patches","4570505","","2020-08 Cumulative Update for .NET Framework 3.5, 4.7.2 and 4.8 for Windows Server 2019 for x64 (KB4570505)" +"Server 2019 Required Patches","4580325","","2020-10 Security Update for Adobe Flash Player for Windows Server 2019 for x64-based Systems (KB4580325)" +"Server 2019 Required Patches","890830","","Windows Malicious Software Removal Tool x64 - v5.84 (KB890830)" +"Server 2019 Required Patches","4586082","","2020-11 Cumulative Update for .NET Framework 3.5, 4.7.2 and 4.8 for Windows Server 2019 for x64 (KB4586082)" +"Server 2019 Required Patches","4587735","","2020-11 Servicing Stack Update for Windows Server 2019 for x64-based Systems (KB4587735)" +"Server 2019 Required Patches","4592440","","2020-12 Cumulative Update for Windows Server 2019 for x64-based Systems (KB4592440)" +"Server 2012 R2 Required Patches","2966826","MS14-046","Security Update for Microsoft .NET Framework 3.5 on Windows 8.1 and Windows Server 2012 R2 for x64-based Systems (KB2966826)" +"Server 2012 R2 Required Patches","4468323","","Update for Windows Server 2012 R2 (KB4468323)" +"Server 2012 R2 Required Patches","4099639","","2018-05 Security Only Update for .NET Framework 3.5, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1 on Windows 8.1 and Server 2012 R2 for x64 (KB4099639)" +"Server 2012 R2 Required Patches","4580325","","2020-10 Security Update for Adobe Flash Player for Windows Server 2012 R2 for x64-based Systems (KB4580325)" +"Server 2012 R2 Required Patches","4556853","","2020-05 Security Only Quality Update for Windows Server 2012 R2 for x64-based Systems (KB4556853)" +"Server 2012 R2 Required Patches","3138910","MS16-027","Security Update for Windows Server 2012 R2 (KB3138910)" +"Server 2012 R2 Required Patches","3115224","","Update for Windows Server 2012 R2 (KB3115224)" +"Server 2012 R2 Required Patches","4487028","","2019-02 Security Only Quality Update for Windows Server 2012 R2 for x64-based Systems (KB4487028)" +"Server 2012 R2 Required Patches","4055271","","2018-01 Security Only Update for .NET Framework 3.5, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1 on Windows 8.1 and Server 2012 R2 for x64 (KB4055271)" +"Server 2012 R2 Required Patches","4471983","","2018-12 Security Only Update for .NET Framework 3.5, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2 for Windows 8.1 and Server 2012 R2 for x64 (KB4471983)" +"Server 2012 R2 Required Patches","3020393","MS15-002","Security Update for Windows Server 2012 R2 (KB3020393)" +"Server 2012 R2 Required Patches","4340006","","2018-07 Security Only Update for .NET Framework 3.5, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2 for Windows 8.1 and Server 2012 R2 for x64 (KB4340006)" +"Server 2012 R2 Required Patches","3109560","MS16-007","Security Update for Windows Server 2012 R2 (KB3109560)" +"Server 2012 R2 Required Patches","2972213","MS14-053","Security Update for Microsoft .NET Framework 3.5 on Windows 8.1 and Windows Server 2012 R2 for x64-based Systems (KB2972213)" +"Server 2012 R2 Required Patches","4565540","","2020-07 Security Only Quality Update for Windows Server 2012 R2 for x64-based Systems (KB4565540)" +"Server 2012 R2 Required Patches","890830","","Windows Malicious Software Removal Tool x64 - v5.84 (KB890830)" +"Server 2012 R2 Required Patches","4019111","","May, 2017 Security Only Update for .NET Framework 3.5, 4.5.2, 4.6, 4.6.1, 4.6.2 on Windows 8.1 and Windows Server 2012 R2 for x64 (KB4019111)" +"Server 2012 R2 Required Patches","3015696","","Update for Windows Server 2012 R2 (KB3015696)" +"Server 2012 R2 Required Patches","3115858","MS16-013","Security Update for Windows Server 2012 R2 (KB3115858)" +"Server 2012 R2 Required Patches","3186539","","Microsoft .NET Framework 4.7 for Windows 8.1 and Windows Server 2012 R2 for x64 (KB3186539)" +"Server 2012 R2 Required Patches","4556405","","2020-05 Security Only Update for .NET Framework 3.5, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8 for Windows 8.1 and Server 2012 R2 for x64 (KB4556405)" +"Server 2012 R2 Required Patches","3072307","MS15-080","Security Update for Microsoft .NET Framework 3.5 on Windows 8.1 and Windows Server 2012 R2 for x64-based Systems (KB3072307)" +"Server 2012 R2 Required Patches","4566425","","2020-07 Servicing Stack Update for Windows Server 2012 R2 for x64-based Systems (KB4566425)" +"Server 2012 R2 Required Patches","4530730","","2019-12 Security Only Quality Update for Windows Server 2012 R2 for x64-based Systems (KB4530730)" +"Server 2012 R2 Required Patches","3000483","MS15-011","Security Update for Windows Server 2012 R2 (KB3000483)" +"Server 2012 R2 Required Patches","3037576","MS15-041","Security Update for Microsoft .NET Framework 3.5 on Windows 8.1 and Windows Server 2012 R2 for x64-based Systems (KB3037576)" +"Server 2012 R2 Required Patches","4566371","","2020-09 Update for Windows Server 2012 R2 for x64-based Systems (KB4566371)" +"Server 2012 R2 Required Patches","3023219","MS15-048","Security Update for Microsoft .NET Framework 3.5 on Windows 8.1 and Windows Server 2012 R2 for x64-based Systems (KB3023219)" +"Server 2012 R2 Required Patches","4514599","","2019-09 Security Only Update for .NET Framework 3.5, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8 for Windows 8.1 and Server 2012 R2 for x64 (KB4514599)" +"Server 2012 R2 Required Patches","3013538","","Update for Windows Server 2012 R2 (KB3013538)" +"Server 2012 R2 Required Patches","4507704","","2019-07 Update for Windows Server 2012 R2 for x64-based Systems (KB4507704)" +"Server 2012 R2 Required Patches","4041092","","2017-09 Security Only Update for .NET Framework 3.5, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 on Windows 8.1 and Server 2012 R2 for x64 (KB4041092)" +"Server 2012 R2 Required Patches","2968296","MS14-057","Security Update for Microsoft .NET Framework 3.5 on Windows 8.1 and Windows Server 2012 R2 for x64-based Systems (KB2968296)" +"Server 2012 R2 Required Patches","4550970","","2020-04 Security Only Quality Update for Windows Server 2012 R2 for x64-based Systems (KB4550970)" +"Server 2012 R2 Required Patches","4561673","","2020-06 Security Only Quality Update for Windows Server 2012 R2 for x64-based Systems (KB4561673)" +"Server 2012 R2 Required Patches","4503290","","2019-06 Security Only Quality Update for Windows Server 2012 R2 for x64-based Systems (KB4503290)" +"Server 2012 R2 Required Patches","2894852","","Security Update for Microsoft .NET Framework 3.5 on Windows 8.1 and Windows Server 2012 R2 for x64-based Systems (KB2894852)" +"Server 2012 R2 Required Patches","4557900","","2020-05 Update for Windows Server 2012 R2 for x64-based Systems (KB4557900)" +"Server 2012 R2 Required Patches","4576489","","2020-09 Security Only Update for .NET Framework 4.8 for Windows 8.1 and Server 2012 R2 for x64 (KB4576489)" +"Server 2012 R2 Required Patches","4577071","","2020-09 Security Only Quality Update for Windows Server 2012 R2 for x64-based Systems (KB4577071)" +"Server 2012 R2 Required Patches","4507457","","2019-07 Security Only Quality Update for Windows Server 2012 R2 for x64-based Systems (KB4507457)" +"Server 2012 R2 Required Patches","4501226","","2019-05 Update for Windows Server 2012 R2 for x64-based Systems (KB4501226)" +"Server 2012 R2 Required Patches","4592484","","2020-12 Security Monthly Quality Rollup for Windows Server 2012 R2 for x64-based Systems (KB4592484)" +"Server 2012 R2 Required Patches","2973114","MS14-053","Security Update for Microsoft .NET Framework 3.5 on Windows 8.1 and Windows Server 2012 R2 for x64-based Systems (KB2973114)" +"Server 2012 R2 Required Patches","3134813","","Update for Windows Server 2012 R2 (KB3134813)" +"Server 2012 R2 Required Patches","4499165","","2019-05 Security Only Quality Update for Windows Server 2012 R2 for x64-based Systems (KB4499165)" +"Server 2012 R2 Required Patches","3097992","MS15-118","Security Update for Microsoft .NET Framework 3.5 on Windows 8.1 and Windows Server 2012 R2 for x64-based Systems (KB3097992)" +"Server 2012 R2 Required Patches","4541505","","2020-03 Security Only Quality Update for Windows Server 2012 R2 for x64-based Systems (KB4541505)" +"Server 2012 R2 Required Patches","4462930","","Update for Adobe Flash Player for Windows Server 2012 R2 (KB4462930)" +"Server 2012 R2 Required Patches","4033369","","Microsoft .NET Framework 4.7.1 for Windows 8.1 and Windows Server 2012 R2 for x64 (KB4033369)" +"Server 2012 R2 Required Patches","4493467","","2019-04 Security Only Quality Update for Windows Server 2012 R2 for x64-based Systems (KB4493467)" +"Server 2012 R2 Required Patches","2982998","MS14-076","Security Update for Windows Server 2012 R2 (KB2982998)" +"Server 2012 R2 Required Patches","3074545","MS15-101","Security Update for Microsoft .NET Framework 3.5 on Windows 8.1 and Windows Server 2012 R2 for x64-based Systems (KB3074545)" +"Server 2012 R2 Required Patches","4507413","","2019-07 Security Only Update for .NET Framework 3.5, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8 for Windows 8.1 and Server 2012 R2 for x64 (KB4507413)" +"Server 2012 R2 Required Patches","4586085","","2020-11 Security and Quality Rollup for .NET Framework 3.5, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8 for Windows 8.1 and Server 2012 R2 for x64 (KB4586085)" +"Server 2012 R2 Required Patches","4534978","","2020-01 Security Only Update for .NET Framework 3.5, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8 for Windows 8.1 and Server 2012 R2 for x64 (KB4534978)" +"Server 2012 R2 Required Patches","4586823","","2020-11 Security Only Quality Update for Windows Server 2012 R2 for x64-based Systems (KB4586823)" +"Server 2012 R2 Required Patches","3138962","MS16-027","Security Update for Windows Server 2012 R2 (KB3138962)" +"Server 2012 R2 Required Patches","3127222","MS16-019","Security Update for Microsoft .NET Framework 3.5 on Windows 8.1 and Windows Server 2012 R2 for x64 (KB3127222)" +"Server 2012 R2 Required Patches","4525250","","2019-11 Security Only Quality Update for Windows Server 2012 R2 for x64-based Systems (KB4525250)" +"Server 2012 R2 Required Patches","4586768","","2020-11 Cumulative Security Update for Internet Explorer 11 for Windows Server 2012 R2 for x64-based systems (KB4586768)" +"Server 2012 R2 Required Patches","4487123","","2019-02 Security Only Update for .NET Framework 3.5, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2 for Windows 8.1 and Server 2012 R2 for x64 (KB4487123)" +"Server 2012 R2 Required Patches","3018133","","Update for Windows Server 2012 R2 (KB3018133)" +"Server 2012 R2 Required Patches","4578623","","2020-10 Update for Windows Server 2012 R2 for x64-based Systems (KB4578623)" +"Server 2012 R2 Required Patches","4534309","","2020-01 Security Only Quality Update for Windows Server 2012 R2 for x64-based Systems (KB4534309)" +"Server 2012 R2 Required Patches","4486459","","2019-02 Update for Windows Server 2012 R2 for x64-based Systems (KB4486459)" +"Server 2012 R2 Required Patches","4054566","","Microsoft .NET Framework 4.7.2 for Windows Server 2012 R2 for x64 (KB4054566)" +"Server 2012 R2 Required Patches","4592495","","2020-12 Security Only Quality Update for Windows Server 2012 R2 for x64-based Systems (KB4592495)" +"Server 2012 R2 Required Patches","4512489","","2019-08 Security Only Quality Update for Windows Server 2012 R2 for x64-based Systems (KB4512489)" +"Server 2012 R2 Required Patches","4498963","","2019-05 Security Only Update for .NET Framework 3.5, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8 for Windows 8.1 and Server 2012 R2 for x64 (KB4498963)" +"Server 2012 R2 Required Patches","4467703","","2018-11 Security Only Quality Update for Windows Server 2012 R2 for x64-based Systems (KB4467703)" +"Server 2012 R2 Required Patches","4519108","","2019-10 Update for Windows Server 2012 R2 for x64-based Systems (KB4519108)" +"Server 2012 R2 Required Patches","4490128","","2019-03 Update for Windows Server 2012 R2 for x64-based Systems (KB4490128)" +"Server 2012 R2 Required Patches","4345681","","2018-08 Security Only Update for .NET Framework 3.5, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2 for Windows 8.1 and Server 2012 R2 for x64 (KB4345681)" +"Server 2012 R2 Required Patches","4570502","","2020-08 Security Only Update for .NET Framework 3.5, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8 for Windows 8.1 and Server 2012 R2 for x64 (KB4570502)" +"Server 2012 R2 Required Patches","4516064","","2019-09 Security Only Quality Update for Windows Server 2012 R2 for x64-based Systems (KB4516064)" +"Server 2012 R2 Required Patches","4566468","","2020-10 Security Only Update for .NET Framework 3.5, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8 for Windows 8.1 and Server 2012 R2 for x64 (KB4566468)" +"Server 2012 R2 Required Patches","3138378","","Update for Windows Server 2012 R2 (KB3138378)" +"Server 2012 R2 Required Patches","4462901","","Update for Windows Server 2012 R2 (KB4462901)" +"Server 2012 R2 Required Patches","2966828","MS14-046","Security Update for Microsoft .NET Framework 3.5 on Windows 8.1 and Windows Server 2012 R2 for x64-based Systems (KB2966828)" +"Server 2012 R2 Required Patches","4486105","","Microsoft .NET Framework 4.8 for Windows Server 2012 R2 for x64 (KB4486105)" +"Server 2012 R2 Required Patches","3134179","","Update for Windows Server 2012 R2 (KB3134179)" +"Server 2012 R2 Required Patches","4339284","","Update for Windows Server 2012 R2 (KB4339284)" +"Server 2012 R2 Required Patches","4537803","","2020-02 Security Only Quality Update for Windows Server 2012 R2 for x64-based Systems (KB4537803)" +"Server 2012 R2 Required Patches","4489883","","2019-03 Security Only Quality Update for Windows Server 2012 R2 for x64-based Systems (KB4489883)" +"Server 2012 R2 Required Patches","4014987","","April, 2017 Security Only Update for .NET Framework 3.5, 4.5.2, 4.6, 4.6.1, 4.6.2 on Windows 8.1 and Windows Server 2012 R2 for x64 (KB4014987)" +"Server 2012 R2 Required Patches","4519990","","2019-10 Security Only Quality Update for Windows Server 2012 R2 for x64-based Systems (KB4519990)" +"Server 2012 R2 Required Patches","3005628","","Update for Microsoft .NET Framework 3.5 for x64-based Systems (KB3005628)" +"Server 2012 R2 Required Patches","3076949","MS15-089","Security Update for Windows Server 2012 R2 (KB3076949)" +"Server 2012 R2 Required Patches","4580358","","2020-10 Security Only Quality Update for Windows Server 2012 R2 for x64-based Systems (KB4580358)" +"Server 2012 R2 Required Patches","4489488","","2019-03 Update for .NET Framework 3.5, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2 for Windows 8.1 and Server 2012 R2 for x64 (KB4489488)" +"Server 2012 R2 Required Patches","3012235","","Update for Windows Server 2012 R2 (KB3012235)" +"Server 2012 R2 Required Patches","4580469","","2020-10 Security Only Update for .NET Framework 3.5, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8 for Windows 8.1 and Server 2012 R2 for x64 (KB4580469)" +"Server 2012 R2 Required Patches","2972103","MS14-057","Security Update for Microsoft .NET Framework 3.5 on Windows 8.1 and Windows Server 2012 R2 for x64-based Systems (KB2972103)" +"Server 2012 R2 Required Patches","3013531","","Update for Windows Server 2012 R2 (KB3013531)" diff --git a/dump/Files/Production-Patching-minus-DO-NOT-PATCH.csv b/dump/Files/Production-Patching-minus-DO-NOT-PATCH.csv new file mode 100644 index 0000000..9bab88a --- /dev/null +++ b/dump/Files/Production-Patching-minus-DO-NOT-PATCH.csv @@ -0,0 +1,637 @@ +server +W2012A +W2012B +Q1NCRAFILE001 +DFNP014 +DAPCAC002 +DAPCAV001 +DAPVRNS001 +DGAW001 +DWAM002 +DIAP001 +DWHD003 +DCTI001 +DVB6001 +DFNP009 +DVCO001 +DBIT901 +DFNP020 +DAPP011 +DMHB001 +QRSH023 +QRSH022 +QRSH021 +DCAM011 +DCIC011 +DCIC012 +DSPUPG2010 +DOSM012 +DOSM011 +DMDA011 +DICW011 +DTABL001 +DSIS002 +DOWA001 +DBIZ111 +DBIZ112 +DBIZ113 +DUTL012 +DWAM001 +DSRS004 +DSSS001 +DSQL009 +DSQL021 +DSIS004 +QRSH002 +QRSH041 +QRSH051 +QRSH001 +QRSH031 +QAPP041 +DEDI111 +DEDI112 +DEDI113 +QRSH111 +DSQL027A +DSQL027B +DSRS005 +DSQL000 +DSQL030 +DSQL004 +DSQL029 +DSIS005 +DSQL031 +DSIS003 +DNCRASSIS001 +DSQL028 +DSQL021Q +DSQL024 +DNCRASPWFE01 +DNCRASPAS01 +QAPP031 +QNCRASPAPP01 +QNCRASPDC01 +QNCRASPAPP02 +QNCRASPWFE01 +QNCRASPWFE02 +QNCRASPDC02 +QNCRASPSEA01 +QNCRASPSEA02 +QRDS002 +QMHB003 +QMHB004 +QRDS001 +QAPP051 +QMHB001 +QMFT001 +QBIZ151 +QBIZ152 +Q1SQL024 +QAPP011 +QNCRASPOOS01 +DNCRASPOOS01 +QRSH101 +QSCH012 +QDRF001 +QFNP008 +Q2NCRAFILE001 +Q3NCRAFILE001 +QMHB002 +QSRS004 +QFNP007 +QSQL029 +QSQL030 +Q5NCRAFILE001 +QADF001 +QTABL001 +Q4NCRAFILE001 +QFNP009 +QSCH011 +QSQL028 +QAPP021 +QSCH014 +QFNP001 +QSCH013 +PQRSH001 +QVST012 +QVST011 +QSIS003 +PNCRAVPRXY001 +PIAP002 +PKEY003 +PMON005 +PNCRAVERIDX002 +PNCRAVERIDX005 +PNCRAVERDA001 +PNCRAVERVLT002 +PNCRAVERVLT001 +PNCRAVERIDX004 +PNCRAVERIDX001 +PNCRAVERIDX003 +PSEV013 +PSEV011 +PALT001 +NYMEPALT001 +AZPHPALT001 +PSEV012 +PADM001 +PSEV014 +KSOPPALT001 +PRSH027 +PRSH019 +PRSH011 +PUTL005 +PSEV010 +PICW011 +PVEO002 +PIAP001 +PKEY002 +PNCRAVERVLT003 +PSEV024 +PSNX001 +PSEV022 +PNCRAWINAUTO001 +PUTL011 +PSSP004 +PVRS012 +PCAC002 +PDRF001 +PRSH020 +PRSH021 +PAAD001 +PIAM001 +PAPCAV001 +PRSH023 +PSSP002 +PMON010 +PRSH010 +PRSH024 +PRSH008 +PRSH001 +PRSH006 +PRSH000 +PRSH009 +PRSH005 +PRSH003 +PRSH004 +PRSH002 +PRSH007 +PRSH022 +PRSH014 +PRSH012 +PRSH016 +PRSH015 +PRSH018 +PRSH017 +PRSH013 +PFAX021 +PVEO001 +PNCRAVPRXY002 +PFAX022 +CTHAPALT001 +PSEV015 +PUTL006 +PVET001 +PDEP001 +PRSH028 +PCAC001 +PRSH052 +PRSH030 +PRSH025 +PRSH029 +PMON009 +PRSH026 +PSSP001 +PAPCAC002 +PIAC001 +PNCRANTRX002 +PRSH172 +PIWM002 +PFNP009 +PDOC001 +PEDI114 +PRSH054 +PRSH051 +PWHD003 +PRSH174 +PBIZ125 +PBIZ121 +PFNP010 +PRSH171 +PNCRAFILE003 +PSUF002 +PPCH001 +PRSH059 +PBIZ112 +PSSS001 +PPCS001 +PSKY001 +PSQL022B +PTTS011 +PFNP006 +PFNP013 +PSQL013 +PALM001 +PGAW001 +PWHD004 +PNCRAFILE007 +PSUF001 +PEDI111 +PEZP001 +PNCRANTRX001 +PMON006 +PEDI112 +PVER001 +PSQL015 +PADF003 +PVEB001 +PSQL026 +PBIZ126 +PADF002 +PFNP011 +PFNP002 +POWA001 +PSQL030A +PSQL029A +PSQL016 +PRDS001 +PRSH176 +PRSH056 +PRSH057 +PBIZ124 +PSQL010 +PMON011 +PBIZ111 +PMON002 +PFNP008 +PSSP003 +PRSH152 +PMHB002 +PAPJNKSSLA201 +PTABL001 +PCCR001 +PEDI116 +PDMC005 +PSNW001 +PSLK001 +PDMC003 +PRSH161 +PSKY003 +PDMC002 +PDMC001 +PDMC004 +PVRS011 +PAPSEP001 +CTHAPDMC001 +PDMC006 +CTSTPDMC001 +PBIZ123 +FLT2PTTS011 +FLT2PDMC001 +AZPHPDMC001 +FLT2PDMC002 +KSOPPDMC001 +NYMEPDMC001 +PRSH175 +PRSH151 +PSQL030B +PMHB001 +PVST001 +PIQV001 +PSQL009 +PFNP015 +PSQL025 +PRSH173 +PBIZ122 +PPDQ001 +PVST002 +PRSH053 +PSQL029B +PRSH038 +PRSH039 +PRSH033 +PRSH031 +PRSH035 +PRSH032 +PVSS012 +PDFS001 +PDFS003 +PIAM002 +PSQL021 +PRDS002 +PRSH037 +PRSH034 +PFNP016 +PVAV001 +PFNP017 +PFNP012 +PNCRAMSMQ001 +PRSH036 +PFNP018 +PNCRAFILE001 +PIWM001 +PAPP011 +PDFS002 +PSQL028A +PRSH040 +PVAV002 +PVAV003 +PFNP019 +PNCRAFILE005 +PSIS002 +FLT2PSQL021 +PAPP001 +PFNP007 +PNCRARCM001 +AZPHPRCS011 +CTHAPRCS011 +CTHAPALT002 +CTSTPALT001 +PPKI004 +PMON007 +PVSS011 +PFNP003 +PEDI113 +DPOCSP001 +PVVC012 +PVVC014 +PVVC013 +QRSH113 +Q5SQL022 +QUTL012 +Q4SQL024 +QFNP003 +QBIZ121 +QBIZ132 +QEDI153 +PQRDS001 +QEDI113 +QRSH112 +QBIZ131 +QSIS002 +QBIZ122 +QVST021 +QEDI152 +QEDI111 +QVST022 +QEDI151 +QEDI112 +Q1SQL022 +PAPJNKSSLA202 +PUTL012 +PVVC015 +PVVC016 +QBIZ112 +QBIZ111 +Q2SQL022 +Q3SQL022 +Q4SQL022B +Q4SQL022 +POSM014 +PSQL022 +PCIC011 +PIMQ011 +PRSH050 +PMDA011 +PISR011 +PSRS004 +PMDA014 +PSQL014 +PRSH055 +PMDA012 +PMDA013 +PRSH058 +PRSH162 +FLT2PCIC011 +PBIT901 +PIWC012 +FLT2POSM012 +POSM012 +PIWC011 +FLT2POSM013 +PVVC011 +PRSH101 +QBIZ142 +FLT2PMDA011 +FLT2POSM011 +FLT2PMDA012 +FLT2POSM014 +FLT2PICW011 +FLT2PMDA013 +FLT2PMDA014 +PRCS012 +POSM011 +POSM013 +DIWC011 +PRCS011 +PSQL024 +PDISKTEST1 +PMDA016 +FLT2PCAC001 +PMDA015 +PMDA017 +FLT2PALT001 +POSM016 +FLT2PCAC002 +POSM015 +PSQL012 +FLT2PRCS011 +FLT2PMDA017 +FLT2PMDA015 +FLT2PMDA016 +KSOPPRCS011 +PEDI115 +PRSH102 +DVST001 +QBIZ141 +PIPM001 +DRCS011 +QSNX001 +PJMP001 +PAPCAC001 +DNCRAAUTO006 +PSQL027 +PSUS001 +PNCRAVERRRPT001 +PSIS003 +PSQL028Q +PSQL028B +PSQL030Q +QNCRASCCM001 +QQATEST01 +PVAPV002 +PSEC003 +PVAPV003 +PVAPV001 +PSQL029Q +PVVCO005 +PVVCO006 +PVVCO002 +PICO001 +PVVCO003 +PNCRALSWMON001 +PVVCO004 +PNCRANTRX004 +PNCRAVERVLT004 +FLT2VEB002 +FLT2VEB003 +S16NCRASRV00001 +PNCRAVONE01 +DSPUPG2013 +DAPP012 +DDOC001 +DAPCAC001 +DFNP001 +DFAX011 +DAPP006 +DFNP002 +DAPSEP001 +PNCRASCCMWKDP03 +PNCRASCCMWSP2 +PNCRASCCMWKDP02 +PNCRASCCMWSP3 +PNCRASMTP02 +PNCRASMTP01 +PNCRAADMIN01 +PVVCO001 +PFNP005 +PFNP001 +PNCRACS01 +QNCRACS01 +DNCRACS01 +PNCRAMEP01 +DNCRAMEP01 +PNCRAEXMBX005 +DNCRAFILETEST01 +PPKI003 +PSQL008 +PAPP002 +QAPP005 +PSEV005 +PSEV002 +PVEP001 +PRSH181 +PRSH150 +PVCO001 +PRSH182 +QAPP002 +DFNP011 +DHIL001 +QAPP010 +PSEV021 +PRSH049 +PRSH060 +PDRDS001 +PSQL023 +PSQL023B +PSEV017 +PFNP014 +DAPP001-2012R2 +PSEV023 +DOIT001 +PVRT006 +PVRT003 +PVRT004 +PVRT001 +PVRT005 +PVRT002 +PFAX014 +PFAX013 +PFAX012 +PFAX011 +PVRT007 +FLT2PVRT007 +DVVC002 +DVVC001 +CTHAPVRT007 +AZPHPVRT007 +KSOPPVRT007 +PSQL026B +PSQLCL26 +PRMS002 +PRMS001 +PVER005 +Q2FNP003 +Q5FNP003 +Q1FNP003 +Q4FNP003 +Q3FNP003 +QDNS001 +PMQS001 +QCMX001 +psql029cl +psql028cl +PNTX001 +PCMX001 +DMQS001 +FLT2VEB001 +psql030cl +DRSQL003 +DRSQL002 +DRRDS001 +DRTEST001 +DRRDS002 +dsql02130cl +DMS3001 +PNCRASPOWA01 +I3-PROD-LIS +PNCRASMI01 +DNCRAAUTO004 +DNCRAAUTO003 +DSPC001 +DFAX001 +DWHD004 +GOLD-S16-INSTAN +DVRS001 +DFAX002 +DVVC003 +FLT2PDEP001 +DVVC004 +DSTMN001 +DNCRATESTVM2 +PADS001 +NPTEST1 +PSCH014-TEST +PVEP602 +PWAP002-0 +PSQL000 +PSEV006 +PVEP601 +PFAX011CAP +PSCH011-TEST +PVEP604 +PMFT001 +PFAX015 +PDOMS001 +PVEP603 +PWAP001-0 +TESTVM6 +TEST +QBIZ100 +PNCRAMEDI001 +TEMPDC004 +TEMPDC006 +TEMPNETWRIX +DSTEA001 +DSACS001 +DSBAMCS001 +PNCRAWFM01 +DSNX001 +CLVA1PFNP005 +CLVA1PFNP003 +CLVA1PFNP006 +CLVA1PEXM001 +CLVA1PFNP007 +CLVA1PFNP001 +CLVA1PFNP002 +CLVA1PDMC001 +DSPUPG2016 +DRSQL028 +PNCRAFILE004 +QNCRAMEP01 +PNCRAPROSPD01 +PNFP012A +PNFP011A +PFNP003A +PFNP001A +PEXM004 diff --git a/dump/Files/Servers-Not-In-Patching-Group-UPDATED.csv b/dump/Files/Servers-Not-In-Patching-Group-UPDATED.csv new file mode 100644 index 0000000..6420add --- /dev/null +++ b/dump/Files/Servers-Not-In-Patching-Group-UPDATED.csv @@ -0,0 +1,301 @@ +"PSComputerName","caption" +"W2012A","Microsoft Windows Server 2012 R2 Standard" +"W2012B","Microsoft Windows Server 2012 R2 Standard" +"Q1NCRAFILE001","Microsoft Windows Server 2019 Standard" +"DFNP014","Microsoft Windows Server 2016 Standard" +"DAPCAC002","Microsoft Windows Server 2016 Standard" +"DAPCAV001","Microsoft Windows Server 2016 Standard" +"DAPVRNS001","Microsoft Windows Server 2012 R2 Standard" +"DGAW001","Microsoft Windows Server 2016 Standard" +"DWAM002","Microsoft Windows Server 2012 R2 Standard" +"DIAP001","Microsoft Windows Server 2012 R2 Standard" +"DWHD003","Microsoft Windows Server 2012 R2 Standard" +"DCTI001","Microsoft Windows Server 2012 R2 Standard" +"DVB6001","Microsoft Windows Server 2012 R2 Standard" +"DFNP009","Microsoft Windows Server 2012 R2 Standard" +"DBIT901","Microsoft Windows Server 2012 R2 Standard" +"DFNP020","Microsoft Windows Server 2012 R2 Standard" +"DAPP011","Microsoft Windows Server 2012 R2 Standard" +"DMHB001","Microsoft Windows Server 2012 R2 Standard" +"QRSH023","Microsoft Windows Server 2012 R2 Standard" +"QRSH022","Microsoft Windows Server 2012 R2 Standard" +"QRSH021","Microsoft Windows Server 2012 R2 Standard" +"DCAM011","Microsoft Windows Server 2012 R2 Standard" +"DCIC011","Microsoft Windows Server 2012 R2 Standard" +"DCIC012","Microsoft Windows Server 2012 R2 Standard" +"DSPUPG2010","Microsoft Windows Server 2012 R2 Standard" +"DOSM012","Microsoft Windows Server 2012 R2 Standard" +"DOSM011","Microsoft Windows Server 2012 R2 Standard" +"DMDA011","Microsoft Windows Server 2012 R2 Standard" +"DICW011","Microsoft Windows Server 2012 R2 Standard" +"DTABL001","Microsoft Windows Server 2012 R2 Standard" +"DSIS002","Microsoft Windows Server 2012 R2 Standard" +"DOWA001","Microsoft Windows Server 2012 R2 Standard" +"DBIZ111","Microsoft Windows Server 2012 R2 Standard" +"DBIZ112","Microsoft Windows Server 2012 R2 Standard" +"DBIZ113","Microsoft Windows Server 2012 R2 Standard" +"DUTL012","Microsoft Windows Server 2016 Standard" +"DWAM001","Microsoft Windows Server 2012 R2 Standard" +"DSRS004","Microsoft Windows Server 2012 R2 Standard" +"DSSS001","Microsoft Windows Server 2012 R2 Standard" +"DSQL009","Microsoft Windows Server 2012 R2 Standard" +"DSQL021","Microsoft Windows Server 2012 R2 Standard" +"DSIS004","Microsoft Windows Server 2016 Standard" +"QRSH002","Microsoft Windows Server 2012 R2 Standard" +"QRSH041","Microsoft Windows Server 2012 R2 Standard" +"QRSH051","Microsoft Windows Server 2012 R2 Standard" +"QRSH001","Microsoft Windows Server 2012 R2 Standard" +"QRSH031","Microsoft Windows Server 2012 R2 Standard" +"QAPP041","Microsoft Windows Server 2012 R2 Standard" +"DEDI111","Microsoft Windows Server 2012 R2 Standard" +"DEDI112","Microsoft Windows Server 2012 R2 Standard" +"DEDI113","Microsoft Windows Server 2012 R2 Standard" +"QRSH111","Microsoft Windows Server 2012 R2 Standard" +"DSQL027A","Microsoft Windows Server 2016 Standard" +"DSQL027B","Microsoft Windows Server 2016 Standard" +"DSRS005","Microsoft Windows Server 2016 Standard" +"DSQL000","Microsoft Windows Server 2016 Standard" +"DSQL030","Microsoft Windows Server 2016 Standard" +"DSQL004","Microsoft Windows Server 2016 Standard" +"DSQL029","Microsoft Windows Server 2016 Standard" +"DSIS005","Microsoft Windows Server 2016 Standard" +"DSQL031","Microsoft Windows Server 2016 Standard" +"DSIS003","Microsoft Windows Server 2016 Standard" +"DNCRASSIS001","Microsoft Windows Server 2019 Standard" +"DSQL028","Microsoft Windows Server 2016 Standard" +"DSQL021Q","Microsoft Windows Server 2019 Standard" +"DSQL024","Microsoft Windows Server 2012 R2 Standard" +"DNCRASPWFE01","Microsoft Windows Server 2019 Standard" +"DNCRASPAS01","Microsoft Windows Server 2019 Standard" +"QAPP031","Microsoft Windows Server 2012 R2 Standard" +"QNCRASPAPP01","Microsoft Windows Server 2019 Standard" +"QNCRASPDC01","Microsoft Windows Server 2019 Standard" +"QNCRASPAPP02","Microsoft Windows Server 2019 Standard" +"QNCRASPWFE01","Microsoft Windows Server 2019 Standard" +"QNCRASPWFE02","Microsoft Windows Server 2019 Standard" +"QNCRASPDC02","Microsoft Windows Server 2019 Standard" +"QNCRASPSEA01","Microsoft Windows Server 2019 Standard" +"QNCRASPSEA02","Microsoft Windows Server 2019 Standard" +"QRDS002","Microsoft Windows Server 2012 R2 Standard" +"QMHB003","Microsoft Windows Server 2012 R2 Standard" +"QMHB004","Microsoft Windows Server 2012 R2 Standard" +"QRDS001","Microsoft Windows Server 2012 R2 Standard" +"QAPP051","Microsoft Windows Server 2012 R2 Standard" +"QMHB001","Microsoft Windows Server 2012 R2 Standard" +"QMFT001","Microsoft Windows Server 2012 R2 Standard" +"QBIZ151","Microsoft Windows Server 2012 R2 Standard" +"QBIZ152","Microsoft Windows Server 2012 R2 Standard" +"Q1SQL024","Microsoft Windows Server 2012 R2 Standard" +"QAPP011","Microsoft Windows Server 2012 R2 Standard" +"QNCRASPOOS01","Microsoft Windows Server 2016 Standard" +"DNCRASPOOS01","Microsoft Windows Server 2016 Standard" +"QRSH101","Microsoft Windows Server 2012 R2 Standard" +"QSCH012","Microsoft Windows Server 2012 R2 Standard" +"QDRF001","Microsoft Windows Server 2012 R2 Standard" +"QFNP008","Microsoft Windows Server 2012 R2 Standard" +"Q2NCRAFILE001","Microsoft Windows Server 2019 Standard" +"Q3NCRAFILE001","Microsoft Windows Server 2019 Standard" +"QMHB002","Microsoft Windows Server 2012 R2 Standard" +"QSRS004","Microsoft Windows Server 2012 R2 Standard" +"QFNP007","Microsoft Windows Server 2012 R2 Standard" +"QSQL029","Microsoft Windows Server 2016 Standard" +"QSQL030","Microsoft Windows Server 2016 Standard" +"Q5NCRAFILE001","Microsoft Windows Server 2019 Standard" +"QADF001","Microsoft Windows Server 2016 Standard" +"QTABL001","Microsoft Windows Server 2012 R2 Standard" +"Q4NCRAFILE001","Microsoft Windows Server 2019 Standard" +"QFNP009","Microsoft Windows Server 2012 R2 Standard" +"QSCH011","Microsoft Windows Server 2012 R2 Standard" +"QSQL028","Microsoft Windows Server 2016 Standard" +"QAPP021","Microsoft Windows Server 2012 R2 Standard" +"QSCH014","Microsoft Windows Server 2012 R2 Standard" +"QFNP001","Microsoft Windows Server 2012 R2 Standard" +"QSCH013","Microsoft Windows Server 2012 R2 Standard" +"QVST012","Microsoft Windows Server 2012 R2 Standard" +"QVST011","Microsoft Windows Server 2012 R2 Standard" +"QSIS003","Microsoft Windows Server 2016 Standard" +"PNCRAVPRXY001","Microsoft Windows Server 2019 Standard" +"PMON005","Microsoft Windows Server 2016 Standard" +"PNCRAVERVLT001","Microsoft Windows Server 2016 Standard" +"PICW011","Microsoft Windows Server 2012 R2 Standard" +"PMON010","Microsoft Windows Server 2016 Standard" +"PNCRAVPRXY002","Microsoft Windows Server 2019 Standard" +"PVET001","Microsoft Windows Server 2016 Standard" +"PMON009","Microsoft Windows Server 2016 Standard" +"PNCRANTRX002","Microsoft Windows Server 2016 Standard" +"PSSS001","Microsoft Windows Server 2012 R2 Standard" +"PTTS011","Microsoft Windows Server 2012 R2 Standard" +"PVER001","Microsoft Windows Server 2019 Standard" +"PVEB001","Microsoft Windows Server 2012 R2 Standard" +"PMON011","Microsoft Windows Server 2016 Standard" +"PDMC005","Microsoft Windows Server 2019 Standard" +"PDMC003","Microsoft Windows Server 2012 R2 Standard" +"PDMC003","Microsoft Windows Server 2012 R2 Standard" +"PDMC004","Microsoft Windows Server 2012 R2 Standard" +"PDMC006","Microsoft Windows Server 2012 R2 Standard" +"CTSTPDMC001","Microsoft Windows Server 2012 R2 Standard" +"FLT2PTTS011","Microsoft Windows Server 2012 R2 Standard" +"FLT2PDMC001","Microsoft Windows Server 2012 R2 Standard" +"FLT2PDMC002","Microsoft Windows Server 2012 R2 Standard" +"KSOPPDMC001","Microsoft Windows Server 2012 R2 Standard" +"NYMEPDMC001","Microsoft Windows Server 2012 R2 Standard" +"PVAV001","Microsoft Windows Server 2012 R2 Standard" +"PVAV002","Microsoft Windows Server 2016 Standard" +"PVAV003","Microsoft Windows Server 2016 Standard" +"AZPHPRCS011","Microsoft Windows Server 2012 R2 Standard" +"CTHAPRCS011","Microsoft Windows Server 2012 R2 Standard" +"CTHAPALT002","Microsoft Windows Server 2012 R2 Standard" +"CTSTPALT001","Microsoft Windows Server 2012 R2 Standard" +"PFNP003","Microsoft? Windows Server? 2008 Enterprise " +"DPOCSP001","Microsoft Windows Server 2019 Standard" +"PVVC012","Microsoft Windows Server 2012 R2 Standard" +"PVVC014","Microsoft Windows Server 2012 R2 Standard" +"PVVC013","Microsoft Windows Server 2012 R2 Standard" +"QRSH113","Microsoft Windows Server 2012 R2 Standard" +"Q5SQL022","Microsoft Windows Server 2012 R2 Standard" +"QUTL012","Microsoft Windows Server 2016 Standard" +"Q4SQL024","Microsoft Windows Server 2012 R2 Standard" +"QFNP003","Microsoft Windows Server 2012 R2 Standard" +"QBIZ121","Microsoft Windows Server 2012 R2 Standard" +"QBIZ132","Microsoft Windows Server 2012 R2 Standard" +"QEDI153","Microsoft Windows Server 2012 R2 Standard" +"QEDI113","Microsoft Windows Server 2012 R2 Standard" +"QRSH112","Microsoft Windows Server 2012 R2 Standard" +"QBIZ131","Microsoft Windows Server 2012 R2 Standard" +"QSIS002","Microsoft Windows Server 2012 R2 Standard" +"QBIZ122","Microsoft Windows Server 2012 R2 Standard" +"QVST021","Microsoft Windows Server 2012 R2 Standard" +"QEDI152","Microsoft Windows Server 2012 R2 Standard" +"QEDI111","Microsoft Windows Server 2012 R2 Standard" +"QVST022","Microsoft Windows Server 2012 R2 Standard" +"QEDI151","Microsoft Windows Server 2012 R2 Standard" +"QEDI112","Microsoft Windows Server 2012 R2 Standard" +"Q1SQL022","Microsoft Windows Server 2012 R2 Standard" +"PVVC015","Microsoft Windows Server 2012 R2 Standard" +"PVVC016","Microsoft Windows Server 2012 R2 Standard" +"QBIZ112","Microsoft Windows Server 2012 R2 Standard" +"QBIZ111","Microsoft Windows Server 2012 R2 Standard" +"Q2SQL022","Microsoft Windows Server 2012 R2 Standard" +"Q3SQL022","Microsoft Windows Server 2012 R2 Standard" +"Q4SQL022B","Microsoft Windows Server 2012 R2 Standard" +"Q4SQL022","Microsoft Windows Server 2012 R2 Standard" +"POSM014","Microsoft Windows Server 2012 R2 Standard" +"PCIC011","Microsoft Windows Server 2012 R2 Standard" +"PIMQ011","Microsoft Windows Server 2012 R2 Standard" +"PMDA011","Microsoft Windows Server 2012 R2 Standard" +"PISR011","Microsoft Windows Server 2012 R2 Standard" +"PSRS004","Microsoft Windows Server 2012 R2 Standard" +"PMDA014","Microsoft Windows Server 2012 R2 Standard" +"PSQL014","Microsoft Windows Server 2012 R2 Standard" +"PMDA012","Microsoft Windows Server 2012 R2 Standard" +"PMDA013","Microsoft Windows Server 2012 R2 Standard" +"FLT2PCIC011","Microsoft Windows Server 2012 R2 Standard" +"PBIT901","Microsoft Windows Server 2012 R2 Standard" +"PIWC012","Microsoft Windows Server 2012 R2 Standard" +"FLT2POSM012","Microsoft Windows Server 2012 R2 Standard" +"POSM012","Microsoft Windows Server 2012 R2 Standard" +"PIWC011","Microsoft Windows Server 2012 R2 Standard" +"FLT2POSM013","Microsoft Windows Server 2012 R2 Standard" +"PVVC011","Microsoft Windows Server 2012 R2 Standard" +"PRSH101","Microsoft Windows Server 2012 R2 Standard" +"QBIZ142","Microsoft Windows Server 2012 R2 Standard" +"FLT2PMDA011","Microsoft Windows Server 2012 R2 Standard" +"FLT2POSM011","Microsoft Windows Server 2012 R2 Standard" +"FLT2PMDA012","Microsoft Windows Server 2012 R2 Standard" +"FLT2POSM014","Microsoft Windows Server 2012 R2 Standard" +"FLT2PICW011","Microsoft Windows Server 2012 R2 Standard" +"FLT2PMDA013","Microsoft Windows Server 2012 R2 Standard" +"FLT2PMDA014","Microsoft Windows Server 2012 R2 Standard" +"PRCS012","Microsoft Windows Server 2012 R2 Standard" +"POSM011","Microsoft Windows Server 2012 R2 Standard" +"POSM013","Microsoft Windows Server 2012 R2 Standard" +"DIWC011","Microsoft Windows Server 2012 R2 Standard" +"PRCS011","Microsoft Windows Server 2012 R2 Standard" +"PSQL024","Microsoft Windows Server 2012 R2 Standard" +"PDISKTEST1","Microsoft Windows Server 2012 R2 Standard" +"PMDA016","Microsoft Windows Server 2012 R2 Standard" +"FLT2PCAC001","Microsoft Windows Server 2012 R2 Standard" +"PMDA015","Microsoft Windows Server 2012 R2 Standard" +"PMDA017","Microsoft Windows Server 2012 R2 Standard" +"FLT2PALT001","Microsoft Windows Server 2012 R2 Standard" +"POSM016","Microsoft Windows Server 2012 R2 Standard" +"FLT2PCAC002","Microsoft Windows Server 2012 R2 Standard" +"POSM015","Microsoft Windows Server 2012 R2 Standard" +"PSQL012","Microsoft Windows Server 2012 R2 Standard" +"FLT2PRCS011","Microsoft Windows Server 2012 R2 Standard" +"FLT2PMDA017","Microsoft Windows Server 2012 R2 Standard" +"FLT2PMDA015","Microsoft Windows Server 2012 R2 Standard" +"FLT2PMDA016","Microsoft Windows Server 2012 R2 Standard" +"KSOPPRCS011","Microsoft Windows Server 2012 R2 Standard" +"PRSH102","Microsoft Windows Server 2012 R2 Standard" +"DVST001","Microsoft Windows Server 2012 R2 Standard" +"QBIZ141","Microsoft Windows Server 2012 R2 Standard" +"DRCS011","Microsoft Windows Server 2012 R2 Standard" +"QSNX001","Microsoft Windows Server 2012 R2 Standard" +"PAPCAC001","Microsoft Windows Server 2016 Standard" +"DNCRAAUTO006","Microsoft Windows Server 2016 Standard" +"PSQL027","Microsoft Windows Server 2016 Standard" +"PSUS001","Microsoft Windows Server 2016 Standard" +"PNCRAVERRRPT001","Microsoft Windows Server 2016 Standard" +"PSIS003","Microsoft Windows Server 2016 Standard" +"PSQL028Q","Microsoft Windows Server 2019 Standard" +"PSQL030Q","Microsoft Windows Server 2019 Standard" +"QNCRASCCM001","Microsoft Windows Server 2019 Standard" +"PVAPV002","Microsoft Windows Server 2019 Standard" +"PSEC003","Microsoft Windows Server 2019 Standard" +"PVAPV003","Microsoft Windows Server 2019 Standard" +"PVAPV001","Microsoft Windows Server 2019 Standard" +"PSQL029Q","Microsoft Windows Server 2019 Standard" +"PVVCO005","Microsoft Windows Server 2019 Standard" +"PVVCO006","Microsoft Windows Server 2019 Standard" +"PVVCO002","Microsoft Windows Server 2019 Standard" +"PVVCO003","Microsoft Windows Server 2019 Standard" +"PNCRALSWMON001","Microsoft Windows Server 2019 Standard" +"PVVCO004","Microsoft Windows Server 2019 Standard" +"PNCRANTRX004","Microsoft Windows Server 2019 Standard" +"PNCRAVERVLT004","Microsoft Windows Server 2016 Standard" +"FLT2VEB002","Microsoft Windows Server 2019 Standard" +"FLT2VEB003","Microsoft Windows Server 2016 Standard" +"S16NCRASRV00001","Microsoft Windows Server 2016 Standard" +"PNCRAVONE01","Microsoft Windows Server 2019 Standard" +"DSPUPG2013","Microsoft Windows Server 2012 R2 Standard" +"DAPP012","Microsoft Windows Server 2012 R2 Standard" +"DDOC001","Microsoft Windows Server 2012 R2 Standard" +"DAPCAC001","Microsoft Windows Server 2016 Standard" +"DFNP001","Microsoft Windows Server 2012 R2 Standard" +"DFAX011","Microsoft Windows Server 2016 Standard" +"DAPP006","Microsoft Windows Server 2012 R2 Standard" +"DFNP002","Microsoft Windows Server 2012 R2 Standard" +"DAPSEP001","Microsoft Windows Server 2016 Standard" +"PNCRASCCMWKDP03","Microsoft Windows Server 2019 Standard" +"PNCRASCCMWSP2","Microsoft Windows Server 2019 Standard" +"PNCRASCCMWKDP02","Microsoft Windows Server 2019 Standard" +"PNCRASCCMWSP3","Microsoft Windows Server 2019 Standard" +"PNCRASMTP02","Microsoft Windows Server 2019 Standard" +"PNCRASMTP01","Microsoft Windows Server 2019 Standard" +"PNCRAADMIN01","Microsoft Windows Server 2019 Standard" +"PVVCO001","Microsoft Windows Server 2019 Standard" +"PFNP005","Microsoft Windows Server 2019 Standard" +"PFNP001","Microsoft? Windows Server? 2008 Enterprise " +"PNCRACS01","Microsoft Windows Server 2019 Standard" +"QNCRACS01","Microsoft Windows Server 2019 Standard" +"DNCRACS01","Microsoft Windows Server 2019 Standard" +"PNCRAMEP01","Microsoft Windows Server 2019 Standard" +"DNCRAMEP01","Microsoft Windows Server 2019 Standard" +"PNCRAEXMBX005","Microsoft Windows Server 2012 R2 Standard" +"DNCRAFILETEST01","Microsoft Windows Server 2019 Standard" +"PAPP002","Microsoft Windows 2000 Server" +"DFNP011","Microsoft Windows Server 2012 R2 Standard" +"PSQL023","Microsoft Windows Server 2012 R2 Standard" +"PSQL023B","Microsoft Windows Server 2012 R2 Standard" +"PSQL026","Microsoft Windows Server 2016 Standard" +"PSQL029A","Microsoft Windows Server 2016 Standard" +"PSQL030A","Microsoft Windows Server 2016 Standard" +"PSQL030A","Microsoft Windows Server 2016 Standard" +"PNCRAWFM01","Microsoft Windows Server 2019 Standard" +"DSPUPG2016","Microsoft Windows Server 2019 Standard" +"DRSQL028","Microsoft Windows Server 2016 Standard" +"PNCRAFILE004","Microsoft Windows Server 2019 Standard" +"QNCRAMEP01","Microsoft Windows Server 2019 Standard" +"PFNP003A","Microsoft Windows Server 2019 Standard" +"PFNP001A","Microsoft Windows Server 2019 Standard" diff --git a/dump/Files/Servers-Not-In-Patching-Group.csv b/dump/Files/Servers-Not-In-Patching-Group.csv new file mode 100644 index 0000000..2d9ee9b --- /dev/null +++ b/dump/Files/Servers-Not-In-Patching-Group.csv @@ -0,0 +1,426 @@ +"server","SideIndicator" +"W2012A","<=" +"W2012B","<=" +"Q1NCRAFILE001","<=" +"DFNP014","<=" +"DAPCAC002","<=" +"DAPCAV001","<=" +"DAPVRNS001","<=" +"DGAW001","<=" +"DWAM002","<=" +"DIAP001","<=" +"DWHD003","<=" +"DCTI001","<=" +"DVB6001","<=" +"DFNP009","<=" +"DVCO001","<=" +"DBIT901","<=" +"DFNP020","<=" +"DAPP011","<=" +"DMHB001","<=" +"QRSH023","<=" +"QRSH022","<=" +"QRSH021","<=" +"DCAM011","<=" +"DCIC011","<=" +"DCIC012","<=" +"DSPUPG2010","<=" +"DOSM012","<=" +"DOSM011","<=" +"DMDA011","<=" +"DICW011","<=" +"DTABL001","<=" +"DSIS002","<=" +"DOWA001","<=" +"DBIZ111","<=" +"DBIZ112","<=" +"DBIZ113","<=" +"DUTL012","<=" +"DWAM001","<=" +"DSRS004","<=" +"DSSS001","<=" +"DSQL009","<=" +"DSQL021","<=" +"DSIS004","<=" +"QRSH002","<=" +"QRSH041","<=" +"QRSH051","<=" +"QRSH001","<=" +"QRSH031","<=" +"QAPP041","<=" +"DEDI111","<=" +"DEDI112","<=" +"DEDI113","<=" +"QRSH111","<=" +"DSQL027A","<=" +"DSQL027B","<=" +"DSRS005","<=" +"DSQL000","<=" +"DSQL030","<=" +"DSQL004","<=" +"DSQL029","<=" +"DSIS005","<=" +"DSQL031","<=" +"DSIS003","<=" +"DNCRASSIS001","<=" +"DSQL028","<=" +"DSQL021Q","<=" +"DSQL024","<=" +"DNCRASPWFE01","<=" +"DNCRASPAS01","<=" +"QAPP031","<=" +"QNCRASPAPP01","<=" +"QNCRASPDC01","<=" +"QNCRASPAPP02","<=" +"QNCRASPWFE01","<=" +"QNCRASPWFE02","<=" +"QNCRASPDC02","<=" +"QNCRASPSEA01","<=" +"QNCRASPSEA02","<=" +"QRDS002","<=" +"QMHB003","<=" +"QMHB004","<=" +"QRDS001","<=" +"QAPP051","<=" +"QMHB001","<=" +"QMFT001","<=" +"QBIZ151","<=" +"QBIZ152","<=" +"Q1SQL024","<=" +"QAPP011","<=" +"QNCRASPOOS01","<=" +"DNCRASPOOS01","<=" +"QRSH101","<=" +"QSCH012","<=" +"QDRF001","<=" +"QFNP008","<=" +"Q2NCRAFILE001","<=" +"Q3NCRAFILE001","<=" +"QMHB002","<=" +"QSRS004","<=" +"QFNP007","<=" +"QSQL029","<=" +"QSQL030","<=" +"Q5NCRAFILE001","<=" +"QADF001","<=" +"QTABL001","<=" +"Q4NCRAFILE001","<=" +"QFNP009","<=" +"QSCH011","<=" +"QSQL028","<=" +"QAPP021","<=" +"QSCH014","<=" +"QFNP001","<=" +"QSCH013","<=" +"QVST012","<=" +"QVST011","<=" +"QSIS003","<=" +"PNCRAVPRXY001","<=" +"PMON005","<=" +"PNCRAVERVLT001","<=" +"PALT001","<=" +"PICW011","<=" +"PVEO002","<=" +"PMON010","<=" +"PRSH014","<=" +"PVEO001","<=" +"PNCRAVPRXY002","<=" +"PVET001","<=" +"PMON009","<=" +"PNCRANTRX002","<=" +"PSSS001","<=" +"PTTS011","<=" +"PVER001","<=" +"PVEB001","<=" +"PMON011","<=" +"PDMC005","<=" +"PDMC003","<=" +"PDMC002","<=" +"PDMC001","<=" +"PDMC004","<=" +"PDMC006","<=" +"CTSTPDMC001","<=" +"FLT2PTTS011","<=" +"FLT2PDMC001","<=" +"FLT2PDMC002","<=" +"KSOPPDMC001","<=" +"NYMEPDMC001","<=" +"PVAV001","<=" +"PVAV002","<=" +"PVAV003","<=" +"PNCRARCM001","<=" +"AZPHPRCS011","<=" +"CTHAPRCS011","<=" +"CTHAPALT002","<=" +"CTSTPALT001","<=" +"PFNP003","<=" +"DPOCSP001","<=" +"PVVC012","<=" +"PVVC014","<=" +"PVVC013","<=" +"QRSH113","<=" +"Q5SQL022","<=" +"QUTL012","<=" +"Q4SQL024","<=" +"QFNP003","<=" +"QBIZ121","<=" +"QBIZ132","<=" +"QEDI153","<=" +"QEDI113","<=" +"QRSH112","<=" +"QBIZ131","<=" +"QSIS002","<=" +"QBIZ122","<=" +"QVST021","<=" +"QEDI152","<=" +"QEDI111","<=" +"QVST022","<=" +"QEDI151","<=" +"QEDI112","<=" +"Q1SQL022","<=" +"PVVC015","<=" +"PVVC016","<=" +"QBIZ112","<=" +"QBIZ111","<=" +"Q2SQL022","<=" +"Q3SQL022","<=" +"Q4SQL022B","<=" +"Q4SQL022","<=" +"POSM014","<=" +"PCIC011","<=" +"PIMQ011","<=" +"PMDA011","<=" +"PISR011","<=" +"PSRS004","<=" +"PMDA014","<=" +"PSQL014","<=" +"PMDA012","<=" +"PMDA013","<=" +"FLT2PCIC011","<=" +"PBIT901","<=" +"PIWC012","<=" +"FLT2POSM012","<=" +"POSM012","<=" +"PIWC011","<=" +"FLT2POSM013","<=" +"PVVC011","<=" +"PRSH101","<=" +"QBIZ142","<=" +"FLT2PMDA011","<=" +"FLT2POSM011","<=" +"FLT2PMDA012","<=" +"FLT2POSM014","<=" +"FLT2PICW011","<=" +"FLT2PMDA013","<=" +"FLT2PMDA014","<=" +"PRCS012","<=" +"POSM011","<=" +"POSM013","<=" +"DIWC011","<=" +"PRCS011","<=" +"PSQL024","<=" +"PDISKTEST1","<=" +"PMDA016","<=" +"FLT2PCAC001","<=" +"PMDA015","<=" +"PMDA017","<=" +"FLT2PALT001","<=" +"POSM016","<=" +"FLT2PCAC002","<=" +"POSM015","<=" +"PSQL012","<=" +"FLT2PRCS011","<=" +"FLT2PMDA017","<=" +"FLT2PMDA015","<=" +"FLT2PMDA016","<=" +"KSOPPRCS011","<=" +"PRSH102","<=" +"DVST001","<=" +"QBIZ141","<=" +"PIPM001","<=" +"DRCS011","<=" +"QSNX001","<=" +"PAPCAC001","<=" +"DNCRAAUTO006","<=" +"PSQL027","<=" +"PSUS001","<=" +"PNCRAVERRRPT001","<=" +"PSIS003","<=" +"PSQL028Q","<=" +"PSQL030Q","<=" +"QNCRASCCM001","<=" +"QQATEST01","<=" +"PVAPV002","<=" +"PSEC003","<=" +"PVAPV003","<=" +"PVAPV001","<=" +"PSQL029Q","<=" +"PVVCO005","<=" +"PVVCO006","<=" +"PVVCO002","<=" +"PVVCO003","<=" +"PNCRALSWMON001","<=" +"PVVCO004","<=" +"PNCRANTRX004","<=" +"PNCRAVERVLT004","<=" +"FLT2VEB002","<=" +"FLT2VEB003","<=" +"S16NCRASRV00001","<=" +"PNCRAVONE01","<=" +"DSPUPG2013","<=" +"DAPP012","<=" +"DDOC001","<=" +"DAPCAC001","<=" +"DFNP001","<=" +"DFAX011","<=" +"DAPP006","<=" +"DFNP002","<=" +"DAPSEP001","<=" +"PNCRASCCMWKDP03","<=" +"PNCRASCCMWSP2","<=" +"PNCRASCCMWKDP02","<=" +"PNCRASCCMWSP3","<=" +"PNCRASMTP02","<=" +"PNCRASMTP01","<=" +"PNCRAADMIN01","<=" +"PVVCO001","<=" +"PFNP005","<=" +"PFNP001","<=" +"PNCRACS01","<=" +"QNCRACS01","<=" +"DNCRACS01","<=" +"PNCRAMEP01","<=" +"DNCRAMEP01","<=" +"PNCRAEXMBX005","<=" +"DNCRAFILETEST01","<=" +"PPKI003","<=" +"PSQL008","<=" +"PAPP002","<=" +"QAPP005","<=" +"PSEV005","<=" +"PSEV002","<=" +"PVEP001","<=" +"PRSH181","<=" +"PRSH150","<=" +"PVCO001","<=" +"PRSH182","<=" +"QAPP002","<=" +"DFNP011","<=" +"DHIL001","<=" +"QAPP010","<=" +"PSEV021","<=" +"PRSH049","<=" +"PRSH060","<=" +"PDRDS001","<=" +"PSQL023","<=" +"PSQL023B","<=" +"PSEV017","<=" +"DAPP001-2012R2","<=" +"PSEV023","<=" +"DOIT001","<=" +"PVRT006","<=" +"PVRT003","<=" +"PVRT004","<=" +"PVRT001","<=" +"PVRT005","<=" +"PVRT002","<=" +"PFAX014","<=" +"PFAX013","<=" +"PFAX012","<=" +"PFAX011","<=" +"PVRT007","<=" +"FLT2PVRT007","<=" +"DVVC002","<=" +"DVVC001","<=" +"CTHAPVRT007","<=" +"AZPHPVRT007","<=" +"KSOPPVRT007","<=" +"PSQL026B","<=" +"PSQLCL26","<=" +"PRMS002","<=" +"PRMS001","<=" +"PVER005","<=" +"Q2FNP003","<=" +"Q5FNP003","<=" +"Q1FNP003","<=" +"Q4FNP003","<=" +"Q3FNP003","<=" +"QDNS001","<=" +"PMQS001","<=" +"QCMX001","<=" +"psql029cl","<=" +"psql028cl","<=" +"PNTX001","<=" +"PCMX001","<=" +"DMQS001","<=" +"FLT2VEB001","<=" +"psql030cl","<=" +"DRSQL003","<=" +"DRSQL002","<=" +"DRRDS001","<=" +"DRTEST001","<=" +"DRRDS002","<=" +"dsql02130cl","<=" +"DMS3001","<=" +"PNCRASPOWA01","<=" +"I3-PROD-LIS","<=" +"PNCRASMI01","<=" +"DNCRAAUTO004","<=" +"DNCRAAUTO003","<=" +"DSPC001","<=" +"DFAX001","<=" +"DWHD004","<=" +"GOLD-S16-INSTAN","<=" +"DVRS001","<=" +"DFAX002","<=" +"DVVC003","<=" +"FLT2PDEP001","<=" +"DVVC004","<=" +"DSTMN001","<=" +"DNCRATESTVM2","<=" +"PADS001","<=" +"NPTEST1","<=" +"PSCH014-TEST","<=" +"PVEP602","<=" +"PWAP002-0","<=" +"PSQL000","<=" +"PSEV006","<=" +"PVEP601","<=" +"PFAX011CAP","<=" +"PSCH011-TEST","<=" +"PVEP604","<=" +"PMFT001","<=" +"PFAX015","<=" +"PDOMS001","<=" +"PVEP603","<=" +"PWAP001-0","<=" +"TESTVM6","<=" +"TEST","<=" +"QBIZ100","<=" +"PNCRAMEDI001","<=" +"TEMPDC004","<=" +"TEMPDC006","<=" +"TEMPNETWRIX","<=" +"DSTEA001","<=" +"DSACS001","<=" +"DSBAMCS001","<=" +"PNCRAWFM01","<=" +"DSNX001","<=" +"CLVA1PFNP005","<=" +"CLVA1PFNP003","<=" +"CLVA1PFNP006","<=" +"CLVA1PEXM001","<=" +"CLVA1PFNP007","<=" +"CLVA1PFNP001","<=" +"CLVA1PFNP002","<=" +"CLVA1PDMC001","<=" +"DSPUPG2016","<=" +"DRSQL028","<=" +"PNCRAFILE004","<=" +"QNCRAMEP01","<=" +"PNCRAPROSPD01","<=" +"PNFP012A","<=" +"PNFP011A","<=" +"PFNP003A","<=" +"PFNP001A","<=" +"PEXM004","<=" diff --git a/dump/Files/Servers-Not-Responding.txt b/dump/Files/Servers-Not-Responding.txt new file mode 100644 index 0000000..0fd2452 Binary files /dev/null and b/dump/Files/Servers-Not-Responding.txt differ diff --git a/dump/Files/dev-app-error-2-2020.txt b/dump/Files/dev-app-error-2-2020.txt new file mode 100644 index 0000000..ae1d64c Binary files /dev/null and b/dump/Files/dev-app-error-2-2020.txt differ diff --git a/dump/Files/dev-app-pending-restart.txt b/dump/Files/dev-app-pending-restart.txt new file mode 100644 index 0000000..a045e25 --- /dev/null +++ b/dump/Files/dev-app-pending-restart.txt @@ -0,0 +1,13 @@ +DIAP001 +DAPP006 +DFAX011 +DAPVRNS001 +DWAM001 +DMHB001 +DFNP002 +DFNP020 +DBIT901 +DFNP009 +DVB6001 +DCTI001 +DWHD003 \ No newline at end of file diff --git a/dump/Fully Automate Software Update Maintenance in Configuration Manager – Dam Good Admin.website b/dump/Fully Automate Software Update Maintenance in Configuration Manager – Dam Good Admin.website new file mode 100644 index 0000000..e058c41 --- /dev/null +++ b/dump/Fully Automate Software Update Maintenance in Configuration Manager – Dam Good Admin.website @@ -0,0 +1,18 @@ +[{000214A0-0000-0000-C000-000000000046}] +Prop3=19,11 +Prop4=31,Fully Automate Software Update Maintenance in Configuration Manager Dam Good Admin +[InternetShortcut] +IDList= +URL=https://damgoodadmin.com/2017/11/05/fully-automate-software-update-maintenance-in-cm/ +IconFile=https://damgoodadmin.com/favicon.ico +IconIndex=1 +[{A7AF692E-098D-4C08-A225-D433CA835ED0}] +Prop5=3,0 +Prop9=19,0 +Prop2=65,2C0000000000000001000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8F0200003D0000003F07000083030000B7 +[{000214A0-0000-0000-C000-000000000046}.A] +Prop4=31,Fully Automate Software Update Maintenance in Configuration Manager Dam Good Admin +[{000214A0-0000-0000-C000-000000000046}.W] +Prop4=31,Fully Automate Software Update Maintenance in Configuration Manager +IBM- Dam Good Admin +[{9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3}] +Prop5=8,Microsoft.Website.47A136E5.3264C1C6 diff --git a/dump/GUI-AlertBox.ps1 b/dump/GUI-AlertBox.ps1 new file mode 100644 index 0000000..2106d6b --- /dev/null +++ b/dump/GUI-AlertBox.ps1 @@ -0,0 +1,7 @@ +Add-Type -AssemblyName PresentationCore,PresentationFramework +$ButtonType = [System.Windows.MessageBoxButton]::YesNoCancel +$MessageIcon = [System.Windows.MessageBoxImage]::Error +$MessageBody = "Are you sure you want to delete the log file?" +$MessageTitle = "Confirm Deletion" +$Result = [System.Windows.MessageBox]::Show($MessageBody,$MessageTitle,$ButtonType,$MessageIcon) +"Your choice is $Result" \ No newline at end of file diff --git a/dump/GUI-DialogBox.ps1 b/dump/GUI-DialogBox.ps1 new file mode 100644 index 0000000..6311c4b --- /dev/null +++ b/dump/GUI-DialogBox.ps1 @@ -0,0 +1,12 @@ + +$d = [Windows.Forms.MessageBox]::show("PowerShell Rocks", "PowerShell Rocks", +[Windows.Forms.MessageBoxButtons]::YesNo, [Windows.Forms.MessageBoxIcon]::Question) + +If ($d -eq [Windows.Forms.DialogResult]::Yes) +{ + 'Yes, PowerShell Rocks' +} +else +{ + "On no, you don't like me" +} \ No newline at end of file diff --git a/dump/GUI-Inputbox-Dropdown-temp.ps1 b/dump/GUI-Inputbox-Dropdown-temp.ps1 new file mode 100644 index 0000000..be560ac --- /dev/null +++ b/dump/GUI-Inputbox-Dropdown-temp.ps1 @@ -0,0 +1,135 @@ +$Location = Split-Path $MyInvocation.MyCommand.Path -Parent +Function Start-Form { + + $Global:Collection_Name = "" + #$Global:Select_Tool = "" + $Global:Output_Type = "" + + $Temp = "" + + [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") + [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") + + $Form = New-Object System.Windows.Forms.Form + $Form.Size = New-Object System.Drawing.Size(600,400) + ############################################## + #$Form_Load={ $outputBox.text = "Welcome" } + ############################################## Start functions + <# function pingInfo { + + if ($RadioButton1.Checked -eq $true) {$nrOfPings=1} + if ($RadioButton2.Checked -eq $true) {$nrOfPings=2} + if ($RadioButton3.Checked -eq $true) {$nrOfPings=3} + + $computer=$DropDownBox.SelectedItem.ToString() #populate the var with the value you selected + $pingResult=ping $wks -n $nrOfPings | fl | out-string; + $outputBox.text=$pingResult + + } #end pingInfo + #> + ############################################## end functions + ############################################## + Function temp { + $outputBox.text = $textBox1.text | Out-String + $Global:Collection_Name = $textBox1.Text + #$Global:Select_Tool = $RadioButton1.Checked + $Global:Select_Tool = $DropDownBox.text + #$Global:Output_Type = + #if ($RadioButton2.Checked -eq $true) {Get-Service | Out-GridView} + + If($DropDownBox.text = "Tool1"){gcc} + + $textBox1.clear() + $DropDownBox.text = "----Select Tool----" + } + ############################################## + Function Update-Dropdown1 { + # $Collections += $textBox1.text + $Collections = @("Tool1","Tool2","Tool3","Tool4","Tool5","Tool6","Tool7") + $Collections | % { $DropDownBox.Items.Add($_) } + } + ############################################## + Function gcc { + $outputBox.text = Get-Service | Out-String + } + ############################################## + Function Clear-Variables { + $Global:Collection_Name = "" + $Global:Select_Tool = "" + $Global:Output_Type = "" + } + ############################################## Start group boxes + $groupBox = New-Object System.Windows.Forms.GroupBox + $groupBox.Location = New-Object System.Drawing.Size(270,20) + $groupBox.size = New-Object System.Drawing.Size(150,110) + $groupBox.text = "Select Output:" + $Form.Controls.Add($groupBox) + ############################################## end group boxes + + ############################################## Start radio buttons + $RadioButton1 = New-Object System.Windows.Forms.RadioButton + $RadioButton1.Location = new-object System.Drawing.Point(15,15) + $RadioButton1.size = New-Object System.Drawing.Size(130,20) + $RadioButton1.Checked = $true + $RadioButton1.Text = "Powershell Window" + $groupBox.Controls.Add($RadioButton1) + + $RadioButton2 = New-Object System.Windows.Forms.RadioButton + $RadioButton2.Location = new-object System.Drawing.Point(15,35) + $RadioButton2.size = New-Object System.Drawing.Size(80,20) + $RadioButton2.Text = "Gridview" + $groupBox.Controls.Add($RadioButton2) + + $RadioButton3 = New-Object System.Windows.Forms.RadioButton + $RadioButton3.Location = new-object System.Drawing.Point(15,55) + $RadioButton3.size = New-Object System.Drawing.Size(80,20) + $RadioButton3.Text = "Export csv" + $groupBox.Controls.Add($RadioButton3) + + ############################################## end radio buttons + ########### Text Box ########### + ############Define text box1 for input + $textBox1 = New-Object “System.Windows.Forms.TextBox”; + $textBox1.Left = 20; + $textBox1.Top = 30; + $textBox1.width = 200; + $Form.Controls.Add($textBox1) + ############################################## Start drop down boxes + + $DropDownBox = New-Object System.Windows.Forms.ComboBox + $DropDownBox.Location = New-Object System.Drawing.Size(20,80) + $DropDownBox.Size = New-Object System.Drawing.Size(180,20) + $DropDownBox.DropDownHeight = 200 + $DropDownBox.text = "----Select Tool----" + $Form.Controls.Add($DropDownBox) + + ############################################## end drop down boxes + + ############################################## Start text fields + + $outputBox = New-Object System.Windows.Forms.TextBox + $outputBox.Location = New-Object System.Drawing.Size(10,150) + $outputBox.Size = New-Object System.Drawing.Size(565,200) + $outputBox.MultiLine = $True + + $outputBox.ScrollBars = "Vertical" + $Form.Controls.Add($outputBox) + + ############################################## end text fields + + ############################################## Start buttons + + $Button = New-Object System.Windows.Forms.Button + $Button.Location = New-Object System.Drawing.Size(450,30) + $Button.Size = New-Object System.Drawing.Size(110,80) + $Button.Text = "Go" + $Button.Add_Click({temp}) + $Form.Controls.Add($Button) + + ############################################## end buttons + Update-Dropdown1 + + $Form.Add_Shown({$Form.Activate()}) + [void] $Form.ShowDialog() + +} \ No newline at end of file diff --git a/dump/GUI-Inputbox-Dropdown.ps1 b/dump/GUI-Inputbox-Dropdown.ps1 new file mode 100644 index 0000000..0ea901e --- /dev/null +++ b/dump/GUI-Inputbox-Dropdown.ps1 @@ -0,0 +1,96 @@ +[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") +[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") + +$Form = New-Object System.Windows.Forms.Form +$Form.Size = New-Object System.Drawing.Size(600,400) + +############################################## Start functions + +function pingInfo { + +if ($RadioButton1.Checked -eq $true) {$nrOfPings=1} +if ($RadioButton2.Checked -eq $true) {$nrOfPings=2} +if ($RadioButton3.Checked -eq $true) {$nrOfPings=3} + +$computer=$DropDownBox.SelectedItem.ToString() #populate the var with the value you selected +$pingResult=ping $wks -n $nrOfPings | fl | out-string; +$outputBox.text=$pingResult + + } #end pingInfo + +############################################## end functions + +############################################## Start group boxes + +$groupBox = New-Object System.Windows.Forms.GroupBox +$groupBox.Location = New-Object System.Drawing.Size(270,20) +$groupBox.size = New-Object System.Drawing.Size(100,100) +$groupBox.text = "Nr of pings:" +$Form.Controls.Add($groupBox) + +############################################## end group boxes + +############################################## Start radio buttons + +$RadioButton1 = New-Object System.Windows.Forms.RadioButton +$RadioButton1.Location = new-object System.Drawing.Point(15,15) +$RadioButton1.size = New-Object System.Drawing.Size(80,20) +$RadioButton1.Checked = $true +$RadioButton1.Text = "Ping once" +$groupBox.Controls.Add($RadioButton1) + +$RadioButton2 = New-Object System.Windows.Forms.RadioButton +$RadioButton2.Location = new-object System.Drawing.Point(15,45) +$RadioButton2.size = New-Object System.Drawing.Size(80,20) +$RadioButton2.Text = "Ping twice" +$groupBox.Controls.Add($RadioButton2) + +$RadioButton3 = New-Object System.Windows.Forms.RadioButton +$RadioButton3.Location = new-object System.Drawing.Point(15,75) +$RadioButton3.size = New-Object System.Drawing.Size(80,20) +$RadioButton3.Text = "Ping thrice" +$groupBox.Controls.Add($RadioButton3) + +############################################## end radio buttons + +############################################## Start drop down boxes + +$DropDownBox = New-Object System.Windows.Forms.ComboBox +$DropDownBox.Location = New-Object System.Drawing.Size(20,50) +$DropDownBox.Size = New-Object System.Drawing.Size(180,20) +$DropDownBox.DropDownHeight = 200 +$Form.Controls.Add($DropDownBox) + +$wksList=@("hrcomputer1","hrcomputer2","hrcomputer3","workstation1","workstation2","computer5","localhost") + +foreach ($wks in $wksList) { + $DropDownBox.Items.Add($wks) + } #end foreach + +############################################## end drop down boxes + +############################################## Start text fields + +$outputBox = New-Object System.Windows.Forms.TextBox +$outputBox.Location = New-Object System.Drawing.Size(10,150) +$outputBox.Size = New-Object System.Drawing.Size(565,200) +$outputBox.MultiLine = $True + +$outputBox.ScrollBars = "Vertical" +$Form.Controls.Add($outputBox) + +############################################## end text fields + +############################################## Start buttons + +$Button = New-Object System.Windows.Forms.Button +$Button.Location = New-Object System.Drawing.Size(400,30) +$Button.Size = New-Object System.Drawing.Size(110,80) +$Button.Text = "Ping" +$Button.Add_Click({pingInfo}) +$Form.Controls.Add($Button) + +############################################## end buttons + +$Form.Add_Shown({$Form.Activate()}) +[void] $Form.ShowDialog() \ No newline at end of file diff --git a/dump/GUI-Inputbox-Radio.ps1 b/dump/GUI-Inputbox-Radio.ps1 new file mode 100644 index 0000000..9fcd112 --- /dev/null +++ b/dump/GUI-Inputbox-Radio.ps1 @@ -0,0 +1,93 @@ +2 +3 + +# Introduction to Radio buttons and Grouping # +############################################## + +# A function to create the form +function Cheesy_Form{ + [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") + [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") + + # Set the size of your form + $Form = New-Object System.Windows.Forms.Form + $Form.width = 500 + $Form.height = 300 + $Form.Text = "My Cheesy Form with Radio buttons" + + # Set the font of the text to be used within the form + $Font = New-Object System.Drawing.Font("Times New Roman",12) + $Form.Font = $Font + + # Create a group that will contain your radio buttons + $MyGroupBox = New-Object System.Windows.Forms.GroupBox + $MyGroupBox.Location = '40,30' + $MyGroupBox.size = '400,110' + $MyGroupBox.text = "Do you like Cheese?" + + # Create the collection of radio buttons + $RadioButton1 = New-Object System.Windows.Forms.RadioButton + $RadioButton1.Location = '20,40' + $RadioButton1.size = '350,20' + $RadioButton1.Checked = $true + $RadioButton1.Text = "Yes - I like Cheese." + + $RadioButton2 = New-Object System.Windows.Forms.RadioButton + $RadioButton2.Location = '20,70' + $RadioButton2.size = '350,20' + $RadioButton2.Checked = $false + $RadioButton2.Text = "No - I don't like Cheese." + + $RadioButton3 = New-Object System.Windows.Forms.RadioButton + $RadioButton3.Location = '60,150' + $RadioButton3.size = '350,20' + $RadioButton3.Checked = $false + $RadioButton3.Text = "This is not a cheese related response." + + # Add an OK button + # Thanks to J.Vierra for simplifing the use of buttons in forms + $OKButton = new-object System.Windows.Forms.Button + $OKButton.Location = '130,200' + $OKButton.Size = '100,40' + $OKButton.Text = 'OK' + $OKButton.DialogResult=[System.Windows.Forms.DialogResult]::OK + + #Add a cancel button + $CancelButton = new-object System.Windows.Forms.Button + $CancelButton.Location = '255,200' + $CancelButton.Size = '100,40' + $CancelButton.Text = "Cancel" + $CancelButton.DialogResult=[System.Windows.Forms.DialogResult]::Cancel + + # Add all the GroupBox controls on one line + $MyGroupBox.Controls.AddRange(@($Radiobutton1,$RadioButton2)) + + # Add all the Form controls on one line + $form.Controls.AddRange(@($MyGroupBox,$OKButton,$CancelButton,$RadioButton3)) + + + + # Assign the Accept and Cancel options in the form to the corresponding buttons + $form.AcceptButton = $OKButton + $form.CancelButton = $CancelButton + + # Activate the form + $form.Add_Shown({$form.Activate()}) + + # Get the results from the button click + $dialogResult = $form.ShowDialog() + + # If the OK button is selected + if ($dialogResult -eq "OK"){ + + # Check the current state of each radio button and respond accordingly + if ($RadioButton1.Checked -and (!($RadioButton3.Checked))){ + [System.Windows.Forms.MessageBox]::Show("You like cheese." , "Great")} + elseif ($RadioButton2.Checked -and (!($RadioButton3.Checked))){ + [System.Windows.Forms.MessageBox]::Show("So your not a fan of cheese." , "Awe")} + elseif ($RadioButton3.Checked = $true){[System.Windows.Forms.MessageBox]::Show("That's OK - You don't have to answer cheesy questions" , "'No' to cheesy")} + } +} + +# Call the function +Cheesy_Form \ No newline at end of file diff --git a/dump/GUI-Inputbox-Text.ps1 b/dump/GUI-Inputbox-Text.ps1 new file mode 100644 index 0000000..91d8a50 --- /dev/null +++ b/dump/GUI-Inputbox-Text.ps1 @@ -0,0 +1,118 @@ +Function Invoke-InputBox { + + [cmdletbinding(DefaultParameterSetName="plain")] + [OutputType([system.string],ParameterSetName='plain')] + [OutputType([system.security.securestring],ParameterSetName='secure')] + + Param( + [Parameter(ParameterSetName="secure")] + [Parameter(HelpMessage = "Enter the title for the input box. No more than 25 characters.", + ParameterSetName="plain")] + + [ValidateNotNullorEmpty()] + [ValidateScript({$_.length -le 25})] + [string]$Title = "User Input", + + [Parameter(ParameterSetName="secure")] + [Parameter(HelpMessage = "Enter a prompt. No more than 50 characters.",ParameterSetName="plain")] + [ValidateNotNullorEmpty()] + [ValidateScript({$_.length -le 50})] + [string]$Prompt = "Please enter a value:", + + [Parameter(HelpMessage = "Use to mask the entry and return a secure string.", + ParameterSetName="secure")] + [switch]$AsSecureString + ) + + if ($PSEdition -eq 'Core') { + Write-Warning "Sorry. This command will not run on PowerShell Core." + #bail out + Return + } + + Add-Type -AssemblyName PresentationFramework + Add-Type –assemblyName PresentationCore + Add-Type –assemblyName WindowsBase + + #remove the variable because it might get cached in the ISE or VS Code + Remove-Variable -Name myInput -Scope script -ErrorAction SilentlyContinue + + $form = New-Object System.Windows.Window + $stack = New-object System.Windows.Controls.StackPanel + + #define what it looks like + $form.Title = $title + $form.Height = 150 + $form.Width = 350 + + $label = New-Object System.Windows.Controls.Label + $label.Content = " $Prompt" + $label.HorizontalAlignment = "left" + $stack.AddChild($label) + + if ($AsSecureString) { + $inputbox = New-Object System.Windows.Controls.PasswordBox + } + else { + $inputbox = New-Object System.Windows.Controls.TextBox + } + + $inputbox.Width = 300 + $inputbox.HorizontalAlignment = "center" + + $stack.AddChild($inputbox) + + $space = new-object System.Windows.Controls.Label + $space.Height = 10 + $stack.AddChild($space) + + $btn = New-Object System.Windows.Controls.Button + $btn.Content = "_OK" + + $btn.Width = 65 + $btn.HorizontalAlignment = "center" + $btn.VerticalAlignment = "bottom" + + #add an event handler + $btn.Add_click( { + if ($AsSecureString) { + $script:myInput = $inputbox.SecurePassword + } + else { + $script:myInput = $inputbox.text + } + $form.Close() + }) + + $stack.AddChild($btn) + $space2 = new-object System.Windows.Controls.Label + $space2.Height = 10 + $stack.AddChild($space2) + + $btn2 = New-Object System.Windows.Controls.Button + $btn2.Content = "_Cancel" + + $btn2.Width = 65 + $btn2.HorizontalAlignment = "center" + $btn2.VerticalAlignment = "bottom" + + #add an event handler + $btn2.Add_click( { + $form.Close() + }) + + $stack.AddChild($btn2) + + #add the stack to the form + $form.AddChild($stack) + + #show the form + $inputbox.Focus() | Out-Null + $form.WindowStartupLocation = [System.Windows.WindowStartupLocation]::CenterScreen + + $form.ShowDialog() | out-null + + #write the result from the input box back to the pipeline + $script:myInput + +} \ No newline at end of file diff --git a/dump/GUI-Inputbox.ps1 b/dump/GUI-Inputbox.ps1 new file mode 100644 index 0000000..31971ec --- /dev/null +++ b/dump/GUI-Inputbox.ps1 @@ -0,0 +1,20 @@ +$global:FN = "" +function New-InputBox +{ + param + ( + [Parameter(Mandatory)] + [string]$FirstName, + + [Parameter(Mandatory)] + [string]$LastName, + + [Parameter(Mandatory)] + [string]$Password + ) + + $FirstName, $LastName, $Password + $Global:FN = $FirstName + +} +Show-Command -Name New-InputBox \ No newline at end of file diff --git a/dump/GUI-Inputbox2.ps1 b/dump/GUI-Inputbox2.ps1 new file mode 100644 index 0000000..78670c1 --- /dev/null +++ b/dump/GUI-Inputbox2.ps1 @@ -0,0 +1,3 @@ +[void][System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic') +$name = [Microsoft.VisualBasic.Interaction]::InputBox("Enter your name", "Name", "Lastname") +"Your name is $name" \ No newline at end of file diff --git a/dump/GUI-Inputbox3.ps1 b/dump/GUI-Inputbox3.ps1 new file mode 100644 index 0000000..2dc2708 --- /dev/null +++ b/dump/GUI-Inputbox3.ps1 @@ -0,0 +1,98 @@ +function button ($title,$mailbx, $WF, $TF) { + +###################Load Assembly for creating form & button###### + +[void][System.Reflection.Assembly]::LoadWithPartialName( “System.Windows.Forms”) +[void][System.Reflection.Assembly]::LoadWithPartialName( “Microsoft.VisualBasic”) + +#####Define the form size & placement + +$form = New-Object “System.Windows.Forms.Form”; +$form.Width = 500; +$form.Height = 150; +$form.Text = $title; +$form.StartPosition = [System.Windows.Forms.FormStartPosition]::CenterScreen; + +##############Define text label1 +$textLabel1 = New-Object “System.Windows.Forms.Label”; +$textLabel1.Left = 25; +$textLabel1.Top = 15; + +$textLabel1.Text = $mailbx; + +##############Define text label2 + +$textLabel2 = New-Object “System.Windows.Forms.Label”; +$textLabel2.Left = 25; +$textLabel2.Top = 50; + +$textLabel2.Text = $WF; + +##############Define text label3 + +$textLabel3 = New-Object “System.Windows.Forms.Label”; +$textLabel3.Left = 25; +$textLabel3.Top = 85; + +$textLabel3.Text = $TF; + +############Define text box1 for input +$textBox1 = New-Object “System.Windows.Forms.TextBox”; +$textBox1.Left = 150; +$textBox1.Top = 10; +$textBox1.width = 200; + +############Define text box2 for input + +$textBox2 = New-Object “System.Windows.Forms.TextBox”; +$textBox2.Left = 150; +$textBox2.Top = 50; +$textBox2.width = 200; + + +############Define text box3 for input + +$textBox3 = New-Object “System.Windows.Forms.TextBox”; +$textBox3.Left = 150; +$textBox3.Top = 90; +$textBox3.width = 200; + +#############Define default values for the input boxes +$defaultValue = “” +$textBox1.Text = $defaultValue; +$textBox2.Text = $defaultValue; +$textBox3.Text = $defaultValue; + +#############define OK button +$button = New-Object “System.Windows.Forms.Button”; +$button.Left = 360; +$button.Top = 85; +$button.Width = 100; +$button.Text = “Ok”; + +############# This is when you have to close the form after getting values +$eventHandler = [System.EventHandler]{ +$textBox1.Text; +$textBox2.Text; +$textBox3.Text; +$form.Close();}; + +$button.Add_Click($eventHandler) ; + +#############Add controls to all the above objects defined +$form.Controls.Add($button); +$form.Controls.Add($textLabel1); +$form.Controls.Add($textLabel2); +$form.Controls.Add($textLabel3); +$form.Controls.Add($textBox1); +$form.Controls.Add($textBox2); +$form.Controls.Add($textBox3); +$ret = $form.ShowDialog(); + +#################return values + +return $textBox1.Text, $textBox2.Text, $textBox3.Text +} + +$return= button “Enter Folders” “Enter mailbox” “Working Folder” “Target Folder” + diff --git a/dump/GUI-Rich-Textbox.ps1 b/dump/GUI-Rich-Textbox.ps1 new file mode 100644 index 0000000..b8869f3 --- /dev/null +++ b/dump/GUI-Rich-Textbox.ps1 @@ -0,0 +1,78 @@ +function Load-Form { +Add-Type -AssemblyName System.Windows.Forms +Add-Type -AssemblyName System.Drawing + +$form = New-Object System.Windows.Forms.Form +$form.Text = "Data Entry Form" +$form.Size = New-Object System.Drawing.Size(400,300) +$form.StartPosition = "CenterScreen" + +$OKButton = New-Object System.Windows.Forms.Button +$OKButton.Location = New-Object System.Drawing.Point(75,120) +$OKButton.Size = New-Object System.Drawing.Size(75,23) +$OKButton.Text = "OK" +$OKButton.DialogResult = [System.Windows.Forms.DialogResult]::OK +$form.AcceptButton = $OKButton +$form.Controls.Add($OKButton) + +$CancelButton = New-Object System.Windows.Forms.Button +$CancelButton.Location = New-Object System.Drawing.Point(150,120) +$CancelButton.Size = New-Object System.Drawing.Size(75,23) +$CancelButton.Text = "Cancel" +$CancelButton.DialogResult = [System.Windows.Forms.DialogResult]::Cancel +$form.CancelButton = $CancelButton +$form.Controls.Add($CancelButton) + +$StartButton = New-Object System.Windows.Forms.Button +$StartButton.Location = New-Object System.Drawing.Point(75,90) +$StartButton.Size = New-Object System.Drawing.Size(75,23) +$StartButton.Text = "Start" +$StartButton.DialogResult = [System.Windows.Forms.DialogResult]::None +$StartButton.Add_Click({ +Test +$OUTPUT_RICHTEXT.Text+="Get out" +}) +$form.Controls.Add($StartButton) + +$SCRIPT:OUTPUT_RICHTEXT=New-Object System.Windows.Forms.RichTextBox +$OUTPUT_RICHTEXT.Location=New-Object System.Drawing.Size(10,150) +$OUTPUT_RICHTEXT.Size=New-Object System.Drawing.Size(300,100) +$OUTPUT_RICHTEXT.Multiline=$True +$OUTPUT_RICHTEXT.ReadOnly = $True +$OUTPUT_RICHTEXT.BackColor = [Drawing.Color]::White +$OUTPUT_RICHTEXT.ScrollBars = "Vertical" +$form.Controls.Add($OUTPUT_RICHTEXT) + +$label = New-Object System.Windows.Forms.Label +$label.Location = New-Object System.Drawing.Point(10,20) +$label.Size = New-Object System.Drawing.Size(280,20) +$label.Text = "Please enter the information in the space below:" +$form.Controls.Add($label) + +$textBox = New-Object System.Windows.Forms.TextBox +$textBox.Location = New-Object System.Drawing.Point(10,40) +$textBox.Size = New-Object System.Drawing.Size(260,20) +$form.Controls.Add($textBox) + +$form.Topmost = $True + +$form.Add_Shown({$textBox.Select()}) +$result = $form.ShowDialog() + +if ($result -eq [System.Windows.Forms.DialogResult]::OK) +{ + $x = $textBox.Text + $x +} +} + +function Test { +$script:OUTPUT_RICHTEXT.SelectionColor = 'Magenta' +$script:OUTPUT_RICHTEXT.AppendText("This text will be Magenta. `n") +$script:OUTPUT_RICHTEXT.SelectionColor = 'Green' +$script:OUTPUT_RICHTEXT.AppendText("This text will be Green. `n") +$script:OUTPUT_RICHTEXT.SelectionColor = 'Blue' +$script:OUTPUT_RICHTEXT.AppendText("This text will be Blue. `n") +} + +Load-Form \ No newline at end of file diff --git a/dump/GUI-Textbox.ps1 b/dump/GUI-Textbox.ps1 new file mode 100644 index 0000000..9cfcb07 --- /dev/null +++ b/dump/GUI-Textbox.ps1 @@ -0,0 +1,45 @@ +Add-Type -AssemblyName System.Windows.Forms +Add-Type -AssemblyName System.Drawing + +$form = New-Object System.Windows.Forms.Form +$form.Text = 'Data Entry Form' +$form.Size = New-Object System.Drawing.Size(300,200) +$form.StartPosition = 'CenterScreen' + +$okButton = New-Object System.Windows.Forms.Button +$okButton.Location = New-Object System.Drawing.Point(75,120) +$okButton.Size = New-Object System.Drawing.Size(75,23) +$okButton.Text = 'OK' +$okButton.DialogResult = [System.Windows.Forms.DialogResult]::OK +$form.AcceptButton = $okButton +$form.Controls.Add($okButton) + +$cancelButton = New-Object System.Windows.Forms.Button +$cancelButton.Location = New-Object System.Drawing.Point(150,120) +$cancelButton.Size = New-Object System.Drawing.Size(75,23) +$cancelButton.Text = 'Cancel' +$cancelButton.DialogResult = [System.Windows.Forms.DialogResult]::Cancel +$form.CancelButton = $cancelButton +$form.Controls.Add($cancelButton) + +$label = New-Object System.Windows.Forms.Label +$label.Location = New-Object System.Drawing.Point(10,20) +$label.Size = New-Object System.Drawing.Size(280,20) +$label.Text = 'Please enter the information in the space below:' +$form.Controls.Add($label) + +$textBox = New-Object System.Windows.Forms.TextBox +$textBox.Location = New-Object System.Drawing.Point(10,40) +$textBox.Size = New-Object System.Drawing.Size(260,20) +$form.Controls.Add($textBox) + +$form.Topmost = $true + +$form.Add_Shown({$textBox.Select()}) +$result = $form.ShowDialog() + +if ($result -eq [System.Windows.Forms.DialogResult]::OK) +{ + $x = $textBox.Text + $x +} \ No newline at end of file diff --git a/dump/GUI-Textbox2.ps1 b/dump/GUI-Textbox2.ps1 new file mode 100644 index 0000000..ab2a6bd --- /dev/null +++ b/dump/GUI-Textbox2.ps1 @@ -0,0 +1,92 @@ +### Creating the form with the Windows forms namespace +Add-Type -AssemblyName System.Windows.Forms +Add-Type -AssemblyName System.Drawing +$form = New-Object System.Windows.Forms.Form +$form.Text = 'Enter the appropriate information' ### Text to be displayed in the title +$form.Size = New-Object System.Drawing.Size(310,625) ### Size of the window +$form.StartPosition = 'CenterScreen' ### Optional - specifies where the window should start +$form.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::FixedToolWindow ### Optional - prevents resize of the window +#$form.Topmost = $true ### Optional - Opens on top of other windows + +### Adding an OK button to the text box window +$OKButton = New-Object System.Windows.Forms.Button +$OKButton.Location = New-Object System.Drawing.Point(155,550) ### Location of where the button will be +$OKButton.Size = New-Object System.Drawing.Size(75,23) ### Size of the button +$OKButton.Text = 'OK' ### Text inside the button +$OKButton.DialogResult = [System.Windows.Forms.DialogResult]::OK +$form.AcceptButton = $OKButton +$form.Controls.Add($OKButton) + +### Adding a Cancel button to the text box window +$CancelButton = New-Object System.Windows.Forms.Button +$CancelButton.Location = New-Object System.Drawing.Point(70,550) ### Location of where the button will be +$CancelButton.Size = New-Object System.Drawing.Size(75,23) ### Size of the button +$CancelButton.Text = 'Cancel' ### Text inside the button +$CancelButton.DialogResult = [System.Windows.Forms.DialogResult]::Cancel +$form.CancelButton = $CancelButton +$form.Controls.Add($CancelButton) + +### Putting a label above the text box +$label = New-Object System.Windows.Forms.Label +$label.Location = New-Object System.Drawing.Point(10,10) ### Location of where the label will be +$label.AutoSize = $True +$Font = New-Object System.Drawing.Font("Arial",12,[System.Drawing.FontStyle]::Bold) ### Formatting text for the label +$label.Font = $Font +$label.Text = $Input_Type ### Text of label, defined by the parameter that was used when the function is called +$label.ForeColor = 'Red' ### Color of the label text +$form.Controls.Add($label) + +### Inserting the text box that will accept input +$textBox = New-Object System.Windows.Forms.TextBox +$textBox.Location = New-Object System.Drawing.Point(10,40) ### Location of the text box +$textBox.Size = New-Object System.Drawing.Size(275,500) ### Size of the text box +$textBox.Multiline = $true ### Allows multiple lines of data +$textbox.AcceptsReturn = $true ### By hitting enter it creates a new line +$textBox.ScrollBars = "Vertical" ### Allows for a vertical scroll bar if the list of text is too big for the window +$form.Controls.Add($textBox) + +$form.Add_Shown({$textBox.Select()}) ### Activates the form and sets the focus on it +$result = $form.ShowDialog() ### Displays the form + +### If the OK button is selected do the following +if ($result -eq [System.Windows.Forms.DialogResult]::OK) +{ + ### Removing all the spaces and extra lines + $x = $textBox.Lines | Where{$_} | ForEach{ $_.Trim() } + ### Putting the array together + $array = @() + ### Putting each entry into array as individual objects + $array = $x -split "`r`n" + ### Sending back the results while taking out empty objects + Return $array | Where-Object {$_ -ne ''} +} + +### If the cancel button is selected do the following +if ($result -eq [System.Windows.Forms.DialogResult]::Cancel) +{ + Write-Host "User Canceled" -BackgroundColor Red -ForegroundColor White + Write-Host "Press any key to exit..." + $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") + Exit +} + + + + + +############################################################################### +### User Name(s) example of how to utilize the GUI_TextBox function +############################################################################### +$Users = GUI_TextBox "User Names(s):" ### Calls the text box function with a parameter and puts returned input in variable +$User_Count = $Users | Measure-Object | % {$_.Count} ### Measures how many objects were inputted + +If ($User_Count -eq 0){ ### If the count returns 0 it will throw and error + Write-Host "Nothing was inputed..." -BackgroundColor Red -ForegroundColor White + Return +} +Else { ### If there was actual data returned in the input, the script will continue + Write-Host "Number of users entered:" $User_Count -BackgroundColor Cyan -ForegroundColor Black + $Users + ### Here is where you would put your specific code to take action on those users inputted +} + diff --git a/dump/Hotfix-Report1.ps1 b/dump/Hotfix-Report1.ps1 new file mode 100644 index 0000000..b59afa3 --- /dev/null +++ b/dump/Hotfix-Report1.ps1 @@ -0,0 +1,59 @@ +<# +.Synopsis + This script will get details of perticular patch installed on remote computer. +.DESCRIPTION + This script will get details of perticular patch installed on remote computer, in this case I am trying to get recent emergency patch installed on remote computer. +.EXAMPLE + get-content "C:\temp\Hareesh\Script\Computers.txt" | get-installedpatch +.EXAMPLE + get-installedpatch -computers computer1,computer2 +.INPUTS + computername +.FUNCTIONALITY + This cmdlet is useful to check the recent emergency patch (KB4499175 or KB4499180) is installed on remote computer or not. +#> + +function get-installedpatch +{ +[cmdletbinding()] +param +( +[Parameter( +Mandatory=$true, +ValueFromPipeline=$true +)] +[string[]]$computers +) +Begin +{ + $Results = @() +} + + Process + { + foreach ($computer in $computers) + { + if (Test-Connection -ComputerName $computer -Count 1 -ea SilentlyContinue) + { + try + { + $hotfix = get-wmiobject win32_quickfixengineering -ComputerName $computer | sort Installedon -Descending | select -First 1 -ErrorAction stop + + } + catch + { + Write-output "$computer is giving exception" + $Computer #| out-file 'C:\temp\Hareesh\Script\KB4499175_ExceptionComputers.txt' -Append + } + } + else + { + Write-output "$computer is not online" #| Out-File "C:\temp\Hareesh\Script\KB4499175_Notonline.txt" + } + $hotfix + $Results #| export-csv "C:\temp\Hareesh\Script\KB4499175_Installed.csv" -NoTypeInformation + } + } +end {} +} +#get-content "C:\temp\Hareesh\Script\Computers.txt" | get-installedpatch \ No newline at end of file diff --git a/dump/Maintenance-Windows.ps1 b/dump/Maintenance-Windows.ps1 new file mode 100644 index 0000000..1e85ff8 --- /dev/null +++ b/dump/Maintenance-Windows.ps1 @@ -0,0 +1,36 @@ +<# + +Import-Module 'C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1' +New-PSDrive -Name SCCM-Drive -PSProvider "AdminUI.PS.Provider\CMSite" -Root "PNCRASCCM001.ccx.carecentrix.com" -Description "SCCM Site" + +#> +$Current_Location = Get-Location +CD sccm-drive: + +$All_Collections = @() +$Collection_Names = + "_6PM - Production Patching", + "_9PM - Production Patching", + "_11PM - Production Patching - File Servers", + "_11PM - Production Patching", + "__6PM - Production Patching - Domain Controllers 1", + "__9PM - Production Patching - Domain Controllers 2", + "__11PM - Production Patching - Domain Controllers 3" + +$Collection_Names | % { $All_Collections += Get-CMCollection -Name $_ } + +$All_Collections.name | % { $Maint = Get-CMMaintenanceWindow -CollectionName $_ + $Obj = New-Object -TypeName PSObject + $obj | Add-Member -MemberType NoteProperty -Name Collection -Value $_ + $Obj | Add-Member -MemberType NoteProperty -Name MaintenanceWindowName -Value $Maint.Name + $Obj | Add-Member -MemberType NoteProperty -Name Description -Value $Maint.Description + $Obj | Add-Member -MemberType NoteProperty -Name StartTime -Value $Maint.StartTime + $Obj | Add-Member -MemberType NoteProperty -Name RecurrenceType -Value $Maint.RecurrenceType + + $Obj + + }#end% + +#Set-Location $Current_Location + + diff --git a/dump/NA-Collections-Updates-Downloaded.ps1 b/dump/NA-Collections-Updates-Downloaded.ps1 new file mode 100644 index 0000000..57961af --- /dev/null +++ b/dump/NA-Collections-Updates-Downloaded.ps1 @@ -0,0 +1,73 @@ +<# + +Import-Module 'C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1' +New-PSDrive -Name SCCM-Drive -PSProvider "AdminUI.PS.Provider\CMSite" -Root "PNCRASCCM001.ccx.carecentrix.com" -Description "SCCM Site" + +#> + +$DeviceCollection_Name = "6PM - Production Patching" +#$DeviceCollection_Name = "9PM - Production Patching" +#$DeviceCollection_Name = "11PM - Production Patching - File Servers" +#$DeviceCollection_Name = "11PM - Production Patching" +#$DeviceCollection_Name = "" + +$DD = @() +$Downloaded_Updates = @() +$NOT_Downloaded_Updates = @() +$Count = 0 +[INT]$Last_Writetime = "800" #hours + + +CD sccm-drive: + +$DeviceCollection_MemberCount = Get-CMDeviceCollection -Name $DeviceCollection_Name | select Name,MemberCount +$DeviceCollection_ServerNames = Get-CMCollectionMember -CollectionName $DeviceCollection_Name | select Name,IsClient + +Set-Location c: + +$DeviceCollection_ServerNames.Name | % { + $Computer = $_ + $Check_Contents = gci "\\$Computer\c$\Windows\ccmcache" | ? { $_.lastwritetime -gt ((Get-Date).AddHours((-$Last_Writetime))) } + + If ($Check_Contents) { $Downloaded_Updates += $Computer } + Else { $NOT_Downloaded_Updates += $Computer } + +} + +If($Downloaded_Updates) { + $Downloaded_Updates | % { + $Updates_Downloaded = gci "\\$_\c$\Windows\ccmcache" | ? { $_.lastwritetime -gt ((Get-Date).AddHours((-$Last_Writetime))) } + $Obj = New-Object -TypeName PSObject + $Obj | Add-Member -MemberType NoteProperty -Name Computer -Value $_ + $Obj | Add-Member -MemberType NoteProperty -Name LastWriteTime -Value $Updates_Downloaded[-1].LastWriteTime + $Obj | Add-Member -MemberType NoteProperty -Name FileName -Value $Updates_Downloaded[-1].Name + $Obj | Add-Member -MemberType NoteProperty -Name UpdatesCount -Value ($Updates_Downloaded.count) + $Obj + }#end% + }#endIf +Write-Host "" +Write-Host "Total Servers in Collection: $($DeviceCollection_MemberCount.MemberCount)" -ForegroundColor Green +Write-Host "" +Write-Host "Servers Downloaded patches count: $($Downloaded_Updates.count)" -ForegroundColor Green +Write-Host "" +Write-Host "Total Servers in Collection - $($DeviceCollection_MemberCount.MemberCount)" +Write-Host "" +Write-Host "Nothing Downloaded for: $($NOT_Downloaded_Updates.count) Servers" -ForegroundColor Yellow + +Write-Host "" + + + +<# + Write-Host "" + Write-Host "" + Write-Host "Folder Empty for the following:" + Write-Host "$NOT_Downloaded_Updates" + + +#> + + + + + diff --git a/dump/NA-Servers-Updates-Downloaded.ps1 b/dump/NA-Servers-Updates-Downloaded.ps1 new file mode 100644 index 0000000..9269afa --- /dev/null +++ b/dump/NA-Servers-Updates-Downloaded.ps1 @@ -0,0 +1,37 @@ +$Downloaded_Updates = @() +$NOT_Downloaded_Updates = @() +$Count = 0 + +$Servers = Import-Csv 'E:\SCCM-Files\SCCM-Scripts\Files\9PM - Production Patching-NoInstall.csv' + +$Servers.Server | % { + $Computer = $_ + $Check_Contents = gci "\\$Computer\c$\Windows\ccmcache" -ErrorAction SilentlyContinue #| ? { $_.lastwritetime -gt ((Get-Date).AddHours((-$Last_Writetime))) } + + If ($Check_Contents) { $Downloaded_Updates += $Computer } + Else { $NOT_Downloaded_Updates += $Computer } + +} + +If($Downloaded_Updates) { + $Downloaded_Updates | % { + $Updates_Downloaded = gci "\\$_\c$\Windows\ccmcache" -ErrorAction SilentlyContinue #| ? { $_.lastwritetime -gt ((Get-Date).AddHours((-$Last_Writetime))) } + $Obj = New-Object -TypeName PSObject + $Obj | Add-Member -MemberType NoteProperty -Name Computer -Value $_ + $Obj | Add-Member -MemberType NoteProperty -Name LastWriteTime -Value $Updates_Downloaded[-1].LastWriteTime + $Obj | Add-Member -MemberType NoteProperty -Name FileName -Value $Updates_Downloaded[-1].Name + $Obj | Add-Member -MemberType NoteProperty -Name UpdatesCount -Value ($Updates_Downloaded.count) + $Obj + }#end% + }#endIf +Write-Host "" +Write-Host "Nothing Downloaded for: $NOT_Downloaded_Updates" -ForegroundColor Yellow +Write-Host "" +Write-Host "Servers Downloaded patches count: $($Downloaded_Updates.count)" -ForegroundColor Green +Write-Host "" + + + + + + diff --git a/dump/NA-Tool-GUI-2.ps1 b/dump/NA-Tool-GUI-2.ps1 new file mode 100644 index 0000000..25fb1a7 --- /dev/null +++ b/dump/NA-Tool-GUI-2.ps1 @@ -0,0 +1,312 @@ +$Location = Split-Path $MyInvocation.MyCommand.Path -Parent + +$Script:ALL_Patch_Servers = @() +$Script:Responding = @() +$Script:NotResponding = @() +$Global:Collection_Name = "" +$Global:Select_Tool +$Global:Output_Type = "" + +If(!(Get-PSDrive -Name SCCM-Drive -ErrorAction SilentlyContinue)) { + Import-Module 'C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1' + New-PSDrive -Name SCCM-Drive -PSProvider "AdminUI.PS.Provider\CMSite" -Root "PNCRASCCM001.ccx.carecentrix.com" -Description "SCCM Site" +} +######################################################################################################################################################### +Function Start-Form { + + #$Global:Collection_Name = "" + #$Global:Select_Tool = "" + #$Global:Output_Type = "" + + $Temp = "" + + [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") + [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") + + $Form = New-Object System.Windows.Forms.Form + $Form.Size = New-Object System.Drawing.Size(1000,800) + ############################################## + #$Form_Load={ $Script:outputBox.text = "Welcome" } + ############################################## Start functions + <# function pingInfo { + + if ($RadioButton1.Checked -eq $true) {$nrOfPings=1} + if ($RadioButton2.Checked -eq $true) {$nrOfPings=2} + if ($RadioButton3.Checked -eq $true) {$nrOfPings=3} + + $computer=$DropDownBox.SelectedItem.ToString() #populate the var with the value you selected + $pingResult=ping $wks -n $nrOfPings | fl | out-string; + $Script:outputBox.text=$pingResult + + } #end pingInfo + #> + ############################################## end functions + Function SCCM-Module { + + If(!(Get-PSDrive).Name -eq "sccm-drive") { + Import-Module 'C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1' + New-PSDrive -Name SCCM-Drive -PSProvider "AdminUI.PS.Provider\CMSite" -Root "PNCRASCCM001.ccx.carecentrix.com" -Description "SCCM Site" + }#endIf + CD sccm-drive: + }#endFunction + ############################################## + Function Run-Defaults { + $Script:textBox1.Text = "Nabil - Test Collection" + $Script:RadioButton1.Checked = $true + } + ############################################## + Function temp { + $outputBox.Clear() + #$Script:outputBox.text = $textBox1.text | Out-String + $Global:Collection_Name = $textBox1.Text + #$Global:Select_Tool = $RadioButton1.Checked + + $Global:Select_Tool = $DropDownBox.text + #$Global:Output_Type = + If ($RadioButton1.Checked -eq $true) { $Global:Output_Type = "Window"; $outputBox.Text = "Radio1 Checked: $($RadioButton1.Checked)" | Out-String } + ElseIf ($RadioButton2.Checked -eq $true) { $Global:Output_Type = "Gridview"; $outputBox.Text = "Radio2 Checked: $RadioButton2.Checked" | Out-String } + ElseIf ($RadioButton3.Checked -eq $true) { $Global:Output_Type = "Export"; $outputBox.Text = "Radio3 Checked: $RadioButton2.Checked" | Out-String } + + If($Global:Collection_Name -and $Global:Select_Tool) { + # If($DropDownBox.text = "Tool1"){gcc} + Run-Tool + $textBox1.clear() + $DropDownBox.text = "----Select Tool----" + Clear-Variables + }#endIf + Else { #$T = { Write-Host "You must enter Collection Name ............!!" -ForegroundColor Red } + $Script:outputBox.SelectionColor = 'red' + $Script:outputBox.Text = "You must select 'Tool' and enter Collection Name............!!" + } + + Run-Defaults + }#endFunction + ############################################## + Function Update-Dropdown1 { + # $Collections += $textBox1.text + $Collections = @("Collection-Servers","Ping-Collection","Check_Uptime","Test-Service","Tool5","Tool6","Tool7") + $Collections | % { $DropDownBox.Items.Add($_) } + } + ############################################## + Function gcc { + $Script:outputBox.text = Get-Service | Out-String + } + ############################################## + Function Clear-Variables { + $Global:Collection_Name = "" + $Global:Select_Tool = "" + $Global:Output_Type = "" + + $Script:ALL_Patch_Servers = @() + } +#region Controls + ############################################## Start group boxes + $groupBox = New-Object System.Windows.Forms.GroupBox + $groupBox.Location = New-Object System.Drawing.Size(270,20) + $groupBox.size = New-Object System.Drawing.Size(150,110) + $groupBox.text = "Select Output:" + $Form.Controls.Add($groupBox) + ############################################## end group boxes + + ############################################## Start radio buttons + $Script:RadioButton1 = New-Object System.Windows.Forms.RadioButton + $Script:RadioButton1.Location = new-object System.Drawing.Point(15,15) + $Script:RadioButton1.size = New-Object System.Drawing.Size(130,20) + $Script:RadioButton1.Checked = $true + $Script:RadioButton1.Text = "Window" + $groupBox.Controls.Add($RadioButton1) + + $Script:RadioButton2 = New-Object System.Windows.Forms.RadioButton + $Script:RadioButton2.Location = new-object System.Drawing.Point(15,35) + $Script:RadioButton2.size = New-Object System.Drawing.Size(80,20) + $Script:RadioButton2.Text = "Gridview" + $groupBox.Controls.Add($RadioButton2) + + $Script:RadioButton3 = New-Object System.Windows.Forms.RadioButton + $Script:RadioButton3.Location = new-object System.Drawing.Point(15,55) + $Script:RadioButton3.size = New-Object System.Drawing.Size(80,20) + $Script:RadioButton3.Text = "Export csv" + $groupBox.Controls.Add($RadioButton3) + + ############################################## end radio buttons + ########### Text Box ########### + ############Define text box1 for input + $Script:textBox1 = New-Object “System.Windows.Forms.TextBox”; + $Script:textBox1.Left = 20; + $Script:textBox1.Top = 30; + $Script:textBox1.width = 200; + $Script:textBox1.Text = "Nabil - Test Collection" + $Form.Controls.Add($textBox1) + ############################################## Start drop down boxes + + $Script:DropDownBox = New-Object System.Windows.Forms.ComboBox + $Script:DropDownBox.Location = New-Object System.Drawing.Size(20,80) + $Script:DropDownBox.Size = New-Object System.Drawing.Size(180,20) + $Script:DropDownBox.DropDownHeight = 200 + $Script:DropDownBox.text = "----Select Tool----" + $Form.Controls.Add($DropDownBox) + + ############################################## end drop down boxes + + <############################################## Start text fields + + $Script:outputBox = New-Object System.Windows.Forms.TextBox + $Script:outputBox.Location = New-Object System.Drawing.Size(10,150) + $Script:outputBox.Size = New-Object System.Drawing.Size(865,300) + $Script:outputBox.MultiLine = $True + + $Script:outputBox.ScrollBars = "Vertical" + $Form.Controls.Add($Script:outputBox) + ###########> + $SCRIPT:outputBox=New-Object System.Windows.Forms.RichTextBox + $outputBox.Location=New-Object System.Drawing.Size(10,150) + $outputBox.Size=New-Object System.Drawing.Size(965,600) + $outputBox.Multiline=$True + $outputBox.ReadOnly = $True + $outputBox.BackColor = [Drawing.Color]::White + $outputBox.ScrollBars = "both" + $outputBox.WordWrap = $false + $outputBox.Font = 'Consolas, 8.25pt' + $form.Controls.Add($Script:outputBox) + + + + + ############################################## end text fields + + ############################################## Start buttons + + $Button = New-Object System.Windows.Forms.Button + $Button.Location = New-Object System.Drawing.Size(450,30) + $Button.Size = New-Object System.Drawing.Size(110,80) + $Button.Text = "Go" + $Button.Add_Click({temp}) + $Form.Controls.Add($Button) +#endregion Controls + ############################################## end buttons + Update-Dropdown1 + + $Form.Add_Shown({$Form.Activate()}) + [void] $Form.ShowDialog() + +} +######################################################################################################################################################### + <# Function Input-Box { + [void][System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic') + $Global:Collection_Name = [Microsoft.VisualBasic.Interaction]::InputBox("Enter your name", "Name", "Enter Collection Name") + + } + #> +############################################################################################################################################################# + Function Display-Results { + #Param($Global:Output_Type,$Final_Result) + Write-Host "DisplayType: $($Global:Output_Type)" + Switch ($Global:Output_Type){ + + Window { $Script:outputBox.Text = $Script:ALL_Patch_Servers | Out-String} + Gridview { $Script:ALL_Patch_Servers | Out-GridView } + Export { $Script:ALL_Patch_Servers | Export-Csv -Path $Location\Results.csv -NoTypeInformation; ii $Location\Results.csv } + + }#endSwitch + + } +############################################################################################################################################################# + Function Collection-Servers { + #Param($Coll_Name) + + Write-Host "Collection:$Global:Collection_Name" + + SCCM-Module + #CD sccm-drive: + $Script:DeviceCollection_MemberCount = Get-CMDeviceCollection -Name $Global:Collection_Name | select Name,MemberCount + $Script:DeviceCollection_ServerNames = Get-CMCollectionMember -CollectionName $Global:Collection_Name | select Name,IsClient #| Export-Csv "E:\SCCM-Files\SCCM-Scripts\Files\$Global:Collection_Name.csv" -NoTypeInformation + #$ServerName = $DeviceCollection_ServerNames.Name + Set-Location c: + + #$Script:Temp = Get-CMCollectionMember -CollectionName $Global:Collection_Name #| select Name,IsClient + + $Script:DeviceCollection_ServerNames | % { + $Obj = New-Object -TypeName PSObject + $Obj | Add-Member -MemberType NoteProperty -Name Server -Value $_.Name + $Obj | Add-Member -MemberType NoteProperty -Name ClientInstalled -Value $_.IsClient + $Obj | Add-Member -MemberType NoteProperty -Name CollectionName -Value $Global:Collection_Name + #$Obj | Add-Member -MemberType NoteProperty -Name CollectionMemberCount -Value {(Get-CMCollectionMember -Name $Global:Collection_Name).MemberCount} + + $Obj + $Script:ALL_Patch_Servers += $Obj + + }#end% + + # $Script:outputBox.Text = $Script:ALL_Patch_Servers | Out-String + Display-Results #-Final_Result $Script:ALL_Patch_Servers + Write-Host "$Script:ALL_Patch_Servers" + + }#endFunction +############################################################################################################################################################# + Function Ping_Collection { + + $Ping_Result = @() + Write-Host "Total Server Count: $($Script:ALL_Patch_Servers.count)" -ForegroundColor Green + Write-Host "" + + SCCM-Module + #CD sccm-drive: + $Script:DeviceCollection_ServerNames1 = Get-CMCollectionMember -CollectionName $Global:Collection_Name | select Name + Set-Location c: + $Script:DeviceCollection_ServerNames1.Name | % { + + $Obj = New-Object -TypeName PSObject + If (Test-Connection $_ -Count 1 -ErrorAction SilentlyContinue ) { + #Write-Host "Responding:---- $_ " -ForegroundColor Green + #$Script:outputBox.AppendText("Responding: $_") + + $Obj | Add-Member -MemberType NoteProperty -Name Server -Value $_ + $Obj | Add-Member -MemberType NoteProperty -Name Responding -Value "No!" + $Ping_Result += $Obj + + }#endIf + + Else { + #$Script:outputBox.AppendText("NOT Responding: $_") + $NotResponding += $_ + $Obj | Add-Member -MemberType NoteProperty -Name Server -Value $_ + $Obj | Add-Member -MemberType NoteProperty -Name Responding -Value "No!" + $Ping_Result += $Obj + } + }#end% + $Script:outputBox.Text = $Ping_Result | ft -AutoSize | Out-String + + write-host "-------------------------------------------------------" + Write-host "$($Responding.count) / $($DeviceCollection_ServerNames1.count) -- Responding" -foregroundcolor Green + Write-host "$($NotResponding.count) / $($DeviceCollection_ServerNames1.count) -- NOT Responding" -foregroundcolor Red + + Write-Host "Servers NOT Responding: $NotResponding " -ForegroundColor Red + + }#endFunction +############################################################################################################################################################# + Function Check_Uptime { + SCCM-Module + $Script:DeviceCollection_ServerNames1 = Get-CMCollectionMember -CollectionName $Global:Collection_Name | select Name + $Script:outputBox.Text = $Script:DeviceCollection_ServerNames1.name | % { gwmi win32_operatingsystem -ComputerName $_ -ErrorAction SilentlyContinue | select @{n="Server";e={$_.PSComputername}},@{n="LastBootup";e={$_.Converttodatetime($_.LastBootUpTime)}}} | sort LastBootup -descending | Out-String + + } + +############################################################################################################################################################# + Function Test-Service { + $T = Get-Service + $outputBox.Text = $T | ft -AutoSize | Out-String + } +############################################################################################################################################################# + Function Run-Tool { + + Switch($Global:Select_Tool) { + Collection-Servers { Collection-Servers; Write-Host "Tool Selected: $Global:Select_Tool" } + Ping-Collection { Ping_Collection } + Check_Uptime { Check_Uptime } + Test-Service { Test-Service } + }#endSwitch + #Clear-Variables + }#endFunction +############################################################################################################################################################# +Start-Form + diff --git a/dump/NA-Tool-GUI.ps1 b/dump/NA-Tool-GUI.ps1 new file mode 100644 index 0000000..e16ec00 --- /dev/null +++ b/dump/NA-Tool-GUI.ps1 @@ -0,0 +1,293 @@ +$Location = Split-Path $MyInvocation.MyCommand.Path -Parent + +$Script:ALL_Patch_Servers = @() +$Script:Responding = @() +$Script:NotResponding = @() +$Global:Collection_Name = "" +$Global:Select_Tool +$Global:Output_Type = "" + +If(!(Get-PSDrive -Name SCCM-Drive -ErrorAction SilentlyContinue)) { + Import-Module 'C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1' + New-PSDrive -Name SCCM-Drive -PSProvider "AdminUI.PS.Provider\CMSite" -Root "PNCRASCCM001.ccx.carecentrix.com" -Description "SCCM Site" +} +######################################################################################################################################################### +Function Start-Form { + + #$Global:Collection_Name = "" + #$Global:Select_Tool = "" + #$Global:Output_Type = "" + + $Temp = "" + + [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") + [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") + + $Form = New-Object System.Windows.Forms.Form + $Form.Size = New-Object System.Drawing.Size(900,500) + ############################################## + #$Form_Load={ $Script:outputBox.text = "Welcome" } + ############################################## Start functions + <# function pingInfo { + + if ($RadioButton1.Checked -eq $true) {$nrOfPings=1} + if ($RadioButton2.Checked -eq $true) {$nrOfPings=2} + if ($RadioButton3.Checked -eq $true) {$nrOfPings=3} + + $computer=$DropDownBox.SelectedItem.ToString() #populate the var with the value you selected + $pingResult=ping $wks -n $nrOfPings | fl | out-string; + $Script:outputBox.text=$pingResult + + } #end pingInfo + #> + ############################################## end functions + Function SCCM-Module { + + If(!(Get-PSDrive).Name -eq "sccm-drive") { + Import-Module 'C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1' + New-PSDrive -Name SCCM-Drive -PSProvider "AdminUI.PS.Provider\CMSite" -Root "PNCRASCCM001.ccx.carecentrix.com" -Description "SCCM Site" + }#endIf + CD sccm-drive: + }#endFunction + ############################################## + Function Run-Defaults { + $Script:textBox1.Text = "Nabil - Test Collection" + $Script:RadioButton1.Checked = $true + } + ############################################## + Function temp { + $outputBox.Clear() + #$Script:outputBox.text = $textBox1.text | Out-String + $Global:Collection_Name = $textBox1.Text + #$Global:Select_Tool = $RadioButton1.Checked + + $Global:Select_Tool = $DropDownBox.text + #$Global:Output_Type = + If ($RadioButton1.Checked -eq $true) { $Global:Output_Type = "Window"; $outputBox.Text = "Radio1 Checked: $($RadioButton1.Checked)" | Out-String } + ElseIf ($RadioButton2.Checked -eq $true) { $Global:Output_Type = "Gridview"; $outputBox.Text = "Radio2 Checked: $RadioButton2.Checked" | Out-String } + ElseIf ($RadioButton3.Checked -eq $true) { $Global:Output_Type = "Export"; $outputBox.Text = "Radio3 Checked: $RadioButton2.Checked" | Out-String } + + If($Global:Collection_Name -and $Global:Select_Tool) { + # If($DropDownBox.text = "Tool1"){gcc} + Run-Tool + $textBox1.clear() + $DropDownBox.text = "----Select Tool----" + Clear-Variables + }#endIf + Else { #$T = { Write-Host "You must enter Collection Name ............!!" -ForegroundColor Red } + $Script:outputBox.SelectionColor = 'red' + $Script:outputBox.Text = "You must select 'Tool' and enter Collection Name............!!" + } + Run-Defaults + }#endFunction + ############################################## + Function Update-Dropdown1 { + # $Collections += $textBox1.text + $Collections = @("Collection-Servers","Ping-Collection","Check_Uptime","Tool4","Tool5","Tool6","Tool7") + $Collections | % { $DropDownBox.Items.Add($_) } + } + ############################################## + Function gcc { + $Script:outputBox.text = Get-Service | Out-String + } + ############################################## + Function Clear-Variables { + $Global:Collection_Name = "" + $Global:Select_Tool = "" + $Global:Output_Type = "" + + $Script:ALL_Patch_Servers = @() + } +#region Controls + ############################################## Start group boxes + $groupBox = New-Object System.Windows.Forms.GroupBox + $groupBox.Location = New-Object System.Drawing.Size(270,20) + $groupBox.size = New-Object System.Drawing.Size(150,110) + $groupBox.text = "Select Output:" + $Form.Controls.Add($groupBox) + ############################################## end group boxes + + ############################################## Start radio buttons + $Script:RadioButton1 = New-Object System.Windows.Forms.RadioButton + $Script:RadioButton1.Location = new-object System.Drawing.Point(15,15) + $Script:RadioButton1.size = New-Object System.Drawing.Size(130,20) + $Script:RadioButton1.Checked = $true + $Script:RadioButton1.Text = "Window" + $groupBox.Controls.Add($RadioButton1) + + $Script:RadioButton2 = New-Object System.Windows.Forms.RadioButton + $Script:RadioButton2.Location = new-object System.Drawing.Point(15,35) + $Script:RadioButton2.size = New-Object System.Drawing.Size(80,20) + $Script:RadioButton2.Text = "Gridview" + $groupBox.Controls.Add($RadioButton2) + + $Script:RadioButton3 = New-Object System.Windows.Forms.RadioButton + $Script:RadioButton3.Location = new-object System.Drawing.Point(15,55) + $Script:RadioButton3.size = New-Object System.Drawing.Size(80,20) + $Script:RadioButton3.Text = "Export csv" + $groupBox.Controls.Add($RadioButton3) + + ############################################## end radio buttons + ########### Text Box ########### + ############Define text box1 for input + $Script:textBox1 = New-Object “System.Windows.Forms.TextBox”; + $Script:textBox1.Left = 20; + $Script:textBox1.Top = 30; + $Script:textBox1.width = 200; + $Script:textBox1.Text = "Nabil - Test Collection" + $Form.Controls.Add($textBox1) + ############################################## Start drop down boxes + + $Script:DropDownBox = New-Object System.Windows.Forms.ComboBox + $Script:DropDownBox.Location = New-Object System.Drawing.Size(20,80) + $Script:DropDownBox.Size = New-Object System.Drawing.Size(180,20) + $Script:DropDownBox.DropDownHeight = 200 + $Script:DropDownBox.text = "----Select Tool----" + $Form.Controls.Add($DropDownBox) + + ############################################## end drop down boxes + + <############################################## Start text fields + + $Script:outputBox = New-Object System.Windows.Forms.TextBox + $Script:outputBox.Location = New-Object System.Drawing.Size(10,150) + $Script:outputBox.Size = New-Object System.Drawing.Size(865,300) + $Script:outputBox.MultiLine = $True + + $Script:outputBox.ScrollBars = "Vertical" + $Form.Controls.Add($Script:outputBox) + ###########> + $SCRIPT:outputBox=New-Object System.Windows.Forms.RichTextBox + $outputBox.Location=New-Object System.Drawing.Size(10,150) + $outputBox.Size=New-Object System.Drawing.Size(865,300) + $outputBox.Multiline=$True + $outputBox.ReadOnly = $True + $outputBox.BackColor = [Drawing.Color]::White + $outputBox.ScrollBars = "Vertical" + $form.Controls.Add($Script:outputBox) + + + + + ############################################## end text fields + + ############################################## Start buttons + + $Button = New-Object System.Windows.Forms.Button + $Button.Location = New-Object System.Drawing.Size(450,30) + $Button.Size = New-Object System.Drawing.Size(110,80) + $Button.Text = "Go" + $Button.Add_Click({temp}) + $Form.Controls.Add($Button) +#endregion Controls + ############################################## end buttons + Update-Dropdown1 + + $Form.Add_Shown({$Form.Activate()}) + [void] $Form.ShowDialog() + +} +######################################################################################################################################################### + <# Function Input-Box { + [void][System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic') + $Global:Collection_Name = [Microsoft.VisualBasic.Interaction]::InputBox("Enter your name", "Name", "Enter Collection Name") + + } + #> +############################################################################################################################################################# + Function Display-Results { + #Param($Global:Output_Type,$Final_Result) + Write-Host "DisplayType: $($Global:Output_Type)" + Switch ($Global:Output_Type){ + + Window { $Script:outputBox.Text = $Script:ALL_Patch_Servers | Out-String} + Gridview { $Script:ALL_Patch_Servers | Out-GridView } + Export { $Script:ALL_Patch_Servers | Export-Csv -Path $Location\Results.csv -NoTypeInformation; ii $Location\Results.csv } + + }#endSwitch + + } +############################################################################################################################################################# + Function Collection-Servers { + #Param($Coll_Name) + + Write-Host "Collection:$Global:Collection_Name" + + SCCM-Module + #CD sccm-drive: + $Script:DeviceCollection_MemberCount = Get-CMDeviceCollection -Name $Global:Collection_Name | select Name,MemberCount + $Script:DeviceCollection_ServerNames = Get-CMCollectionMember -CollectionName $Global:Collection_Name | select Name,IsClient #| Export-Csv "E:\SCCM-Files\SCCM-Scripts\Files\$Global:Collection_Name.csv" -NoTypeInformation + #$ServerName = $DeviceCollection_ServerNames.Name + Set-Location c: + + #$Script:Temp = Get-CMCollectionMember -CollectionName $Global:Collection_Name #| select Name,IsClient + + $Script:DeviceCollection_ServerNames | % { + $Obj = New-Object -TypeName PSObject + $Obj | Add-Member -MemberType NoteProperty -Name Server -Value $_.Name + $Obj | Add-Member -MemberType NoteProperty -Name ClientInstalled -Value $_.IsClient + $Obj | Add-Member -MemberType NoteProperty -Name CollectionName -Value $Global:Collection_Name + #$Obj | Add-Member -MemberType NoteProperty -Name CollectionMemberCount -Value {(Get-CMCollectionMember -Name $Global:Collection_Name).MemberCount} + + $Obj + $Script:ALL_Patch_Servers += $Obj + + }#end% + + # $Script:outputBox.Text = $Script:ALL_Patch_Servers | Out-String + Display-Results #-Final_Result $Script:ALL_Patch_Servers + Write-Host "$Script:ALL_Patch_Servers" + + }#endFunction +############################################################################################################################################################# + Function Ping_Collection { + + Write-Host "Total Server Count: $($Script:ALL_Patch_Servers.count)" -ForegroundColor Green + Write-Host "" + + SCCM-Module + #CD sccm-drive: + $Script:DeviceCollection_ServerNames1 = Get-CMCollectionMember -CollectionName $Global:Collection_Name | select Name + Set-Location c: + $Script:DeviceCollection_ServerNames1.Name | % { + + If (Test-Connection $_ -Count 1 -ErrorAction SilentlyContinue ) { + #Write-Host "Responding:---- $_ " -ForegroundColor Green + $Script:outputBox.AppendText("Responding: $_") + + $Responding += $_ + + }#endIf + + Else { + $Script:outputBox.AppendText("NOT Responding: $_") + $NotResponding += $_ } + + }#end% + write-host "-------------------------------------------------------" + Write-host "$($Responding.count) / $($DeviceCollection_ServerNames1.count) -- Responding" -foregroundcolor Green + Write-host "$($NotResponding.count) / $($DeviceCollection_ServerNames1.count) -- NOT Responding" -foregroundcolor Red + + Write-Host "Servers NOT Responding: $NotResponding " -ForegroundColor Red + + }#endFunction +############################################################################################################################################################# + Function Check_Uptime { + SCCM-Module + $Script:DeviceCollection_ServerNames1 = Get-CMCollectionMember -CollectionName $Global:Collection_Name | select Name + $Script:outputBox.Text = $Script:DeviceCollection_ServerNames1.name | % { gwmi win32_operatingsystem -ComputerName $_ -ErrorAction SilentlyContinue | select @{n="Server";e={$_.PSComputername}},@{n="LastBootup";e={$_.Converttodatetime($_.LastBootUpTime)}}} | sort LastBootup -descending | Out-String + + } +############################################################################################################################################################# + Function Run-Tool { + + Switch($Global:Select_Tool) { + Collection-Servers { Collection-Servers; Write-Host "Tool Selected: $Global:Select_Tool" } + Ping-Collection { Ping_Collection } + Check_Uptime { Check_Uptime } + }#endSwitch + #Clear-Variables + }#endFunction +############################################################################################################################################################# +Start-Form + diff --git a/dump/NA-Tool.ps1 b/dump/NA-Tool.ps1 new file mode 100644 index 0000000..5d2fc2d --- /dev/null +++ b/dump/NA-Tool.ps1 @@ -0,0 +1,133 @@ +# Import-Module E:\SCCM-Files\SCCM-Scripts\CMClient.psm1 + +######### From _Get-SCCMSoftwareUpdateStatus.ps1 ####### + +#Get-SCCMSoftwareUpdateStatus -DeploymentIDFromGUI +# $Status = Get-SCCMSoftwareUpdateStatus -DeploymentID 16777359 | select DeviceName + +<# + $status | ? { $_.status -eq "InProgress" } + $Status | ? { $_.status -eq "unknown" } + $Status | ? { $_.status -eq "Error" } + $Status | ? { $_.status -eq "unknown" } | Measure | Select Count + +#> +#################################################################################### + +###### From CCMClient.psm1 #### + +<# +#################################################################################### +#################################################################################### + +Invoke-CMClientUpdateScan -ComputerName +Invoke-CMClientUpdateDeploymentEvaluation -ComputerName +Invoke-CMClientMachinePolicyDownload -ComputerName + + + +$comps | % { + Invoke-CMClientUpdateScan -ComputerName $_ + Invoke-CMClientUpdateDeploymentEvaluation -ComputerName $_ + Invoke-CMClientMachinePolicyDownload -ComputerName $_ +} +#################################################################################### +#################################################################################### + +$comps = "" + + +<# + +$DeviceCollection_ServerNames.Name | % { $T = Test-Connection -ComputerName $_ -Count 1 -ErrorAction SilentlyContinue + If($T) { Write-Host "Server $_ -- Responding" -ForegroundColor Green } Else { Write-Host "Server $_ -- Not Responding" -ForegroundColor Red } +} + + +#################################################################################### +### + +$Responding = @() +$NotResponding = @() + +$DeviceCollection_ServerNames.Name | % { + + If (Test-Connection $_ -Count 1 -ErrorAction SilentlyContinue ) { + Write-Host "Responding:---- $_ " -ForegroundColor Green + $Responding += $_ + + }#endIf + + Else { $NotResponding += $_ } + +}#end% + write-host "-------------------------------------------------------" + Write-host "$($Responding.count) / $($DeviceCollection_ServerNames.Name.count) -- Responding" -foregroundcolor Green + Write-host "$($NotResponding.count) / $($DeviceCollection_ServerNames.Name.count) -- NOT Responding" -foregroundcolor Red + + +Write-Host "Servers NOT Responding: $NotResponding " -ForegroundColor Red + +$Responding | % { gwmi win32_operatingsystem -ComputerName $_ -ErrorAction SilentlyContinue | select @{n="Server";e={$_.PSComputername}},@{n="LastBootup";e={$_.Converttodatetime($_.LastBootUpTime)}}} | sort LastBootup -descending | ft -autosize + + +#################################################################################### + + gwmi win32_operatingsystem -ComputerName $DeviceCollection_ServerNames.Name | select @{n="Server";e={$_.PSComputername}},@{n="LastBootup";e={$_.Converttodatetime($_.LastBootUpTime)}} | ft -autosize + + +#> + +<# +#################################################################################### +#################################################################################### + +$Downloaded_Updates = @() +$NOT_Downloaded_Updates = @() +$Count = 0 +[INT]$Last_Writetime = "90" + +$comps = $DeviceCollection_ServerNames.name + +$comps | % { + $Computer = $_ + $Check_Contents = gci "\\$Computer\c$\Windows\ccmcache" | ? { $_.lastwritetime -gt ((Get-Date).ADDDays((-$Last_Writetime))) } + + If ($Check_Contents) { $Downloaded_Updates += $Computer } + Else { $NOT_Downloaded_Updates += $Computer } + +} + +If($Downloaded_Updates) { + $Downloaded_Updates | % { + $Updates_Downloaded = gci "\\$_\c$\Windows\ccmcache" | ? { $_.lastwritetime -gt ((Get-Date).ADDDays((-$Last_Writetime))) } + $Obj = New-Object -TypeName PSObject + $Obj | Add-Member -MemberType NoteProperty -Name Computer -Value $_ + $Obj | Add-Member -MemberType NoteProperty -Name LastWriteTime -Value $Updates_Downloaded[-1].LastWriteTime + $Obj | Add-Member -MemberType NoteProperty -Name FileName -Value $Updates_Downloaded[-1].Name + $Obj | Add-Member -MemberType NoteProperty -Name UpdatesCount -Value ($Updates_Downloaded.count) + $Obj + }#end% + }#endIf +Write-Host "" +Write-Host "Nothing Downloaded for: $NOT_Downloaded_Updates" -ForegroundColor Yellow +Write-Host "" +Write-Host "Servers Downloaded patches count: $($Downloaded_Updates.count)" -ForegroundColor Green +Write-Host "" +#################################################################################### +#################################################################################### +#> + + +#> + +######################## Check Installed Updates ########################### + +# $DeviceCollection_ServerNames.Name | % { Get-HotFix -ComputerName $_ | sort installedon -Descending | Select -First 1} + +# Get-HotFix -ComputerName pfnp013 | sort installedon -Descending | Select -First 10 + + +# $DeviceCollection_Name + + diff --git a/dump/Patching-Status-PILOT.ps1 b/dump/Patching-Status-PILOT.ps1 new file mode 100644 index 0000000..6bd43da --- /dev/null +++ b/dump/Patching-Status-PILOT.ps1 @@ -0,0 +1,93 @@ + <# + +Import-Module 'C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1' +New-PSDrive -Name SCCM-Drive -PSProvider "AdminUI.PS.Provider\CMSite" -Root "PNCRASCCM001.ccx.carecentrix.com" -Description "SCCM Site" + +#> + + + <# + + $Count = 0 + +# $D_ID = "16777912","16777914","16777916" +# $D_ID = "16777913","16777915","16777917" + +# $D_ID = "16778068" + + $Patching_Collections = "All - Inventory - Supporting Infrastructure", #------------------------0 + "All - Inventory - Database", #------------------------1 + "All - Inventory - Application Servers" #----------2 + + + + +<# + $Patching_Collections = "All - Inventory - Infrastructure Servers", #------------------------0 + "All - Inventory - Supporting Infrastructure", #------------------------1 + "All - Inventory - Database", #------------------------2 + "All - Inventory - Application Servers" #----------3 + + $D_ID = @("16777850"),"16777851") + $Patching_Collections = @("_6PM - Production Patching - Group 1"), + "_6PM - Production Patching - Group 2" + +#> + + + + + #> + $Run_Collections = "0","1","2" +# $Run_Collections = "0" + + $Script:Temp = @() + + +$Global:General = @() + + Function Patch_Report { + Param($ID,$Name) + $ID + $T = Get-SCCMSoftwareUpdateStatus -DeploymentID $ID + + write-host "" + write-host "------------------------------------------------------------------------------------" + write-host "$Name" -foregroundcolor white -backgroundcolor black + write-host "Total Servers: $($T.DeviceName.Count)" -foregroundcolor Black -Backgroundcolor white + $S = $T | ? { $_.Status -eq "InProgress" } + $Err = $T | ? { $_.Status -eq 'error' } | Select DeviceName + $Success = $T | ? { $_.Status -eq 'Success' } | Select DeviceName + $Un = $T | ? { $_.Status -eq 'Unknown' } | Select DeviceName + Write-Host "Unknown: $($Un.count)" -ForegroundColor Gray + Write-Host "Success: $($Success.Devicename.count)" -ForegroundColor Green + write-host "InProgress: $($S.DeviceName.count)" -foregroundcolor Cyan + write-host "Error Count: $($err.DeviceName.count)" -foregroundcolor red + + #Write-Host "Error: $($Err.count)" + $Temp = $Err + $Global:General = $Err + }#endFunction + +Write-Host "#####################################################################################" -BackgroundColor green -ForegroundColor black +$Run_Collections | % { Patch_Report -ID $D_ID[$_] -Name $Patching_Collections[$_] } + + + + <# + + + +$DeviceCollection_ServerNames.Name | % { $T = Test-Connection -ComputerName $_ -Count 1 -ErrorAction SilentlyContinue + If($T) { Write-Host "Server $_ -- Responding" -ForegroundColor Green } Else { Write-Host "Server $_ -- Not Responding" -ForegroundColor Red } +} + + + # $DeviceCollection_ServerNames.Name | % { gwmi win32_operatingsystem -ComputerName $_ | select @{n="Server";e={$_.PSComputername}},@{n="LastBootup";e={$_.Converttodatetime($_.LastBootUpTime)}}} | sort server| ft -autosize + + + # gwmi win32_operatingsystem -ComputerName $Temp.DeviceName | select @{n="Server";e={$_.PSComputername}},@{n="LastBootup";e={$_.Converttodatetime($_.LastBootUpTime)}} | ft -autosize + + + + #> \ No newline at end of file diff --git a/dump/Patching-Status.ps1 b/dump/Patching-Status.ps1 new file mode 100644 index 0000000..a191235 --- /dev/null +++ b/dump/Patching-Status.ps1 @@ -0,0 +1,68 @@ + <# + + $T = Get-SCCMSoftwareUpdateStatus -DeploymentID 16777538 # _11PM - Production Patching + $S = $T | ? { $_.Status -eq "InProgress" } + write-host "" + write-host "------------------------------------------------------------------------------------" + write-host "_11PM - Production Patching" -foregroundcolor white -backgroundcolor black + write-host "Total Servers: $($S.DeviceName.count)" -foregroundcolor Black -Backgroundcolor white + $Err = $T | ? { $_.Status -eq 'error' } | Select DeviceName + $Success = $T | ? { $_.Status -eq 'Success' } | Select DeviceName + write-host "Error Count: $($err.count)" -foregroundcolor Yellow + write-host "InProgress: $($S.DeviceName.count)" -foregroundcolor Cyan + + #> + + <# + + $T = Get-SCCMSoftwareUpdateStatus -DeploymentID 16777541 # _9PM - Production Patching + $S = $T | ? { $_.Status -eq "InProgress" } + write-host "" + write-host "------------------------------------------------------------------------------------" + write-host "_9PM - Production Patching" -foregroundcolor white -backgroundcolor black + write-host "Total Servers: $($S.DeviceName.count)" -foregroundcolor Black -Backgroundcolor white + $Err = $T | ? { $_.Status -eq 'error' } | Select DeviceName + $Success = $T | ? { $_.Status -eq 'Success' } | Select DeviceName + write-host "Error Count: $($err.count)" -foregroundcolor Yellow + write-host "InProgress: $($S.DeviceName.count)" -foregroundcolor Cyan + + #> + + <# + $T = Get-SCCMSoftwareUpdateStatus -DeploymentID 16777540 # _6PM - Production Patching + $S = $T | ? { $_.Status -eq "InProgress" } + write-host "" + write-host "------------------------------------------------------------------------------------" + write-host "_6PM - Production Patching" -foregroundcolor white -backgroundcolor black + write-host "Total Servers: $($S.DeviceName.count)" -foregroundcolor Black -Backgroundcolor white + $Err = $T | ? { $_.Status -eq 'error' } | Select DeviceName + $Success = $T | ? { $_.Status -eq 'Success' } | Select DeviceName + write-host "Error Count: $($err.count)" -foregroundcolor Yellow + write-host "InProgress: $($S.DeviceName.count)" -foregroundcolor Cyan + write-host "Success: $($Success.DeviceName.count)" -foregroundcolor Green + + #> + + <# + $T = Get-SCCMSoftwareUpdateStatus -DeploymentID 16777539 # _11PM - Production Patching - File Servers + $S = $T | ? { $_.Status -eq "InProgress" } + $S.DeviceName.count + write-host "" + write-host "------------------------------------------------------------------------------------" + write-host "_11PM - Production Patching - File Servers" -foregroundcolor white -backgroundcolor black + write-host "Total Servers: $($S.DeviceName.count)" -foregroundcolor Black -Backgroundcolor white + $Err = $T | ? { $_.Status -eq 'error' } | Select DeviceName + $Success = $T | ? { $_.Status -eq 'Success' } | Select DeviceName + write-host "Error Count: $($err.count)" -foregroundcolor Yellow + write-host "InProgress: $($S.DeviceName.count)" -foregroundcolor Cyan + write-host "Success: $($Success.DeviceName.count)" -foregroundcolor Green + + #> + + + # + # Test-Connection -ComputerName $s.DeviceName -Count 1 + # gwmi win32_operatingsystem -ComputerName $s.devicename | select @{n="Server";e={$_.PSComputername}},@{n="LastBootup";e={$_.Converttodatetime($_.LastBootUpTime)}} | sort LastBootup -descending | ft -autosize + + + # gwmi win32_operatingsystem -ComputerName PVST002 | select @{n="Server";e={$_.PSComputername}},@{n="LastBootup";e={$_.Converttodatetime($_.LastBootUpTime)}} | ft -autosize diff --git a/dump/Q and A - Remote software center - Concept Preview.URL b/dump/Q and A - Remote software center - Concept Preview.URL new file mode 100644 index 0000000..3575cbf --- /dev/null +++ b/dump/Q and A - Remote software center - Concept Preview.URL @@ -0,0 +1,6 @@ +[InternetShortcut] +URL=https://gallery.technet.microsoft.com/systemcenter/Remote-software-center-044e3514/view/Discussions#content +IDList= +HotKey=0 +IconFile=C:\Users\nnazmat\AppData\Local\Mozilla\Firefox\Profiles\20v5hisb.default-release\shortcutCache\2y5eSHQr6ejNZZQJXZyJKg==.ico +IconIndex=0 diff --git a/dump/RPC2.PS1 b/dump/RPC2.PS1 new file mode 100644 index 0000000..744c131 --- /dev/null +++ b/dump/RPC2.PS1 @@ -0,0 +1,184 @@ +# Author: Ryan Ries [MSFT] +# Updated By: Abdulrehman Altaf +# Origianl date: 15 Feb. 2014 +# updated date: 27 September 2018 +#Requires -Version 3 +Function Test-RPC +{ + [CmdletBinding(SupportsShouldProcess=$True)] + Param([Parameter(ValueFromPipeline=$True)][String[]]$ComputerName = 'localhost') + BEGIN + { + Set-StrictMode -Version Latest + $PInvokeCode = @' + using System; + using System.Collections.Generic; + using System.Runtime.InteropServices; + + public class Rpc + { + // I found this crud in RpcDce.h + + [DllImport("Rpcrt4.dll", CharSet = CharSet.Auto)] + public static extern int RpcBindingFromStringBinding(string StringBinding, out IntPtr Binding); + + [DllImport("Rpcrt4.dll")] + public static extern int RpcBindingFree(ref IntPtr Binding); + + [DllImport("Rpcrt4.dll", CharSet = CharSet.Auto)] + public static extern int RpcMgmtEpEltInqBegin(IntPtr EpBinding, + int InquiryType, // 0x00000000 = RPC_C_EP_ALL_ELTS + int IfId, + int VersOption, + string ObjectUuid, + out IntPtr InquiryContext); + + [DllImport("Rpcrt4.dll", CharSet = CharSet.Auto)] + public static extern int RpcMgmtEpEltInqNext(IntPtr InquiryContext, + out RPC_IF_ID IfId, + out IntPtr Binding, + out Guid ObjectUuid, + out IntPtr Annotation); + + [DllImport("Rpcrt4.dll", CharSet = CharSet.Auto)] + public static extern int RpcBindingToStringBinding(IntPtr Binding, out IntPtr StringBinding); + + public struct RPC_IF_ID + { + public Guid Uuid; + public ushort VersMajor; + public ushort VersMinor; + } + + public static List QueryEPM(string host) + { + List ports = new List(); + int retCode = 0; // RPC_S_OK + IntPtr bindingHandle = IntPtr.Zero; + IntPtr inquiryContext = IntPtr.Zero; + IntPtr elementBindingHandle = IntPtr.Zero; + RPC_IF_ID elementIfId; + Guid elementUuid; + IntPtr elementAnnotation; + + try + { + retCode = RpcBindingFromStringBinding("ncacn_ip_tcp:" + host, out bindingHandle); + if (retCode != 0) + throw new Exception("RpcBindingFromStringBinding: " + retCode); + + retCode = RpcMgmtEpEltInqBegin(bindingHandle, 0, 0, 0, string.Empty, out inquiryContext); + if (retCode != 0) + throw new Exception("RpcMgmtEpEltInqBegin: " + retCode); + + do + { + IntPtr bindString = IntPtr.Zero; + retCode = RpcMgmtEpEltInqNext (inquiryContext, out elementIfId, out elementBindingHandle, out elementUuid, out elementAnnotation); + if (retCode != 0) + if (retCode == 1772) + break; + + retCode = RpcBindingToStringBinding(elementBindingHandle, out bindString); + if (retCode != 0) + throw new Exception("RpcBindingToStringBinding: " + retCode); + + string s = Marshal.PtrToStringAuto(bindString).Trim().ToLower(); + if(s.StartsWith("ncacn_ip_tcp:")) + ports.Add(int.Parse(s.Split('[')[1].Split(']')[0])); + + RpcBindingFree(ref elementBindingHandle); + + } + while (retCode != 1772); // RPC_X_NO_MORE_ENTRIES + + } + catch(Exception ex) + { + Console.WriteLine(ex); + return ports; + } + finally + { + RpcBindingFree(ref bindingHandle); + } + + return ports; + } + } +'@ + } + PROCESS + { + ForEach($Computer In $ComputerName) + { + If($PSCmdlet.ShouldProcess($Computer)) + { + [Bool]$EPMOpen = $False + $Socket = New-Object Net.Sockets.TcpClient + + Try + { + $Socket.Connect($Computer, 135) + If ($Socket.Connected) + { + $EPMOpen = $True + } + $Socket.Close() + } + Catch + { + $Socket.Dispose() + } + + If ($EPMOpen) + { + Add-Type $PInvokeCode + $RPCPorts = [Rpc]::QueryEPM($Computer) + [Bool]$AllPortsOpen = $True + Foreach ($Port In $RPCPorts) + { + $Socket = New-Object Net.Sockets.TcpClient + Try + { + $Socket.Connect($Computer, $Port) + If (!$Socket.Connected) + { + $AllPortsOpen = $False + } + $Socket.Close() + } + Catch + { + $AllPortsOpen = $False + $Socket.Dispose() + } + } + + #[PSObject]@{'ComputerName' = $Computer; 'EndPointMapperOpen' = $EPMOpen; 'RPCPortsInUse' = $RPCPorts; 'AllRPCPortsOpen' = $AllPortsOpen} + + Write-Host "open RPC ports on $Computer are:" -BackgroundColor Green -ForegroundColor Black + Write-Host "------------------Summary------------------" + [PSObject]@{'ComputerName' = $Computer; 'EndPointMapperOpen' = $EPMOpen; 'AllRPCPortsOpen' = $AllPortsOpen; 'RPCPortsInUse' = $RPCPorts;} + Write-Host "------------------Port Detail------------------" + + foreach ($all_rpc_prots in $RPCPorts){ + [PSObject]@{'RPCPortsInUse' = $all_rpc_prots;'AllRPCPortsOpen' = $AllPortsOpen; } + + + } + } + Else + { + [PSObject]@{'ComputerName' = $Computer; 'EndPointMapperOpen' = $EPMOpen} + } + } + } + } + END + { + + } +} + +Test-RPC 10.162.98.80 \ No newline at end of file diff --git a/dump/Reboot-Notification-Dialog.ps1 b/dump/Reboot-Notification-Dialog.ps1 new file mode 100644 index 0000000..90c8058 --- /dev/null +++ b/dump/Reboot-Notification-Dialog.ps1 @@ -0,0 +1,12 @@ +$computer = "dfnp002" +$namespace = "ROOT\ccm\Policy\Machine\ActualConfig" +$classname = "CCM_RebootSettings" + +Write-Output "=====================================" +Write-Output "COMPUTER : $computer " +Write-Output "CLASS : $classname " +Write-Output "=====================================" + +Get-WmiObject -Class $classname -ComputerName $computer -Namespace $namespace | + Select-Object * -ExcludeProperty PSComputerName, Scope, Path, Options, ClassPath, Properties, SystemProperties, Qualifiers, Site, Container | + Format-List -Property [a-z]* diff --git a/dump/Remote Software Center.ps1 b/dump/Remote Software Center.ps1 new file mode 100644 index 0000000..c14f245 --- /dev/null +++ b/dump/Remote Software Center.ps1 @@ -0,0 +1,1648 @@ +#------------------------------------------------------------------------ +# Source File Information (DO NOT MODIFY) +# Source ID: f5f77db1-ba0b-4c5a-80b7-afa0e33b688d +# Source File: Remote Software Center.psproj +#------------------------------------------------------------------------ +#region Project Recovery Data (DO NOT MODIFY) +<#RecoveryData: +/gEAAB+LCAAAAAAABACFkU9PwyAYh+9L9h0I966tc7YHxkGXmh38k3XxaqB9cSiFBuiWfXvRtssW +Nd54wu99fnmBbKAye7DHFfOMTicIkWdr3qHy3xDwBayTRtOrWULiEYa7QipYr6hYiCyreRpxlvDo +ulqwKE94FjHBEpjP+U2e1yQewsPo0LI9tkCD+BxHuVF1qEPxeZsbYEB020lVL3GCaemZ9V07a53r +u/5KonLHLITj1naA0QYEWNAVFJ2ufFhuidd6bz4guleGM/XauhTT/uyCPf3H/ouv3JlD9MCkLoxt +gk9gOlIQigthD/2ap2fp6cnKN6mZ+go8sgboBhrjAZVG+ENYCd2B9mCDsg1jJP6Rn05IfPHfn1/a +p1b+AQAA#> +#endregion +<# + .NOTES + -------------------------------------------------------------------------------- + Code generated by: SAPIEN Technologies, Inc., PowerShell Studio 2016 v5.3.131 + Generated on: 2017-01-18 13:57 + Generated by: Timmy + -------------------------------------------------------------------------------- + .DESCRIPTION + Script generated by PowerShell Studio 2016 +#> + + +#region Source: Startup.pss +#region File Recovery Data (DO NOT MODIFY) +<#RecoveryData: +2gMAAB+LCAAAAAAABAC9k0tLAzEQgO+C/yH0vGR33a5rIbsglV4EFVfUazadLcE8yiRpyb+3rVJF +QaGHMJd5MPMxL/YIwm4A4w33nOwUJ61pJxe0nHTnZ4Swe5QrabhaSAV3XEPXe44+rOnaOZb/ih5y +rp0DPSgJ7mB/eWKnnbCo5JCR50/WlBZ7ycg8KB8QWgPBI1cZeQi7GuIW4pN9A9MOTcNrUV+Ws2oK +xdWM5ceqPyl9dB50CgZ9kWZpt44uLGqXhLjfVBoQ8q00q1NYRTXWYzOW5bIueMX/Z71qlaSnuUVI +MzyJILzF2ANupICTbuPvMR7Nj0dj+fdf7t4BtbYVHtoDAAA=#> +#endregion +#---------------------------------------------- +#region Import Assemblies +#---------------------------------------------- +[void][Reflection.Assembly]::Load('System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') +[void][Reflection.Assembly]::Load('System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') +[void][Reflection.Assembly]::Load('System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') +[void][Reflection.Assembly]::Load('System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') +#endregion Import Assemblies + +#Define a Param block to use custom parameters in the project +#Param ($CustomParameter) + +function Main { +<# + .SYNOPSIS + The Main function starts the project application. + + .PARAMETER Commandline + $Commandline contains the complete argument string passed to the script packager executable. + + .NOTES + Use this function to initialize your script and to call GUI forms. + + .NOTES + To get the console output in the Packager (Forms Engine) use: + $ConsoleOutput (Type: System.Collections.ArrayList) +#> + Param ([String]$Commandline) + + #-------------------------------------------------------------------------- + #TODO: Add initialization script here (Load modules and check requirements) + + + #-------------------------------------------------------------------------- + + if((Show-MainForm_psf) -eq 'OK') + { + + } + + $script:ExitCode = 0 #Set the exit code for the Packager +} + + + + + + + +#endregion Source: Startup.pss + +#region Source: Globals.ps1 + #-------------------------------------------- + # Declare Global Variables and Functions here + #-------------------------------------------- + + + #Sample function that provides the location of the script + function Get-ScriptDirectory + { + <# + .SYNOPSIS + Get-ScriptDirectory returns the proper location of the script. + + .OUTPUTS + System.String + + .NOTES + Returns the correct path within a packaged executable. + #> + [OutputType([string])] + param () + if ($null -ne $hostinvocation) + { + Split-Path $hostinvocation.MyCommand.path + } + else + { + Split-Path $script:MyInvocation.MyCommand.Path + } + } + + #Sample variable that provides the location of the script + [string]$ScriptDirectory = Get-ScriptDirectory + + function Write-Status + { + [cmdletbinding()] + param + ( + [Parameter(Mandatory)] + [ValidateNotNull()] + [String]$Message + + ) + $statusbar1.Text = $Message + } + + function Invoke-OSDInstall + { + Param + ( + [String][Parameter(Mandatory = $True, Position = 1)] + $Computername, + [String][Parameter(Mandatory = $True, Position = 2)] + $OSDName + + ) + Begin + { + + $CIMClass = (Get-CimClass -Namespace root\ccm\clientsdk -ComputerName $Computername -ClassName CCM_ProgramsManager) + $OSD = (Get-CimInstance -ClassName CCM_Program -Namespace "root\ccm\clientSDK" -ComputerName $Computername | Where-Object { $_.Name -like "$OSDName" }) + + $Args = @{ + PackageID = $OSD.PackageID + ProgramID = $OSD.ProgramID + } + } + + Process + { + + Invoke-CimMethod -CimClass $CIMClass -ComputerName $Computername -MethodName "ExecuteProgram" –Arguments $Args + + } + End { } + } + + Function Invoke-AppInstall + { + + Param + ( + [String][Parameter(Mandatory = $True, Position = 1)] + $Computername, + [String][Parameter(Mandatory = $True, Position = 2)] + $AppName, + [ValidateSet("Install", "Uninstall")] + [String][Parameter(Mandatory = $True, Position = 3)] + $Method + ) + + Begin + { + $Application = (Get-CimInstance -ClassName CCM_Application -Namespace "root\ccm\clientSDK" -ComputerName $Computername | Where-Object { $_.Name -like $AppName }) + + $Args = @{ + EnforcePreference = [UINT32] 0 + Id = "$($Application.id)" + IsMachineTarget = $Application.IsMachineTarget + IsRebootIfNeeded = $False + Priority = 'High' + Revision = "$($Application.Revision)" + } + + } + + Process + { + + Invoke-CimMethod -Namespace "root\ccm\clientSDK" -ClassName CCM_Application -ComputerName $Computername -MethodName $Method -Arguments $Args + + } + + End { } + + } + + function Invoke-SupInstall + { + Param + ( + [String][Parameter(Mandatory = $True, Position = 1)] + $Computername, + [String][Parameter(Mandatory = $True, Position = 2)] + $SupName + + ) + Begin + { + $AppEvalState0 = "0" + $AppEvalState1 = "1" + $ApplicationClass = [WmiClass]"root\ccm\clientSDK:CCM_SoftwareUpdatesManager" + } + + Process + { + If ($SupName -Like "All" -or $SupName -like "all") + { + Foreach ($Computer in $Computername) + { + $Application = (Get-WmiObject -Namespace "root\ccm\clientSDK" -Class CCM_SoftwareUpdate -ComputerName $Computer | Where-Object { $_.EvaluationState -like "*$($AppEvalState0)*" -or $_.EvaluationState -like "*$($AppEvalState1)*" }) + Invoke-WmiMethod -Class CCM_SoftwareUpdatesManager -Name InstallUpdates -ArgumentList ( ,$Application) -Namespace root\ccm\clientsdk -ComputerName $Computer + + } + + } + Else + { + Foreach ($Computer in $Computername) + { + $Application = (Get-WmiObject -Namespace "root\ccm\clientSDK" -Class CCM_SoftwareUpdate -ComputerName $Computer | Where-Object { $_.EvaluationState -like "*$($AppEvalState)*" -and $_.Name -like "*$($SupName)*" }) + Invoke-WmiMethod -Class CCM_SoftwareUpdatesManager -Name InstallUpdates -ArgumentList ( ,$Application) -Namespace root\ccm\clientsdk -ComputerName $Computer + + } + + } + } + End { } + } +#endregion Source: Globals.ps1 + +#region Source: MainForm.psf +function Show-MainForm_psf +{ +#region File Recovery Data (DO NOT MODIFY) +<#RecoveryData: +pTcAAB+LCAAAAAAABADVW1tzokwTvrfK/0B58d7ECuIhMfUmVg2IOXwxUVFzuEkhjiwrgi9g0Pz6 +r4eDHASFbMzuZqtieg7dT3c/M92QzeUAS/o7NjZt0RIp+MFUdO2qVD1lSq1igaIuHw1FVjRR7Sgq +fhAXuNUVFa2jG4vTpTm7pHem3U2Tn1iyKGuzxFclYWNaeHH6pGhT3TZPyV73e5lKmipTYw9F/bRC +/pUpbqVaKwNfaXhlGaJapnqriapI/8OboT7H2tXk/FxsSI0z5qJWx5XmRYnSAMpVaQb6CNwSJf1Q +1KkBS0ucrlmGrpque4C1Z+hLbFgbbw9aWbogiSpuKwusERyw9KxMMbVL2l96aGtXn+JSqwOWDu7h +VAVrlqB8wIb6eaNM1c6Zg5tIoEst37uDywVLNKyebioWeFNqcWAQG4JkYHx47xCvrVJrgBe6hSlB +n1m2aGDKVbG7mX+HCW8nSSan6iaeBlDfgsFL2lmctPNeF8N7iBhbfZhf7MqydO3oDJs4Zm410xJV +VRj19jEtgTCa9EM3Si1WBy1wHO7xbJcxu9vudUl0U1k7q5apavUiwyaXM3G8GTa63CTUrO4egQTC +iJNbbYrXpRZzlmW5w69/xMXyXw8VlQ0W2Xi7EGU8wKoXDUdkMRAHk9kMSkYmHivmSlQFa6NiVpTm +nK6SjAyNFU7aH6YpHF1pvhvSN2c8RljaZWx2/nL6YqKz+vroDJaIoYm+zk1eAkS0LEWTeU2cqOSY +p0Utlb8Mk4++IbCZmVurNMHI7qW6l7qN3bstdwrvxQlWj54/lVjxL+bRcipa2Mx5C5Gy5YQqY/5I +YSu1uopk6CYYpgRRMykBG8qsTF0srTJlktN0xerqND8bmCyZctmQ5HpmWjBVCHpCnvfSop75RtuW +yjRc+fn0O0oaWi5/R0ljGuefK2mA96glLdPy3ZKWDdafWdIA+19a0lDvN5W0PPQNgT1uSaseSr6A +VcggnjobuB+iJpMAhPC9Ja34VVZ8Y5UEJsNaJ09/c4lkatkbph2/M3Os2chfHjMx0rkd90L6o0n0 +KLSHojkX8H8rrEn4b+VRvUydJ94I6TSKeZ6906o181OpkplKAIsiuKh9wBKKXJJPf2mhAy9+T6G7 +yJKmaJ0DrEetc4l3Y/YyB/COUuYES7RWJisaRyeF6ViaiAaTjxNBZsF4rZ69xgQGMyfWedNZzXL/ +BIltfkGd6CkSiel3nM2lawoolTMPkZYdrvslPEUmvEg+lMBq9qMZgpo5g1WSwCxdbpDAjKsFS1+W +Wh1RNXfvo7/joTn3dfzJh2bn4fBeMa1AMywa4Bk2SDHzVilklQqr3FCwK3ODNBh0qELRgfbcT+k5 +bv94fI75kJ69dYg8o2dD9Wc+o5Oq9SWtC3HgO25HC+zAfQOd0nJlYYMMfu7IDPWle17K1ECRf+S7 +J5laxsbUJXEC6OxNMENamUzU3E/kMBVItrYdTAK6t9CCKDNiiiBfbd3WkpV4k79KrW+9iYFAGuD5 +BU59gk0N8kY5+0NVBOlR31rmuxCzI/q6e8yz+TWX2LcyjV8rn6SZX+3zM82pvnk6vADqMXmW/bcj +vEO0bHC+jmTE/4MMiwoZKqaywMd/qLOIlTt9Ak8E0hwb2/+8EqkGjquxlW/DmLt5/ds2mUf3cW+j +6juc1AILloHFRejAsYomGpsWQjxCqE2TL9RH/lcXyfC9Mx3i54fK61NlNa6qq9fri5q0aVxPaneW +tLHl8WK8karq++RnpXL/E62KhS5Xt+85tj19Wlemz3dq76mhTp8Hm5cn27ztsMzLYr18qVgqHg/e +xep41Xu6rT1UeeblY1TtDucfD9cj+7E97xAkxQLiXvfYb9xNnjra62i9lGqD4fTmTn15YlRJJv4g +fnDdqbz0Jc7xA83boI34aXfhO1vlyOicGQ60Piv0O+Atz3IkEhOZRei6DvZZnsgDBPKQRgIPnz9p +NLplh32+WiywNmIfZNAmyG0IFEIgdyFsqE9W8jIrg9xrItpu0+jAJ2CDn1YywJNvaPQxYmm7y6BZ +05G7yBtnyPgj54+bMP7Qh3GwTBO/YJzIkAWYkWOaxjAjo2QLtymaUPOWLRZo+2FMRhyNMEKvIXbk +09Pgr/TXObJjwZEhiI8CGZ/LBJuzsgYaXAyOLYS8HZs0za7XgWZH7pOcuisdDS76rVfxeKFGoEn2 +5RAS0BbG8gEzzCiKhcjrFOxk3LXgeFsszP141VK8+vDHD8fXi9t2Joioq0k+YMH1ehzkdDvT46Ka ++uHxSkp8bYSCXAO2INu2n23Hm/oWK4z3gkwEFuy4BcI330Zi1rea5CCnqRacnG5nAk29XU3M7vh8 +a8GNBuFbYIP3T5OTmX5ipEMZEOJx9nLq6L4YpcSnH450apwb7jndF+mLfoqFkOxqtN1zWo/xicib +CDv4rJkg2Ha9hGvSjUc9iNs8wBKN4ybgq3tO417EcxW29OpbakQzQe7JYiEpHqaf20Y0Lg/hnJ/3 +d86Ql9PIKTqp5DsTJ7I/XiyM/cjveBlgYhN5GDvXaXGbhzFME+qGHGPHPJbTJMYmesuHLd2FMUew +STAz7u9i4GM7wqcwHhX37u2m7JAi9dQ9XUTuJJ9nwcWWfENemIfullgG7egdksbYh5SKHK/sLrax +N5N0mtKi0E2wUCz4NpIy0N1zipIsuH3I4Y4myEB3z6kLndOana+eJtS6eD2NaWJSajzRFL8XwQev +nib1F2ndwh4LgC3edwSnKM4zOdxdxePmYQv3QGlYMnYPfs1K7ArklLqZ2Iv6d0jM5tmeyCdF5TzA +7p6FQ70PvQaYbhd/Qnr4XkoPT84pz7LwHCDDZwd6c7rOw/ImSyOeRjOb7dlD7/OmiYbNNm3ftImM +7BvQ2I3IoK3vj0Am7B6NpC6JD5HZJvFyRuJ4YxP5pB+V4/PFQnwkQYPmWnAssg37nkZmINtElhDB +dgLYRt7MO6xEvI+aRljiaNc7x+vA+zo7C7w/Qc9N3l8HOfVW2ojXiA1YoSHakdtIuoWdYIkmUbgh +UXCjgiXWdi2CzPcIxrbt8K0PNu3rmT/iysGKbDLspwk2zyaM3DveJssOZmBBl9vGi3jtxCvIOWAb +Bn4Trzn76uqS9h6s/dcm8d/Oxd/1BL++PPgLzehrCWSaeDFRFWz6qr2RTWthSrqhKpMvePFwSW+1 +xq24rzq+w8aXv045bJH8qdf3GDJEW9Hkz9iq1GaN2fmMYaaNilgTD9t6Xqjf4hOnG/jrDW1Fl/KX +dPjP8lr/Bzk7bJalNwAA#> +#endregion + #---------------------------------------------- + #region Import the Assemblies + #---------------------------------------------- + [void][reflection.assembly]::Load('System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') + [void][reflection.assembly]::Load('System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') + [void][reflection.assembly]::Load('System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') + #endregion Import Assemblies + + #---------------------------------------------- + #region Generated Form Objects + #---------------------------------------------- + [System.Windows.Forms.Application]::EnableVisualStyles() + $formMain = New-Object 'System.Windows.Forms.Form' + $buttonInstallSUP = New-Object 'System.Windows.Forms.Button' + $comboboxSUP = New-Object 'System.Windows.Forms.ComboBox' + $labelSoftwareUpdates = New-Object 'System.Windows.Forms.Label' + $buttonInstallApp = New-Object 'System.Windows.Forms.Button' + $comboboxAPP = New-Object 'System.Windows.Forms.ComboBox' + $labelApplications = New-Object 'System.Windows.Forms.Label' + $labelOSDTaskSequence = New-Object 'System.Windows.Forms.Label' + $comboboxOSD = New-Object 'System.Windows.Forms.ComboBox' + $statusbar1 = New-Object 'System.Windows.Forms.StatusBar' + $picturebox1 = New-Object 'System.Windows.Forms.PictureBox' + $buttonInstallOSD = New-Object 'System.Windows.Forms.Button' + $textboxComputername = New-Object 'System.Windows.Forms.TextBox' + $buttonConnect = New-Object 'System.Windows.Forms.Button' + $buttonExit = New-Object 'System.Windows.Forms.Button' + $timerJobTracker = New-Object 'System.Windows.Forms.Timer' + $imagelistButtonBusyAnimation = New-Object 'System.Windows.Forms.ImageList' + $InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState' + #endregion Generated Form Objects + + #---------------------------------------------- + # User Generated Script + #---------------------------------------------- + + #region Control Helper Functions + function Load-ComboBox + { + <# + .SYNOPSIS + This functions helps you load items into a ComboBox. + + .DESCRIPTION + Use this function to dynamically load items into the ComboBox control. + + .PARAMETER ComboBox + The ComboBox control you want to add items to. + + .PARAMETER Items + The object or objects you wish to load into the ComboBox's Items collection. + + .PARAMETER DisplayMember + Indicates the property to display for the items in this control. + + .PARAMETER Append + Adds the item(s) to the ComboBox without clearing the Items collection. + + .EXAMPLE + Load-ComboBox $combobox1 "Red", "White", "Blue" + + .EXAMPLE + Load-ComboBox $combobox1 "Red" -Append + Load-ComboBox $combobox1 "White" -Append + Load-ComboBox $combobox1 "Blue" -Append + + .EXAMPLE + Load-ComboBox $combobox1 (Get-Process) "ProcessName" + #> + Param ( + [ValidateNotNull()] + [Parameter(Mandatory=$true)] + [System.Windows.Forms.ComboBox]$ComboBox, + [ValidateNotNull()] + [Parameter(Mandatory=$true)] + $Items, + [Parameter(Mandatory=$false)] + [string]$DisplayMember, + [switch]$Append + ) + + if(-not $Append) + { + $ComboBox.Items.Clear() + } + + if($Items -is [Object[]]) + { + $ComboBox.Items.AddRange($Items) + } + elseif ($Items -is [System.Collections.IEnumerable]) + { + $ComboBox.BeginUpdate() + foreach($obj in $Items) + { + $ComboBox.Items.Add($obj) + } + $ComboBox.EndUpdate() + } + else + { + $ComboBox.Items.Add($Items) + } + + $ComboBox.DisplayMember = $DisplayMember + } + + function Load-ListBox + { + <# + .SYNOPSIS + This functions helps you load items into a ListBox or CheckedListBox. + + .DESCRIPTION + Use this function to dynamically load items into the ListBox control. + + .PARAMETER ListBox + The ListBox control you want to add items to. + + .PARAMETER Items + The object or objects you wish to load into the ListBox's Items collection. + + .PARAMETER DisplayMember + Indicates the property to display for the items in this control. + + .PARAMETER Append + Adds the item(s) to the ListBox without clearing the Items collection. + + .EXAMPLE + Load-ListBox $ListBox1 "Red", "White", "Blue" + + .EXAMPLE + Load-ListBox $listBox1 "Red" -Append + Load-ListBox $listBox1 "White" -Append + Load-ListBox $listBox1 "Blue" -Append + + .EXAMPLE + Load-ListBox $listBox1 (Get-Process) "ProcessName" + #> + Param ( + [ValidateNotNull()] + [Parameter(Mandatory=$true)] + [System.Windows.Forms.ListBox]$ListBox, + [ValidateNotNull()] + [Parameter(Mandatory=$true)] + $Items, + [Parameter(Mandatory=$false)] + [string]$DisplayMember, + [switch]$Append + ) + + if(-not $Append) + { + $listBox.Items.Clear() + } + + if($Items -is [System.Windows.Forms.ListBox+ObjectCollection]) + { + $listBox.Items.AddRange($Items) + } + elseif ($Items -is [Array]) + { + $listBox.BeginUpdate() + foreach($obj in $Items) + { + $listBox.Items.Add($obj) + } + $listBox.EndUpdate() + } + else + { + $listBox.Items.Add($Items) + } + + $listBox.DisplayMember = $DisplayMember + } + + function Load-DataGridView + { + <# + .SYNOPSIS + This functions helps you load items into a DataGridView. + + .DESCRIPTION + Use this function to dynamically load items into the DataGridView control. + + .PARAMETER DataGridView + The DataGridView control you want to add items to. + + .PARAMETER Item + The object or objects you wish to load into the DataGridView's items collection. + + .PARAMETER DataMember + Sets the name of the list or table in the data source for which the DataGridView is displaying data. + + .PARAMETER AutoSizeColumns + Resizes DataGridView control's columns after loading the items. + #> + Param ( + [ValidateNotNull()] + [Parameter(Mandatory = $true)] + [System.Windows.Forms.DataGridView]$DataGridView, + [ValidateNotNull()] + [Parameter(Mandatory = $true)] + $Item, + [Parameter(Mandatory = $false)] + [string]$DataMember, + [System.Windows.Forms.DataGridViewAutoSizeColumnMode]$AutoSizeColumns = 'None' + ) + $DataGridView.SuspendLayout() + $DataGridView.DataMember = $DataMember + + if ($Item -is [System.Data.DataSet] -and $Item.Tables.Count -gt 0) + { + $DataGridView.DataSource = $Item.Tables[0] + } + elseif ($Item -is [System.ComponentModel.IListSource]` + -or $Item -is [System.ComponentModel.IBindingList] -or $Item -is [System.ComponentModel.IBindingListView]) + { + $DataGridView.DataSource = $Item + } + else + { + $array = New-Object System.Collections.ArrayList + + if ($Item -is [System.Collections.IList]) + { + $array.AddRange($Item) + } + else + { + $array.Add($Item) + } + $DataGridView.DataSource = $array + } + + if ($AutoSizeColumns -ne 'None') + { + $DataGridView.AutoResizeColumns($AutoSizeColumns) + } + + $DataGridView.ResumeLayout() + } + + function ConvertTo-DataTable + { + <# + .SYNOPSIS + Converts objects into a DataTable. + + .DESCRIPTION + Converts objects into a DataTable, which are used for DataBinding. + + .PARAMETER InputObject + The input to convert into a DataTable. + + .PARAMETER Table + The DataTable you wish to load the input into. + + .PARAMETER RetainColumns + This switch tells the function to keep the DataTable's existing columns. + + .PARAMETER FilterWMIProperties + This switch removes WMI properties that start with an underline. + + .EXAMPLE + $DataTable = ConvertTo-DataTable -InputObject (Get-Process) + #> + [OutputType([System.Data.DataTable])] + param ( + [ValidateNotNull()] + $InputObject, + [ValidateNotNull()] + [System.Data.DataTable]$Table, + [switch]$RetainColumns, + [switch]$FilterWMIProperties) + + if ($null -eq $Table) + { + $Table = New-Object System.Data.DataTable + } + + if ($InputObject -is [System.Data.DataTable]) + { + $Table = $InputObject + } + elseif ($InputObject -is [System.Data.DataSet] -and $InputObject.Tables.Count -gt 0) + { + $Table = $InputObject.Tables[0] + } + else + { + if (-not $RetainColumns -or $Table.Columns.Count -eq 0) + { + #Clear out the Table Contents + $Table.Clear() + + if ($null -eq $InputObject) { return } #Empty Data + + $object = $null + #find the first non null value + foreach ($item in $InputObject) + { + if ($null -ne $item) + { + $object = $item + break + } + } + + if ($null -eq $object) { return } #All null then empty + + #Get all the properties in order to create the columns + foreach ($prop in $object.PSObject.Get_Properties()) + { + if (-not $FilterWMIProperties -or -not $prop.Name.StartsWith('__')) #filter out WMI properties + { + #Get the type from the Definition string + $type = $null + + if ($null -ne $prop.Value) + { + try { $type = $prop.Value.GetType() } + catch { } + } + + if ($null -ne $type) # -and [System.Type]::GetTypeCode($type) -ne 'Object') + { + [void]$table.Columns.Add($prop.Name, $type) + } + else #Type info not found + { + [void]$table.Columns.Add($prop.Name) + } + } + } + + if ($object -is [System.Data.DataRow]) + { + foreach ($item in $InputObject) + { + $Table.Rows.Add($item) + } + return @( ,$Table) + } + } + else + { + $Table.Rows.Clear() + } + + foreach ($item in $InputObject) + { + $row = $table.NewRow() + + if ($item) + { + foreach ($prop in $item.PSObject.Get_Properties()) + { + if ($table.Columns.Contains($prop.Name)) + { + $row.Item($prop.Name) = $prop.Value + } + } + } + [void]$table.Rows.Add($row) + } + } + + return @( ,$Table) + } + #endregion + + #region Search Function + function SearchGrid() + { + $RowIndex = 0 + $ColumnIndex = 0 + $seachString = $textboxComputername.Text + + if($seachString -eq "") + { + return + } + + if($datagridviewResults.SelectedCells.Count -ne 0) + { + $startCell = $datagridviewResults.SelectedCells[0]; + $RowIndex = $startCell.RowIndex + $ColumnIndex = $startCell.ColumnIndex + 1 + } + + $columnCount = $datagridviewResults.ColumnCount + $rowCount = $datagridviewResults.RowCount + for(;$RowIndex -lt $rowCount; $RowIndex++) + { + $Row = $datagridviewResults.Rows[$RowIndex] + + for(;$ColumnIndex -lt $columnCount; $ColumnIndex++) + { + $cell = $Row.Cells[$ColumnIndex] + + if($null -ne $cell.Value -and $cell.Value.ToString().IndexOf($seachString, [StringComparison]::OrdinalIgnoreCase) -ne -1) + { + $datagridviewResults.CurrentCell = $cell + return + } + } + + $ColumnIndex = 0 + } + + $datagridviewResults.CurrentCell = $null + [void][System.Windows.Forms.MessageBox]::Show("The search has reached the end of the grid.","String not Found") + + } + #endregion + + $formMain_Load={ + #TODO: Initialize Form Controls here + + } + + $buttonExit_Click={ + #TODO: Place custom script here + $formMain.Close() + } + + $buttonConnect_Click={ + #TODO: Place custom script here + try + { + $Empty = "" + Load-ComboBox $comboboxOSD $Empty + $comboboxOSD.SelectedIndex = 0 + Load-ComboBox $comboboxAPP $Empty + $comboboxAPP.SelectedIndex = 0 + Load-ComboBox $comboboxSUP $Empty + $comboboxSUP.SelectedIndex = 0 + if (-not $textboxComputername.Text) + { + [System.Windows.Forms.MessageBox]::Show('No computer specified', 'Error') + Throw 'No Computer specified' + } + else + { + $global:Computername = $textboxComputername.Text + } + + Write-Status -Message "Connecting to $computername" + $picturebox1.BackColor = "Gold" + + If (-not (Test-Connection -ComputerName $Computername -Count 1 -Quiet)) + { + $picturebox1.BackColor = "Red" + + + [System.Windows.Forms.MessageBox]::Show('No such computer or computer is offline', 'Error') + Throw 'No such computer or computer is offline' + + } + + Else + { + Write-status -Message "Connected to $Computername" + $picturebox1.BackColor = "Green" + + # OSD Task Sequence # + $OSDTS = (Get-CimInstance -ClassName CCM_Program -Namespace "root\ccm\clientSDK" -ComputerName $Computername | Where-Object { $_.TaskSequence -like "True" }) + $OSD = $OSDTS.Name + + + # Application # + $Application = (Get-CimInstance -ClassName CCM_Application -Namespace "root\ccm\clientSDK" -ComputerName $Computername | Where-Object { $_.InstallState -like "NotInstalled" }) + $AppName = $Application.Name + + # Software Updates # + $SUPEvalState0 = "0" + $SUPEvalState1 = "1" + $SUPClass = [WmiClass]"root\ccm\clientSDK:CCM_SoftwareUpdatesManager" + $SUPs = (Get-WmiObject -Namespace "root\ccm\clientSDK" -Class CCM_SoftwareUpdate -ComputerName $Computername | Where-Object { $_.EvaluationState -like "*$($SUPEvalState0)*" -or $_.EvaluationState -like "*$($SUPEvalState1)*" }) + $SUPName = $SUPs.Name + + if ($OSD) + { + Load-ComboBox $comboboxOSD $OSD -Append + $comboboxOSD.SelectedIndex = 1 + } + if ($APPName) + { + Load-ComboBox $comboboxAPP $AppName -Append + $comboboxAPP.SelectedIndex = 1 + } + if ($SUPName) + { + Load-ComboBox $comboboxSUP $SUPName -Append + $comboboxSUP.SelectedIndex = 1 + } + + + } #Else + } #IF + Catch + { + Write-Status -Message $_.Exception.Message + } + + + } + + + + $formMain_FormClosed=[System.Windows.Forms.FormClosedEventHandler]{ + #Event Argument: $_ = [System.Windows.Forms.FormClosedEventArgs] + #Stop any pending jobs + Stop-JobTracker + } + + $timerJobTracker_Tick={ + Update-JobTracker + } + + #region Job Tracker + $JobTrackerList = New-Object System.Collections.ArrayList + function Add-JobTracker + { + <# + .SYNOPSIS + Add a new job to the JobTracker and starts the timer. + + .DESCRIPTION + Add a new job to the JobTracker and starts the timer. + + .PARAMETER Name + The name to assign to the Job + + .PARAMETER JobScript + The script block that the Job will be performing. + Important: Do not access form controls from this script block. + + .PARAMETER ArgumentList + The arguments to pass to the job + + .PARAMETER CompleteScript + The script block that will be called when the job is complete. + The job is passed as an argument. The Job argument is null when the job fails. + + .PARAMETER UpdateScript + The script block that will be called each time the timer ticks. + The job is passed as an argument. Use this to get the Job's progress. + + .EXAMPLE + Add-JobTracker -Name 'JobName' ` + -JobScript { + Param($Argument1)#Pass any arguments using the ArgumentList parameter + #Important: Do not access form controls from this script block. + Get-WmiObject Win32_Process -Namespace "root\CIMV2" + }` + -CompletedScript { + Param($Job) + $results = Receive-Job -Job $Job + }` + -UpdateScript { + Param($Job) + #$results = Receive-Job -Job $Job -Keep + } + + .LINK + + #> + + Param( + [ValidateNotNull()] + [Parameter(Mandatory=$true)] + [string]$Name, + [ValidateNotNull()] + [Parameter(Mandatory=$true)] + [ScriptBlock]$JobScript, + $ArgumentList = $null, + [ScriptBlock]$CompletedScript, + [ScriptBlock]$UpdateScript) + + #Start the Job + $job = Start-Job -Name $Name -ScriptBlock $JobScript -ArgumentList $ArgumentList + + if($null -ne $job) + { + #Create a Custom Object to keep track of the Job & Script Blocks + $members = @{ 'Job' = $Job; + 'CompleteScript' = $CompletedScript; + 'UpdateScript' = $UpdateScript} + + $psObject = New-Object System.Management.Automation.PSObject -Property $members + + [void]$JobTrackerList.Add($psObject) + + #Start the Timer + if(-not $timerJobTracker.Enabled) + { + $timerJobTracker.Start() + } + } + elseif($null -ne $CompletedScript) + { + #Failed + Invoke-Command -ScriptBlock $CompletedScript -ArgumentList $null + } + + } + + function Update-JobTracker + { + <# + .SYNOPSIS + Checks the status of each job on the list. + #> + + #Poll the jobs for status updates + $timerJobTracker.Stop() #Freeze the Timer + + for($index =0; $index -lt $JobTrackerList.Count; $index++) + { + $psObject = $JobTrackerList[$index] + + if($null -ne $psObject) + { + if($null -ne $psObject.Job) + { + if($psObject.Job.State -ne "Running") + { + #Call the Complete Script Block + if($null -ne $psObject.CompleteScript) + { + #$results = Receive-Job -Job $psObject.Job + Invoke-Command -ScriptBlock $psObject.CompleteScript -ArgumentList $psObject.Job + } + + $JobTrackerList.RemoveAt($index) + Remove-Job -Job $psObject.Job + $index-- #Step back so we don't skip a job + } + elseif($null -ne $psObject.UpdateScript) + { + #Call the Update Script Block + Invoke-Command -ScriptBlock $psObject.UpdateScript -ArgumentList $psObject.Job + } + } + } + else + { + $JobTrackerList.RemoveAt($index) + $index-- #Step back so we don't skip a job + } + } + + if($JobTrackerList.Count -gt 0) + { + $timerJobTracker.Start()#Resume the timer + } + } + + function Stop-JobTracker + { + <# + .SYNOPSIS + Stops and removes all Jobs from the list. + #> + #Stop the timer + $timerJobTracker.Stop() + + #Remove all the jobs + while($JobTrackerList.Count -gt 0) + { + $job = $JobTrackerList[0].Job + $JobTrackerList.RemoveAt(0) + Stop-Job $job + Remove-Job $job + } + } + #endregion + + + $textboxComputername_KeyDown=[System.Windows.Forms.KeyEventHandler]{ + #Event Argument: $_ = [System.Windows.Forms.KeyEventArgs] + if($_.KeyCode -eq 'Enter' -and $buttonConnect.Enabled) + { + #SearchGrid + try + { + $Empty = "" + Load-ComboBox $comboboxOSD $Empty + $comboboxOSD.SelectedIndex = 0 + Load-ComboBox $comboboxAPP $Empty + $comboboxAPP.SelectedIndex = 0 + Load-ComboBox $comboboxSUP $Empty + $comboboxSUP.SelectedIndex = 0 + if (-not $textboxComputername.Text) + { + [System.Windows.Forms.MessageBox]::Show('No computer specified', 'Error') + Throw 'No Computer specified' + } + else + { + $global:Computername = $textboxComputername.Text + } + + Write-Status -Message "Connecting to $computername" + $picturebox1.BackColor = "Gold" + + If (-not (Test-Connection -ComputerName $Computername -Count 1 -Quiet)) + { + $picturebox1.BackColor = "Red" + + + [System.Windows.Forms.MessageBox]::Show('No such Computer or computer is offline', 'Error') + Throw 'No such Computer or computer is offline' + + } + + Else + { + Write-status -Message "Connected to $Computername" + $picturebox1.BackColor = "Green" + + # OSD Task Sequence # + $OSDTS = (Get-CimInstance -ClassName CCM_Program -Namespace "root\ccm\clientSDK" -ComputerName $Computername | Where-Object { $_.TaskSequence -like "True" }) + $OSD = $OSDTS.Name + + + # Application # + $Application = (Get-CimInstance -ClassName CCM_Application -Namespace "root\ccm\clientSDK" -ComputerName $Computername | Where-Object { $_.InstallState -like "NotInstalled" }) + $AppName = $Application.Name + + # Software Updates # + $SUPEvalState0 = "0" + $SUPEvalState1 = "1" + $SUPClass = [WmiClass]"root\ccm\clientSDK:CCM_SoftwareUpdatesManager" + $SUPs = (Get-WmiObject -Namespace "root\ccm\clientSDK" -Class CCM_SoftwareUpdate -ComputerName $Computername | Where-Object { $_.EvaluationState -like "*$($SUPEvalState0)*" -or $_.EvaluationState -like "*$($SUPEvalState1)*" }) + $SUPName = $SUPs.Name + + if ($OSD) + { + Load-ComboBox $comboboxOSD $OSD -Append + $comboboxOSD.SelectedIndex = 1 + } + if ($APPName) + { + Load-ComboBox $comboboxAPP $AppName -Append + $comboboxAPP.SelectedIndex = 1 + } + if ($SUPName) + { + Load-ComboBox $comboboxSUP $SUPName -Append + $comboboxSUP.SelectedIndex = 1 + } + + + } #Else + } #IF + Catch + { + Write-Status -Message $_.Exception.Message + } + + $_.SuppressKeyPress = $true + } + } + + $textboxComputername_TextChanged={ + #TODO: Place custom script here + + } + + $statusbar1_PanelClick=[System.Windows.Forms.StatusBarPanelClickEventHandler]{ + #Event Argument: $_ = [System.Windows.Forms.StatusBarPanelClickEventArgs] + #TODO: Place custom script here + + } + + $toolstripstatuslabel1_Click={ + #TODO: Place custom script here + + } + + + $comboboxOSD_SelectedIndexChanged={ + #TODO: Place custom script here + + } + + $labelOSDTaskSequence_Click={ + #TODO: Place custom script here + + } + + $comboboxAPP_SelectedIndexChanged={ + #TODO: Place custom script here + + } + + $buttonInstallOSD_Click={ + #TODO: Place custom script here + Invoke-OSDInstall -Computername $Computername -OSDName $comboboxOSD.SelectedItem + } + + $buttonInstallApp_Click={ + #TODO: Place custom script here + Invoke-AppInstall -Computername $Computername -Method Install -AppName $comboboxAPP.SelectedItem + } + + $buttonInstallSUP_Click={ + #TODO: Place custom script here + Invoke-SupInstall -Computername $Computername -SupName $comboboxSUP.SelectedItem + } + + $buttonCancelProcess_Click={ + $script:CancelLoop = $true + } + + $buttonStartProcess_Click={ + #Init CancelLoop + $script:CancelLoop = $false + $buttonCancelProcess.Enabled = $true + #Disable the button so we don't trigger it again + $this.Enabled = $false + #Reset the Progress Bar + $progressbar1.Value = 0 + + for($i = 0; $i -lt $progressbar1.Maximum; $i++) + { + #---------------------------------------- + #Place custom script here + sleep -Milliseconds 200 + + #---------------------------------------- + #process the pending message + [System.Windows.Forms.Application]::DoEvents() + + if($script:CancelLoop -eq $true) + { + #Clear the progress bar + $progressbar1.Value = 0 + #Exit the loop + break; + } + #Step the progress bar + $progressbar1.PerformStep() + } + + #Enable the button so we can click it again + $this.Enabled = $true + $buttonCancelProcess.Enabled = $false + } + + $buttonRunProcess_Click={ + $buttonRunProcess.Enabled = $false + #TODO: Set the process path there + Add-ProcessTracker -FilePath "$env:windir/System32/notepad.exe" ` + -CompletedScript { + $buttonRunProcess.Enabled = $true + $buttonRunProcess.ImageIndex = -1 + }` + -UpdateScript { + #Animate the Button + if($null -ne $buttonRunProcess.ImageList) + { + if($buttonRunProcess.ImageIndex -lt $buttonRunProcess.ImageList.Images.Count - 1) + { + $buttonRunProcess.ImageIndex += 1 + } + else + { + $buttonRunProcess.ImageIndex = 0 + } + } + } + } + + $processTracker_FormClosed=[System.Windows.Forms.FormClosedEventHandler]{ + #Event Argument: $_ = [System.Windows.Forms.FormClosedEventArgs] + #Stop any pending processes + #Stop-ProcessTracker + } + + $timerProcessTracker_Tick={ + Update-ProcessTracker + } + + #region Process Tracker + $ProcessTrackerList = New-Object System.Collections.ArrayList + function Add-ProcessTracker + { + <# + .SYNOPSIS + Add a new process to the ProcessTracker and starts the timer. + + .DESCRIPTION + Add a new process to the ProcessTracker and starts the timer. + + .PARAMETER FilePath + The path to executable. + + .PARAMETER ArgumentList + The arguments to pass to the process. + + .PARAMETER CompleteScript + The script block that will be called when the process is complete. + The process is passed as an argument. The process argument is null when the job fails. + + .PARAMETER UpdateScript + The script block that will be called each time the timer ticks. + The process is passed as an argument. + + .EXAMPLE + Add-ProcessTracker -FilePath "$env:windir/System32/notepad.exe" ` + -CompletedScript { + Param([System.Diagnostics.Process]$Process) + $button.Enable = $true + }` + -UpdateScript { + Param([System.Diagnostics.Process]$Process) + Function-Animate $button + } + + .LINK + + #> + + Param( + [ValidateNotNull()] + [Parameter(Mandatory=$true)] + [string]$FilePath, + $ArgumentList = $null, + [ScriptBlock]$CompletedScript, + [ScriptBlock]$UpdateScript) + + #Start the Job + if($ArgumentList) + { + $process = Start-Process -FilePath $FilePath -ArgumentList $ArgumentList -PassThru + } + else + { + $process = Start-Process -FilePath $FilePath -PassThru + } + + if($null -ne $process) + { + #Create a Custom Object to keep track of the Job & Script Blocks + $members = @{ "Process" = $process; + "CompleteScript" = $CompletedScript; + "UpdateScript" = $UpdateScript} + + $psObject = New-Object System.Management.Automation.PSObject -Property $members + + [void]$ProcessTrackerList.Add($psObject) + + #Start the Timer + if(-not $timerProcessTracker.Enabled) + { + $timerProcessTracker.Start() + } + } + elseif($null -ne $CompletedScript) + { + #Failed + Invoke-Command -ScriptBlock $CompletedScript -ArgumentList $null + } + + } + + function Update-ProcessTracker + { + <# + .SYNOPSIS + Checks the status of each job on the list. + #> + + #Poll the jobs for status updates + $timerProcessTracker.Stop() #Freeze the Timer + + for($index =0; $index -lt $ProcessTrackerList.Count; $index++) + { + $psObject = $ProcessTrackerList[$index] + + if($null -ne $psObject) + { + if($null -ne $psObject.Process) + { + if($psObject.Process.HasExited) + { + #Call the Complete Script Block + if($null -ne $psObject.CompleteScript) + { + #$results = Receive-Job -Job $psObject.Job + Invoke-Command -ScriptBlock $psObject.CompleteScript -ArgumentList $psObject.Process + } + + $ProcessTrackerList.RemoveAt($index) + $index-- #Step back so we don't skip a job + } + elseif($null -ne $psObject.UpdateScript) + { + #Call the Update Script Block + Invoke-Command -ScriptBlock $psObject.UpdateScript -ArgumentList $psObject.Process + } + } + } + else + { + $ProcessTrackerList.RemoveAt($index) + $index-- #Step back so we don't skip a job + } + } + + if($ProcessTrackerList.Count -gt 0) + { + $timerProcessTracker.Start()#Resume the timer + } + } + + function Stop-ProcessTracker + { + <# + .SYNOPSIS + Stops and removes all processes from the list. + #> + #Stop the timer + $timerProcessTracker.Stop() + + #Remove all the processes + while($ProcessTrackerList.Count -gt 0) + { + $process = $ProcessTrackerList[0].Process + $ProcessTrackerList.RemoveAt(0) + if(-not $psObject.Process.HasExited) + { + Stop-Process -InputObject $process + } + } + } + #endregion + # --End User Generated Script-- + #---------------------------------------------- + #region Generated Events + #---------------------------------------------- + + $Form_StateCorrection_Load= + { + #Correct the initial state of the form to prevent the .Net maximized form issue + $formMain.WindowState = $InitialFormWindowState + } + + $Form_StoreValues_Closing= + { + #Store the control values + $script:MainForm_comboboxSUP = $comboboxSUP.Text + $script:MainForm_comboboxSUP_SelectedItem = $comboboxSUP.SelectedItem + $script:MainForm_comboboxAPP = $comboboxAPP.Text + $script:MainForm_comboboxAPP_SelectedItem = $comboboxAPP.SelectedItem + $script:MainForm_comboboxOSD = $comboboxOSD.Text + $script:MainForm_comboboxOSD_SelectedItem = $comboboxOSD.SelectedItem + $script:MainForm_textboxComputername = $textboxComputername.Text + } + + + $Form_Cleanup_FormClosed= + { + #Remove all event handlers from the controls + try + { + $buttonInstallSUP.remove_Click($buttonInstallSUP_Click) + $buttonInstallApp.remove_Click($buttonInstallApp_Click) + $comboboxAPP.remove_SelectedIndexChanged($comboboxAPP_SelectedIndexChanged) + $labelOSDTaskSequence.remove_Click($labelOSDTaskSequence_Click) + $comboboxOSD.remove_SelectedIndexChanged($comboboxOSD_SelectedIndexChanged) + $buttonInstallOSD.remove_Click($buttonInstallOSD_Click) + $textboxComputername.remove_TextChanged($textboxComputername_TextChanged) + $textboxComputername.remove_KeyDown($textboxComputername_KeyDown) + $buttonConnect.remove_Click($buttonConnect_Click) + $buttonExit.remove_Click($buttonExit_Click) + $formMain.remove_FormClosed($formMain_FormClosed) + $formMain.remove_Load($formMain_Load) + $timerJobTracker.remove_Tick($timerJobTracker_Tick) + $formMain.remove_Load($Form_StateCorrection_Load) + $formMain.remove_Closing($Form_StoreValues_Closing) + $formMain.remove_FormClosed($Form_Cleanup_FormClosed) + } + catch { Out-Null <# Prevent PSScriptAnalyzer warning #> } + } + #endregion Generated Events + + #---------------------------------------------- + #region Generated Form Code + #---------------------------------------------- + $formMain.SuspendLayout() + # + # formMain + # + $formMain.Controls.Add($buttonInstallSUP) + $formMain.Controls.Add($comboboxSUP) + $formMain.Controls.Add($labelSoftwareUpdates) + $formMain.Controls.Add($buttonInstallApp) + $formMain.Controls.Add($comboboxAPP) + $formMain.Controls.Add($labelApplications) + $formMain.Controls.Add($labelOSDTaskSequence) + $formMain.Controls.Add($comboboxOSD) + $formMain.Controls.Add($statusbar1) + $formMain.Controls.Add($picturebox1) + $formMain.Controls.Add($buttonInstallOSD) + $formMain.Controls.Add($textboxComputername) + $formMain.Controls.Add($buttonConnect) + $formMain.Controls.Add($buttonExit) + $formMain.AutoScaleDimensions = '6, 13' + $formMain.AutoScaleMode = 'Font' + $formMain.ClientSize = '475, 371' + $formMain.Name = 'formMain' + $formMain.StartPosition = 'CenterScreen' + $formMain.Text = 'Remote Software Center' + $formMain.add_FormClosed($formMain_FormClosed) + $formMain.add_Load($formMain_Load) + # + # buttonInstallSUP + # + $buttonInstallSUP.Anchor = 'Bottom, Left' + $buttonInstallSUP.Location = '362, 229' + $buttonInstallSUP.Name = 'buttonInstallSUP' + $buttonInstallSUP.Size = '75, 23' + $buttonInstallSUP.TabIndex = 16 + $buttonInstallSUP.Text = '&Install SUP' + $buttonInstallSUP.TextImageRelation = 'ImageBeforeText' + $buttonInstallSUP.UseVisualStyleBackColor = $True + $buttonInstallSUP.add_Click($buttonInstallSUP_Click) + # + # comboboxSUP + # + $comboboxSUP.FormattingEnabled = $True + $comboboxSUP.Location = '11, 229' + $comboboxSUP.Name = 'comboboxSUP' + $comboboxSUP.Size = '308, 21' + $comboboxSUP.TabIndex = 15 + # + # labelSoftwareUpdates + # + $labelSoftwareUpdates.AutoSize = $True + $labelSoftwareUpdates.Font = 'Microsoft Sans Serif, 9pt, style=Bold' + $labelSoftwareUpdates.Location = '11, 211' + $labelSoftwareUpdates.Name = 'labelSoftwareUpdates' + $labelSoftwareUpdates.Size = '120, 15' + $labelSoftwareUpdates.TabIndex = 14 + $labelSoftwareUpdates.Text = 'Software Updates' + # + # buttonInstallApp + # + $buttonInstallApp.Anchor = 'Bottom, Left' + $buttonInstallApp.Location = '362, 157' + $buttonInstallApp.Name = 'buttonInstallApp' + $buttonInstallApp.Size = '75, 23' + $buttonInstallApp.TabIndex = 13 + $buttonInstallApp.Text = '&Install App' + $buttonInstallApp.TextImageRelation = 'ImageBeforeText' + $buttonInstallApp.UseVisualStyleBackColor = $True + $buttonInstallApp.add_Click($buttonInstallApp_Click) + # + # comboboxAPP + # + $comboboxAPP.FormattingEnabled = $True + $comboboxAPP.Location = '11, 157' + $comboboxAPP.Name = 'comboboxAPP' + $comboboxAPP.Size = '308, 21' + $comboboxAPP.TabIndex = 12 + $comboboxAPP.add_SelectedIndexChanged($comboboxAPP_SelectedIndexChanged) + # + # labelApplications + # + $labelApplications.AutoSize = $True + $labelApplications.Font = 'Microsoft Sans Serif, 9pt, style=Bold' + $labelApplications.Location = '11, 139' + $labelApplications.Name = 'labelApplications' + $labelApplications.Size = '85, 15' + $labelApplications.TabIndex = 11 + $labelApplications.Text = 'Applications' + # + # labelOSDTaskSequence + # + $labelOSDTaskSequence.AutoSize = $True + $labelOSDTaskSequence.Font = 'Microsoft Sans Serif, 9pt, style=Bold' + $labelOSDTaskSequence.Location = '14, 72' + $labelOSDTaskSequence.Name = 'labelOSDTaskSequence' + $labelOSDTaskSequence.Size = '138, 15' + $labelOSDTaskSequence.TabIndex = 10 + $labelOSDTaskSequence.Text = 'OSD Task Sequence' + $labelOSDTaskSequence.add_Click($labelOSDTaskSequence_Click) + # + # comboboxOSD + # + $comboboxOSD.FormattingEnabled = $True + $comboboxOSD.Location = '11, 90' + $comboboxOSD.Name = 'comboboxOSD' + $comboboxOSD.Size = '308, 21' + $comboboxOSD.TabIndex = 9 + $comboboxOSD.add_SelectedIndexChanged($comboboxOSD_SelectedIndexChanged) + # + # statusbar1 + # + $statusbar1.Location = '0, 349' + $statusbar1.Name = 'statusbar1' + $statusbar1.Size = '475, 22' + $statusbar1.TabIndex = 8 + # + # picturebox1 + # + $picturebox1.BackColor = 'Transparent' + $picturebox1.Location = '0, 320' + $picturebox1.Name = 'picturebox1' + $picturebox1.Size = '25, 27' + $picturebox1.TabIndex = 7 + $picturebox1.TabStop = $False + # + # buttonInstallOSD + # + $buttonInstallOSD.Anchor = 'Bottom, Left' + $buttonInstallOSD.ImageList = $imagelistButtonBusyAnimation + $buttonInstallOSD.Location = '362, 90' + $buttonInstallOSD.Name = 'buttonInstallOSD' + $buttonInstallOSD.Size = '75, 23' + $buttonInstallOSD.TabIndex = 0 + $buttonInstallOSD.Text = '&Install OSD' + $buttonInstallOSD.TextImageRelation = 'ImageBeforeText' + $buttonInstallOSD.UseVisualStyleBackColor = $True + $buttonInstallOSD.add_Click($buttonInstallOSD_Click) + # + # textboxComputername + # + $textboxComputername.Anchor = 'Top, Left, Right' + $textboxComputername.Location = '13, 15' + $textboxComputername.Name = 'textboxComputername' + $textboxComputername.Size = '118, 20' + $textboxComputername.TabIndex = 0 + $textboxComputername.add_TextChanged($textboxComputername_TextChanged) + $textboxComputername.add_KeyDown($textboxComputername_KeyDown) + # + # buttonConnect + # + $buttonConnect.Anchor = 'Top, Right' + $buttonConnect.Location = '150, 12' + $buttonConnect.Name = 'buttonConnect' + $buttonConnect.Size = '75, 23' + $buttonConnect.TabIndex = 1 + $buttonConnect.Text = '&Connect' + $buttonConnect.UseVisualStyleBackColor = $True + $buttonConnect.add_Click($buttonConnect_Click) + # + # buttonExit + # + $buttonExit.Anchor = 'Bottom, Right' + $buttonExit.Location = '362, 320' + $buttonExit.Name = 'buttonExit' + $buttonExit.Size = '75, 23' + $buttonExit.TabIndex = 4 + $buttonExit.Text = 'E&xit' + $buttonExit.UseVisualStyleBackColor = $True + $buttonExit.add_Click($buttonExit_Click) + # + # timerJobTracker + # + $timerJobTracker.add_Tick($timerJobTracker_Tick) + # + # imagelistButtonBusyAnimation + # + $Formatter_binaryFomatter = New-Object System.Runtime.Serialization.Formatters.Binary.BinaryFormatter + #region Binary Data + $System_IO_MemoryStream = New-Object System.IO.MemoryStream (,[byte[]][System.Convert]::FromBase64String(' +AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAu +MC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAA +ACZTeXN0ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkD +AAAADwMAAAB2CgAAAk1TRnQBSQFMAgEBCAEAAbgBAAG4AQABEAEAARABAAT/ASEBAAj/AUIBTQE2 +BwABNgMAASgDAAFAAwABMAMAAQEBAAEgBgABMP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/ +AP8AugADwgH/AzUB/wM1Af8DwgH/MAADwgH/A1UB/wOCAf8DwgH/sAADNQH/AwAB/wMAAf8DNQH/ +MAADggH/AzUB/wM1Af8DVQH/gAADwgH/AzUB/wM1Af8DwgH/IAADNQH/AwAB/wMAAf8DNQH/A8IB +/wNVAf8DggH/A8IB/xAAA8IB/wM1Af8DNQH/A8IB/wNVAf8DNQH/AzUB/wNVAf8EAAOSAf8DkgH/ +A8IB/3AAAzUB/wMAAf8DAAH/AzUB/yAAA8IB/wM1Af8DNQH/A8IB/wOCAf8DNQH/AzUB/wOCAf8Q +AAM1Af8DAAH/AwAB/wM1Af8DwgH/A1UB/wOCAf8DwgH/A5IB/wOCAf8DggH/A5IB/3AAAzUB/wMA +Af8DAAH/AzUB/zAAA1UB/wM1Af8DNQH/A1UB/xAAAzUB/wMAAf8DAAH/AzUB/xAAA5IB/wOSAf8D +kgH/A8IB/3AAA8IB/wM1Af8DNQH/A8IB/zAAA8IB/wNVAf8DggH/A8IB/xAAA8IB/wM1Af8DNQH/ +A8IB/xAAA8IB/wOSAf8DkgH/A8IB/zgAA8IB/wM1Af8DNQH/A8IB/zAAA8IB/wOCAf8DVQH/A8IB +/zAAA8IB/wPCAf8DkgH/A8IB/zQAA8IB/wPCAf80AAM1Af8DAAH/AwAB/wM1Af8wAANVAf8DNQH/ +AzUB/wNVAf8wAAOSAf8DggH/A4IB/wOSAf8wAAPCAf8DwgH/A8IB/wPCAf8wAAM1Af8DAAH/AwAB +/wM1Af8wAAOCAf8DNQH/AzUB/wOCAf8wAAPCAf8DggH/A5IB/wOSAf8wAAPCAf8DwgH/A8IB/wPC +Af8wAAPCAf8DNQH/AzUB/wPCAf8wAAPCAf8DggH/A1UB/wPCAf8wAAPCAf8DkgH/A5IB/wPCAf80 +AAPCAf8DwgH/EAADwgH/A8IB/xQAA8IB/wOCAf8DVQH/A8IB/zAAA8IB/wOSAf8DkgH/A8IB/zQA +A8IB/wPCAf9UAAPCAf8DwgH/A8IB/wPCAf8QAANVAf8DNQH/AzUB/wNVAf8wAAOSAf8DggH/A5IB +/wOSAf8wAAPCAf8DwgH/A8IB/wPCAf9QAAPCAf8DwgH/A8IB/wPCAf8DwgH/A8IB/wOSAf8DwgH/ +A4IB/wM1Af8DNQH/A4IB/yQAA8IB/wPCAf8EAAPCAf8DggH/A5IB/wOSAf8wAAPCAf8DwgH/A8IB +/wPCAf9UAAPCAf8DwgH/BAADkgH/A4IB/wOCAf8DkgH/A8IB/wOCAf8DVQH/A8IB/yAAA8IB/wPC +Af8DwgH/A8IB/wPCAf8DkgH/A5IB/wPCAf80AAPCAf8DwgH/ZAADkgH/A5IB/wOSAf8DkgH/MAAD +wgH/A8IB/wPCAf8DwgH/sAADwgH/A5IB/wOSAf8DwgH/NAADwgH/A8IB/7QAA8IB/wPCAf8DkgH/ +A8IB/zQAA8IB/wPCAf+0AAOSAf8DggH/A4IB/wOSAf8wAAPCAf8DwgH/A8IB/wPCAf+gAAPCAf8D +VQH/A4IB/wPCAf8DkgH/A5IB/wOSAf8DwgH/BAADwgH/A8IB/xQAA8IB/wPCAf8DkgH/A8IB/wPC +Af8DwgH/A8IB/wPCAf8kAAPCAf8DwgH/dAADggH/AzUB/wM1Af8DggH/A8IB/wOSAf8DkgH/A8IB +/wPCAf8DwgH/A8IB/wPCAf8QAAOSAf8DggH/A4IB/wOSAf8EAAPCAf8DwgH/JAADwgH/A8IB/wPC +Af8DwgH/cAADVQH/AzUB/wM1Af8DggH/EAADwgH/A8IB/wPCAf8DwgH/EAADkgH/A5IB/wOSAf8D +kgH/MAADwgH/A8IB/wPCAf8DwgH/cAADwgH/A1UB/wNVAf8DwgH/FAADwgH/A8IB/xQAA8IB/wOS +Af8DkgH/A8IB/zQAA8IB/wPCAf9sAAPCAf8DNQH/AzUB/wPCAf8wAAPCAf8DVQH/A4IB/wPCAf8w +AAPCAf8DwgH/A5IB/wPCAf80AAPCAf8DwgH/NAADNQH/AwAB/wMAAf8DNQH/MAADggH/AzUB/wM1 +Af8DVQH/MAADkgH/A4IB/wOCAf8DkgH/MAADwgH/A8IB/wPCAf8DwgH/MAADNQH/AwAB/wMAAf8D +NQH/MAADVQH/AzUB/wM1Af8DggH/MAADkgH/A5IB/wOSAf8DkgH/MAADwgH/A8IB/wPCAf8DwgH/ +MAADwgH/AzUB/wM1Af8DwgH/MAADwgH/A1UB/wNVAf8DwgH/MAADwgH/A5IB/wOSAf8DwgH/NAAD +wgH/A8IB/3wAA8IB/wM1Af8DNQH/A8IB/zAAA8IB/wNVAf8DggH/A8IB/zAAA8IB/wPCAf8DkgH/ +A8IB/xAAA8IB/wM1Af8DNQH/A8IB/1AAAzUB/wMAAf8DAAH/AzUB/zAAA4IB/wM1Af8DNQH/A1UB +/zAAA5IB/wOCAf8DggH/A5IB/xAAAzUB/wMAAf8DAAH/AzUB/1AAAzUB/wMAAf8DAAH/AzUB/zAA +A1UB/wM1Af8DNQH/A4IB/wOSAf8DNQH/AzUB/wPCAf8gAAOSAf8DkgH/A5IB/wOSAf8DwgH/A1UB +/wOCAf8DwgH/AzUB/wMAAf8DAAH/AzUB/1AAA8IB/wM1Af8DNQH/A8IB/zAAA8IB/wOCAf8DVQH/ +A8IB/wM1Af8DAAH/AwAB/wM1Af8gAAPCAf8DkgH/A5IB/wPCAf8DggH/AzUB/wM1Af8DVQH/A8IB +/wM1Af8DNQH/A8IB/6AAAzUB/wMAAf8DAAH/AzUB/zAAA1UB/wM1Af8DNQH/A4IB/7AAA8IB/wM1 +Af8DNQH/A8IB/zAAA8IB/wOCAf8DVQH/A8IB/xgAAUIBTQE+BwABPgMAASgDAAFAAwABMAMAAQEB +AAEBBQABgAEBFgAD/4EABP8B/AE/AfwBPwT/AfwBPwH8AT8D/wHDAfwBAwHAASMD/wHDAfwBAwHA +AQMD/wHDAf8DwwP/AcMB/wPDAf8B8AH/AfAB/wHwAf8B+QH/AfAB/wHwAf8B8AH/AfAB/wHwAf8B +8AH/AfAB/wHwAf8B8AH/AfAB/wHwAf8B+QHnAcMB/wHDAf8B5wL/AsMB/wHDAf8BwwL/AcABAwH+ +AUMB/wHDAv8B5AEDAfwBAwH/AecC/wH8AT8B/AE/BP8B/AE/Af4BfwT/AfwBPwH+AX8E/wH8AT8B +/AE/BP8BwAEnAcABPwHnA/8BwAEDAcIBfwHDA/8DwwH/AcMD/wHDAecBwwH/AecD/wEPAf8BDwH/ +AQ8B/wGfAf8BDwH/AQ8B/wEPAf8BDwH/AQ8B/wEPAf8BDwH/AQ8B/wEPAf8BDwH/AQ8B/wGfA/8B +wwH/AcMB/wLDAv8BwwH/AcMB/wLDAv8BwwH/AcABPwHAAQMC/wHDAf8BwAE/AcABAwT/AfwBPwH8 +AT8E/wH8AT8B/AE/Cw==')) + #endregion + $imagelistButtonBusyAnimation.ImageStream = $Formatter_binaryFomatter.Deserialize($System_IO_MemoryStream) + $Formatter_binaryFomatter = $null + $System_IO_MemoryStream = $null + $imagelistButtonBusyAnimation.TransparentColor = 'Transparent' + $formMain.ResumeLayout() + #endregion Generated Form Code + + #---------------------------------------------- + + #Save the initial state of the form + $InitialFormWindowState = $formMain.WindowState + #Init the OnLoad event to correct the initial state of the form + $formMain.add_Load($Form_StateCorrection_Load) + #Clean up the control events + $formMain.add_FormClosed($Form_Cleanup_FormClosed) + #Store the control values when form is closing + $formMain.add_Closing($Form_StoreValues_Closing) + #Show the Form + return $formMain.ShowDialog() + +} +#endregion Source: MainForm.psf + +#Start the application +Main ($CommandLine) diff --git a/dump/Remotely Restart-SCCMSyncCycle Using Powershell.website b/dump/Remotely Restart-SCCMSyncCycle Using Powershell.website new file mode 100644 index 0000000..1697574 --- /dev/null +++ b/dump/Remotely Restart-SCCMSyncCycle Using Powershell.website @@ -0,0 +1,13 @@ +[{000214A0-0000-0000-C000-000000000046}] +Prop3=19,11 +Prop4=31,Remotely Restart-SCCMSyncCycle Using Powershell +[InternetShortcut] +IDList= +URL=https://thesysadminchannel.com/remotely-restart-sccmsynccycle-using-powershell/ +IconFile=https://thesysadminchannel.com/wp-content/uploads/2018/03/favicon.png +IconIndex=1 +[{A7AF692E-098D-4C08-A225-D433CA835ED0}] +Prop5=3,0 +Prop9=19,0 +[{9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3}] +Prop5=8,Microsoft.Website.16B02C56.2527D155 diff --git a/dump/Remotely Restart-SCCMSyncCycle.ps1 b/dump/Remotely Restart-SCCMSyncCycle.ps1 new file mode 100644 index 0000000..601e178 --- /dev/null +++ b/dump/Remotely Restart-SCCMSyncCycle.ps1 @@ -0,0 +1,129 @@ +Function Restart-SCCMSyncCycle { +<# +.Synopsis + Remotely restarts sccm service cycles. + + +.DESCRIPTION + This function restarts all sccm policies on a remote client so that the client can immediately get any pending software updates or inventory. + + +.NOTES + Name: Restart-SCCMSyncCycle + Author: theSysadminChannel + Version: 1 + DateCreated: 2017-02-09 + + +.LINK + https://thesysadminchannel.com/remotely-restart-sccmsynccycle-using-powershell - + + +.PARAMETER ComputerName + The computer to which connectivity will be checked + + +.EXAMPLE + Restart-SCCMSyncCycle -Computername Pactest-1 + + Description: + Will restart all sccm services on a remote machine. + +.EXAMPLE + Restart-SCCMSyncCycle -ComputerName pactest-1, pactest-2, pactest-3 + + Description: + Will generate a list of installed programs on pactest-1, pactest-2 and pactest-3 + +#> + + + [CmdletBinding()] + param( + [Parameter( + ValueFromPipeline=$true, + ValueFromPipelineByPropertyName=$true, + Position=0)] + [string[]] $ComputerName = $env:COMPUTERNAME + + ) + + Foreach ($Computer in $ComputerName ) { + try { + + Write-Host "=====================================================================" + Write-Output "$Computer : Machine Policy Evaluation Cycle" + Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000022}" -ErrorAction Stop | select -ExpandProperty PSComputerName | Out-Null + + + Write-Output "$Computer : Application Deployment Evaluation Cycle" + Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000121}" | select -ExpandProperty PSComputerName | Out-Null + + + # Write-Output "$Computer : Discovery Data Collection Cycle" + # Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000003}" | select -ExpandProperty PSComputerName | Out-Null + + + # Write-Output "$Computer : File Collection Cycle" + # Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000010}" | select -ExpandProperty PSComputerName | Out-Null + + + # Write-Output "$Computer : Hardware Inventory Cycle" + # Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000001}" | select -ExpandProperty PSComputerName | Out-Null + + + Write-Output "$Computer : Machine Policy Retrieval Cycle" + Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000021}" | select -ExpandProperty PSComputerName | Out-Null + + + Write-Output "$Computer : Software Inventory Cycle" + Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000002}" | select -ExpandProperty PSComputerName | Out-Null + + + # Write-Output "$Computer : Software Metering Usage Report Cycle" + # Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000031}" | select -ExpandProperty PSComputerName | Out-Null + + + Write-Output "$Computer : Software Update Deployment Evaluation Cycle" + Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000114}" | select -ExpandProperty PSComputerName | Out-Null + + + #Write-Output "$Computer : Software Update Scan Cycle" + #Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000113}" | select -ExpandProperty PSComputerName | Out-Null + + + # Write-Output "$Computer : State Message Refresh" + # Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000111}" | select -ExpandProperty PSComputerName | Out-Null + + + #Write-Output "$Computer : User Policy Retrieval Cycle" + #Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000026}" | select -ExpandProperty PSComputerName | Out-Null + + + #Write-Output "$Computer : User Policy Evaluation Cycle" + #Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000027}" | select -ExpandProperty PSComputerName | Out-Null + + + # Write-Output "$Computer : Windows Installers Source List Update Cycle" + # Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000032}" | select -ExpandProperty PSComputerName | Out-Null + + sleep 1 + } + + catch { + Write-Host $Computer.toUpper() "is not online or Account is locked out" -ForegroundColor:Red + Write-Host + Write-Host + + } + } +} + + +# Restart-SCCMSyncCycle pver001 +# Restart-SCCMSyncCycle + +# Restart-SCCMSyncCycle $DeviceCollection_ServerNames.name + +# Restart-SCCMSyncCycle $Script:ALL_Patch_Servers.Server + diff --git a/dump/SCCM Deployment Dashboard - PowerBI Version.URL b/dump/SCCM Deployment Dashboard - PowerBI Version.URL new file mode 100644 index 0000000..818b3d1 --- /dev/null +++ b/dump/SCCM Deployment Dashboard - PowerBI Version.URL @@ -0,0 +1,6 @@ +[InternetShortcut] +URL=https://gallery.technet.microsoft.com/systemcenter/SCCM-Deployment-Dashboard-f2b395f5 +IDList= +HotKey=0 +IconFile=C:\Users\nnazmat\AppData\Local\Mozilla\Firefox\Profiles\20v5hisb.default-release\shortcutCache\wiVy1vvHEfWoHxaKfKs0sQ==.ico +IconIndex=0 diff --git a/dump/SCCM Deployment Dashboard.pbix b/dump/SCCM Deployment Dashboard.pbix new file mode 100644 index 0000000..3ab2319 Binary files /dev/null and b/dump/SCCM Deployment Dashboard.pbix differ diff --git a/dump/SCCM-Logs-Description.txt b/dump/SCCM-Logs-Description.txt new file mode 100644 index 0000000..63b16dc --- /dev/null +++ b/dump/SCCM-Logs-Description.txt @@ -0,0 +1,44 @@ +Software Updates Client Computer Log Files + +* CAS.log - Provides information about the process of downloading software updates to the local cache and cache management. + +* CIAgent.log - Provides information about processing configuration items, including software updates. + +* LocationServices.log - Provides information about the location of the WSUS server when a scan is initiated on the client. + +* PatchDownloader.log - Provides information about the process for downloading software updates from the update source to the download destination on the site server. This log is only on the client computer configured as the synchronization host for the Inventory Tool for Microsoft Updates. + +* PolicyAgent.log - Provides information about the process for downloading, compiling, and deleting policies on client computers. + +* PolicyEvaluator - Provides information about the process for evaluating policies on client computers, including policies from software updates. + +* RebootCoordinator.log - Provides information about the process for coordinating system restarts on client computers after software update installations. + +* ScanAgent.log - Provides information about the scan requests for software updates, what tool is requested for the scan, the WSUS location, and so on. + +* ScanWrapper - Provides information about the prerequisite checks and the scan process initialization for the Inventory Tool for Microsoft Updates on Systems Management Server (SMS) 2003 clients. + +* SdmAgent.log - Provides information about the process for verifying and decompressing packages that contain configuration item information for software updates. + +* ServiceWindowManager.log - Provides information about the process for evaluating configured maintenance windows. + +* smscliUI.log - Provides information about the Configuration Manager Control Panel user interactions, such as initiating a Software Updates Scan Cycle from the Configuration Manager Properties dialog box, opening the Program Download Monitor, and so on. + +* SmsWusHandler - Provides information about the scan process for the Inventory Tool for Microsoft Updates on SMS 2003 client computers. + +* StateMessage.log - Provides information about when software updates state messages are created and sent to the management point. + +* UpdatesDeployment.log - Provides information about the deployment on the client, including software update activation, evaluation, and enforcement. Verbose logging shows additional information about the interaction with the client user interface. + +* UpdatesHandler.log - Provides information about software update compliance scanning and about the download and installation of software updates on the client. + +* UpdatesStore.log - Provides information about the compliance status for the software updates that were assessed during the compliance scan cycle. + +* WUAHandler.log - Provides information about when the Windows Update Agent on the client searches for software updates. + +* WUSSyncXML.log - Provides information about the Inventory Tool for the Microsoft Updates synchronization process. This log is only on the client computer configured as the synchronization host for the Inventory Tool for Microsoft Updates. + +* Windows Update Agent Log File + + +* WindowsUpdate.log - Provides information about when the Windows Update Agent connects to the WSUS server and retrieves the software updates for compliance assessment and whether there are updates to the agent components. \ No newline at end of file diff --git a/dump/SCCM-Powershell.txt b/dump/SCCM-Powershell.txt new file mode 100644 index 0000000..fd08935 --- /dev/null +++ b/dump/SCCM-Powershell.txt @@ -0,0 +1,11 @@ + + Right-click the Windows PowerShell icon and choose "Run as administrator". + Type CD 'C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin' and hit enter. + Type Import-Module .\ConfigurationManager.psd1 and run it. + Here's the crucial missing step. Enter New-PSDrive -Name [yoursitecode] -PSProvider "AdminUI.PS.Provider\CMSite" -Root "[your SCCM server's FQDN]" -Description "SCCM Site" + Now we can connect to the site. Enter CD ABC:, where ABC is your site code. The colon is necessary! + + +============================================================================================================================================= +Import-Module 'C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1' +New-PSDrive -Name SCCM-Drive -PSProvider "AdminUI.PS.Provider\CMSite" -Root "PNCRASCCM001.ccx.carecentrix.com" -Description "SCCM Site" diff --git a/dump/SCCM-Reports.txt b/dump/SCCM-Reports.txt new file mode 100644 index 0000000..12533b2 --- /dev/null +++ b/dump/SCCM-Reports.txt @@ -0,0 +1,8 @@ +Report Names: + +- States 5 - States for an update in a deployment(secondary) +- States 4 - Computers in a specific state for a deployment(secondary) +- Software 02D - Computers with specific software installed +- Software 01A - Summary of installed software in a specific collection +- IP - All subnets by subnet mask +- \ No newline at end of file diff --git a/dump/SCCM-Tool/Current-Collection-Servers.csv b/dump/SCCM-Tool/Current-Collection-Servers.csv new file mode 100644 index 0000000..a295f3b --- /dev/null +++ b/dump/SCCM-Tool/Current-Collection-Servers.csv @@ -0,0 +1,3 @@ +"Server","ClientInstalled","CollectionName" +"W2012A","True","Nabil - Test Collection" +"W2012B","True","Nabil - Test Collection" diff --git a/dump/SCCM-Tool/Forms/Combobox.ps1 b/dump/SCCM-Tool/Forms/Combobox.ps1 new file mode 100644 index 0000000..c785442 Binary files /dev/null and b/dump/SCCM-Tool/Forms/Combobox.ps1 differ diff --git a/dump/SCCM-Tool/Forms/Datagrid.ps1 b/dump/SCCM-Tool/Forms/Datagrid.ps1 new file mode 100644 index 0000000..f437e7d Binary files /dev/null and b/dump/SCCM-Tool/Forms/Datagrid.ps1 differ diff --git a/dump/SCCM-Tool/Forms/Form-Examples/Combobox-Final-2.ps1 b/dump/SCCM-Tool/Forms/Form-Examples/Combobox-Final-2.ps1 new file mode 100644 index 0000000..90f45a7 --- /dev/null +++ b/dump/SCCM-Tool/Forms/Form-Examples/Combobox-Final-2.ps1 @@ -0,0 +1,218 @@ +#------------------------------------------------------------------------ +# Source File Information (DO NOT MODIFY) +# Source ID: b24654a3-c952-4b96-8e01-c56d9800c4a7 +# Source File: FirstForm4-tabs.psf +#------------------------------------------------------------------------ +#region File Recovery Data (DO NOT MODIFY) +<#RecoveryData: +UwsAAB+LCAAAAAAABADFVl1vmzAUfZ+0/2DxzELIR9NIBKkhjVStXasl6/ZWGbhJvBo7sk0T9utn +B5Lla4VKaSokBPY5Pvf6XF/wvkPEX0BkA6ww0g+ScNazGjXX8j9/Qsi7F2RKGKZDQuEbTsAfEiHV +kIuk9UXhUNbmcuI5B6icG/6GSCGVzaFnjTKpIKn9JCzmC1kzK+R3Gx2bstFjEUyrVjeXjYKUqlRA +j0GqBKY2ekhDSqKvkI35M7Be2OngdtS+cLvNFtQvuxZiOpSeNdHruRaKZoTGQuOsgDMlOJV5ijrQ +B8HnIFRWEK5SxUcRpjAgCTAThIZe2Mhtes4aWka94zFY/lArlXICSoCpEfmjCd22TvSi1SolmV22 +/FVqpdgxLJWJRSSH0OsXrV3gbjmOizWfzLPnrGbX0HI7A56EvM+X725pZIRCvnzV1iPuUMoXAz1m ++WORwsFuHDJM4FgpwqbXDIcU4srMG53/VigaYEZ2d2+khF7ZRomMuKAkPMUO+fdMh2e0PkB7vOAf +pz0TsJ95BZ9ueYSVlrZ8t3Wpz16nAucOL00VDfiCFTY36hVo+Znd1G4FRt4U3IZro0YV/BiHNyyG +peYcQ28f9hFQfZohXuGDGWZTU9yb4J6Oze81BCfvCNX7Qz9VirN37w7hSuaNveFfHTTr3Yp1kBta +yFW2s9PWbh5+Sl5zs0p15V2+ejA/JDwSmWI6UhmFPo6eA065+E+D2zF79+VKSki0MSDX2GIk8094 +wD1ns+q+Sl5O59A4ecmWK5ofs/MICbxYdeW3a9Wbk/akM3HduF3HTVyu9SuhZ8kp4AJOL7R5zUve +c7Z/ov2/L8SajlMLAAA=#> +#endregion + +<# + .NOTES + -------------------------------------------------------------------------------- + Code generated by: SAPIEN Technologies, Inc., PowerShell Studio 2016 v5.2.124 + Generated on: 7/21/2016 3:30 PM + Generated by: administrator + -------------------------------------------------------------------------------- + .DESCRIPTION + GUI script generated by PowerShell Studio 2016 +#> +#---------------------------------------------- +#region Application Functions +#---------------------------------------------- + +#endregion Application Functions + +#---------------------------------------------- +# Generated Form Function +#---------------------------------------------- +function Call-FirstForm4-tabs_psf { + + #---------------------------------------------- + #region Import the Assemblies + #---------------------------------------------- + [void][reflection.assembly]::Load('System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') + [void][reflection.assembly]::Load('System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') + [void][reflection.assembly]::Load('System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') + #endregion Import Assemblies + + #---------------------------------------------- + #region Generated Form Objects + #---------------------------------------------- + [System.Windows.Forms.Application]::EnableVisualStyles() + $form1 = New-Object 'System.Windows.Forms.Form' + $combobox1 = New-Object 'System.Windows.Forms.ComboBox' + $button1 = New-Object 'System.Windows.Forms.Button' + $button_ComboBoxSelection = New-Object 'System.Windows.Forms.Button' + $InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState' + $TextBox_Display = New-Object 'System.Windows.Forms.TextBox' + #endregion Generated Form Objects + + #---------------------------------------------- + # User Generated Script + #---------------------------------------------- + + $combobox1_SelectedIndexChanged={ + #TODO: Place custom script here + + + } + + $form1_Load={ + #TODO: Place custom script here + + } + + $button1_Click={ + #TODO: Place custom script here + + Ba + } + + $button_ComboBoxSelection_Click={ + + $TextBox_Display.text = $Combobox1.SelectedItem + } + + $TextBox_Display_TextChanged={ + + } + + # --End User Generated Script-- + #---------------------------------------------- + #region Generated Events + #---------------------------------------------- + + $Form_StateCorrection_Load= + { + #Correct the initial state of the form to prevent the .Net maximized form issue + $form1.WindowState = $InitialFormWindowState + } + + $Form_Cleanup_FormClosed= + { + #Remove all event handlers from the controls + try + { + $combobox1.remove_SelectedIndexChanged($combobox1_SelectedIndexChanged) + $form1.remove_Load($form1_Load) + $form1.remove_Load($Form_StateCorrection_Load) + $form1.remove_FormClosed($Form_Cleanup_FormClosed) + } + catch [Exception] + { } + } + #endregion Generated Events + + #---------------------------------------------- + #region Generated Form Code + #---------------------------------------------- + $form1.SuspendLayout() + # + # form1 + # + $form1.Controls.Add($combobox1) + $form1.Controls.Add($button1) + $form1.Controls.Add($button_ComboBoxSelection) + $form1.Controls.Add($TextBox_Display) + $form1.AutoScaleDimensions = '6, 13' + $form1.AutoScaleMode = 'Font' + $form1.ClientSize = '950, 644' + $form1.Name = 'form1' + $form1.Text = 'Form' + $form1.add_Load($form1_Load) + # + # combobox1 + # + $combobox1.AllowDrop = $True + $combobox1.FormattingEnabled = $True + #$combobox1.Items.AddRange("") +<# + [void]$combobox1.Items.Add('One') + [void]$combobox1.Items.Add('Two') + [void]$combobox1.Items.Add('Three') + +#> + # + # + $TextBox_Display.Location = '278, 120' + $TextBox_Display.Name = 'VCenterUserPassword' + $TextBox_Display.Size = '132, 20' + $TextBox_Display.TabIndex = 8 + $TextBox_Display.add_TextChanged($TextBox_Display_TextChanged) + + # + $combobox1.Location = '148, 67' + #$combobox1.MaxDropDownItems = 20 + $Combobox1.Text="- Select -" + $combobox1.Name = 'combobox1' + $combobox1.Size = '121, 21' + $combobox1.TabIndex = 1 + $combobox1.add_SelectedIndexChanged($combobox1_SelectedIndexChanged) + # + # button1 + # + $button1.Location = '309, 67' + $button1.Name = 'button1' + $button1.Size = '75, 23' + $button1.TabIndex = 0 + $button1.Text = 'button1' + $button1.UseVisualStyleBackColor = $True + $form1.ResumeLayout() + $button1.add_Click($button1_Click) + #endregion Generated Form Code + # + # button_ComboBoxSelection + $button_ComboBoxSelection.Location = '309, 40' + $button_ComboBoxSelection.Name = 'button_ComboBoxSelection' + $button_ComboBoxSelection.Size = '75, 23' + $button_ComboBoxSelection.TabIndex = 1 + $button_ComboBoxSelection.Text = 'Select Item' + $button_ComboBoxSelection.add_Click($button_ComboBoxSelection_Click) + + + # + + + #---------------------------------------------- + + + #Save the initial state of the form + $InitialFormWindowState = $form1.WindowState + #Init the OnLoad event to correct the initial state of the form + $form1.add_Load($Form_StateCorrection_Load) + #Clean up the control events + $form1.add_FormClosed($Form_Cleanup_FormClosed) + #Show the Form + return $form1.ShowDialog() + +} #End Function + + +Function Ba { + +#$combobox1.Items.Add('a') + +$combobox1.Items.Clear() + +$P = Get-Process | select -ExpandProperty ProcessName + +$P | % { $combobox1.Items.Add($_) } + +} + + +#Call the form +Call-FirstForm4-tabs_psf | Out-Null diff --git a/dump/SCCM-Tool/Forms/Form-Examples/Combobox-Final.ps1 b/dump/SCCM-Tool/Forms/Form-Examples/Combobox-Final.ps1 new file mode 100644 index 0000000..9c732a6 --- /dev/null +++ b/dump/SCCM-Tool/Forms/Form-Examples/Combobox-Final.ps1 @@ -0,0 +1,222 @@ +#------------------------------------------------------------------------ +# Source File Information (DO NOT MODIFY) +# Source ID: b24654a3-c952-4b96-8e01-c56d9800c4a7 +# Source File: FirstForm4-tabs.psf +#------------------------------------------------------------------------ +#region File Recovery Data (DO NOT MODIFY) +<#RecoveryData: +UwsAAB+LCAAAAAAABADFVl1vmzAUfZ+0/2DxzELIR9NIBKkhjVStXasl6/ZWGbhJvBo7sk0T9utn +B5Lla4VKaSokBPY5Pvf6XF/wvkPEX0BkA6ww0g+ScNazGjXX8j9/Qsi7F2RKGKZDQuEbTsAfEiHV +kIuk9UXhUNbmcuI5B6icG/6GSCGVzaFnjTKpIKn9JCzmC1kzK+R3Gx2bstFjEUyrVjeXjYKUqlRA +j0GqBKY2ekhDSqKvkI35M7Be2OngdtS+cLvNFtQvuxZiOpSeNdHruRaKZoTGQuOsgDMlOJV5ijrQ +B8HnIFRWEK5SxUcRpjAgCTAThIZe2Mhtes4aWka94zFY/lArlXICSoCpEfmjCd22TvSi1SolmV22 +/FVqpdgxLJWJRSSH0OsXrV3gbjmOizWfzLPnrGbX0HI7A56EvM+X725pZIRCvnzV1iPuUMoXAz1m ++WORwsFuHDJM4FgpwqbXDIcU4srMG53/VigaYEZ2d2+khF7ZRomMuKAkPMUO+fdMh2e0PkB7vOAf +pz0TsJ95BZ9ueYSVlrZ8t3Wpz16nAucOL00VDfiCFTY36hVo+Znd1G4FRt4U3IZro0YV/BiHNyyG +peYcQ28f9hFQfZohXuGDGWZTU9yb4J6Oze81BCfvCNX7Qz9VirN37w7hSuaNveFfHTTr3Yp1kBta +yFW2s9PWbh5+Sl5zs0p15V2+ejA/JDwSmWI6UhmFPo6eA065+E+D2zF79+VKSki0MSDX2GIk8094 +wD1ns+q+Sl5O59A4ecmWK5ofs/MICbxYdeW3a9Wbk/akM3HduF3HTVyu9SuhZ8kp4AJOL7R5zUve +c7Z/ov2/L8SajlMLAAA=#> +#endregion + +<# + .NOTES + -------------------------------------------------------------------------------- + Code generated by: SAPIEN Technologies, Inc., PowerShell Studio 2016 v5.2.124 + Generated on: 7/21/2016 3:30 PM + Generated by: administrator + -------------------------------------------------------------------------------- + .DESCRIPTION + GUI script generated by PowerShell Studio 2016 +#> +#---------------------------------------------- +#region Application Functions +#---------------------------------------------- + +#endregion Application Functions + +#---------------------------------------------- +# Generated Form Function +#---------------------------------------------- +function Call-FirstForm4-tabs_psf { + + #---------------------------------------------- + #region Import the Assemblies + #---------------------------------------------- + [void][reflection.assembly]::Load('System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') + [void][reflection.assembly]::Load('System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') + [void][reflection.assembly]::Load('System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') + #endregion Import Assemblies + + #---------------------------------------------- + #region Generated Form Objects + #---------------------------------------------- + [System.Windows.Forms.Application]::EnableVisualStyles() + $form1 = New-Object 'System.Windows.Forms.Form' + $combobox1 = New-Object 'System.Windows.Forms.ComboBox' + $button1 = New-Object 'System.Windows.Forms.Button' + $button_ComboBoxSelection = New-Object 'System.Windows.Forms.Button' + $InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState' + $TextBox_Display = New-Object 'System.Windows.Forms.TextBox' + #endregion Generated Form Objects + + #---------------------------------------------- + # User Generated Script + #---------------------------------------------- + + $combobox1_SelectedIndexChanged={ + #TODO: Place custom script here + + + } + + $form1_Load={ + #TODO: Place custom script here + + } + + + + + + $button1_Click={ + #TODO: Place custom script here + + Ba + } + + $button_ComboBoxSelection_Click={ + + $TextBox_Display.text = $Combobox1.SelectedItem + } + + $TextBox_Display_TextChanged={ + + } + + # --End User Generated Script-- + #---------------------------------------------- + #region Generated Events + #---------------------------------------------- + + $Form_StateCorrection_Load= + { + #Correct the initial state of the form to prevent the .Net maximized form issue + $form1.WindowState = $InitialFormWindowState + } + + $Form_Cleanup_FormClosed= + { + #Remove all event handlers from the controls + try + { + $combobox1.remove_SelectedIndexChanged($combobox1_SelectedIndexChanged) + $form1.remove_Load($form1_Load) + $form1.remove_Load($Form_StateCorrection_Load) + $form1.remove_FormClosed($Form_Cleanup_FormClosed) + } + catch [Exception] + { } + } + #endregion Generated Events + + #---------------------------------------------- + #region Generated Form Code + #---------------------------------------------- + $form1.SuspendLayout() + # + # form1 + # + $form1.Controls.Add($combobox1) + $form1.Controls.Add($button1) + $form1.Controls.Add($button_ComboBoxSelection) + $form1.Controls.Add($TextBox_Display) + $form1.AutoScaleDimensions = '6, 13' + $form1.AutoScaleMode = 'Font' + $form1.ClientSize = '950, 644' + $form1.Name = 'form1' + $form1.Text = 'Form' + $form1.add_Load($form1_Load) + # + # combobox1 + # + $combobox1.AllowDrop = $True + $combobox1.FormattingEnabled = $True + #$combobox1.Items.AddRange("") +<# + [void]$combobox1.Items.Add('One') + [void]$combobox1.Items.Add('Two') + [void]$combobox1.Items.Add('Three') + +#> + # + # + $TextBox_Display.Location = '278, 120' + $TextBox_Display.Name = 'VCenterUserPassword' + $TextBox_Display.Size = '132, 20' + $TextBox_Display.TabIndex = 8 + $TextBox_Display.add_TextChanged($TextBox_Display_TextChanged) + + # + $combobox1.Location = '148, 67' + #$combobox1.MaxDropDownItems = 20 + $Combobox1.Text="- Select -" + $combobox1.Name = 'combobox1' + $combobox1.Size = '121, 21' + $combobox1.TabIndex = 1 + $combobox1.add_SelectedIndexChanged($combobox1_SelectedIndexChanged) + # + # button1 + # + $button1.Location = '309, 67' + $button1.Name = 'button1' + $button1.Size = '75, 23' + $button1.TabIndex = 0 + $button1.Text = 'button1' + $button1.UseVisualStyleBackColor = $True + $form1.ResumeLayout() + $button1.add_Click($button1_Click) + #endregion Generated Form Code + # + # button_ComboBoxSelection + $button_ComboBoxSelection.Location = '309, 40' + $button_ComboBoxSelection.Name = 'button_ComboBoxSelection' + $button_ComboBoxSelection.Size = '75, 23' + $button_ComboBoxSelection.TabIndex = 1 + $button_ComboBoxSelection.Text = 'Select Item' + $button_ComboBoxSelection.add_Click($button_ComboBoxSelection_Click) + + + # + + + #---------------------------------------------- + + + #Save the initial state of the form + $InitialFormWindowState = $form1.WindowState + #Init the OnLoad event to correct the initial state of the form + $form1.add_Load($Form_StateCorrection_Load) + #Clean up the control events + $form1.add_FormClosed($Form_Cleanup_FormClosed) + #Show the Form + return $form1.ShowDialog() + +} #End Function + + +Function Ba { + +#$combobox1.Items.Add('a') + +$combobox1.Items.Clear() + +$P = Get-Process w* | select -ExpandProperty ProcessName + +$P | % { $combobox1.Items.Add($_) } + +} + + +#Call the form +Call-FirstForm4-tabs_psf | Out-Null diff --git a/dump/SCCM-Tool/Forms/Form-Examples/Combobox.ps1 b/dump/SCCM-Tool/Forms/Form-Examples/Combobox.ps1 new file mode 100644 index 0000000..bcf1acd Binary files /dev/null and b/dump/SCCM-Tool/Forms/Form-Examples/Combobox.ps1 differ diff --git a/dump/SCCM-Tool/Forms/Form-Examples/FirstForm4-tabs.Export-10.ps1 b/dump/SCCM-Tool/Forms/Form-Examples/FirstForm4-tabs.Export-10.ps1 new file mode 100644 index 0000000..3248a3d --- /dev/null +++ b/dump/SCCM-Tool/Forms/Form-Examples/FirstForm4-tabs.Export-10.ps1 @@ -0,0 +1,1032 @@ +#------------------------------------------------------------------------ +# Source File Information (DO NOT MODIFY) +# Source ID: b24654a3-c952-4b96-8e01-c56d9800c4a7 +# Source File: FirstForm4-tabs.psf +#------------------------------------------------------------------------ +#region File Recovery Data (DO NOT MODIFY) +<#RecoveryData: +PxYAAB+LCAAAAAAABADNWNtu2kAQfa/Uf7D8TAEbg4kElhJS1KpJgwpN+xat7YFss/ai9ToJ/fqO +L0QBfCVAIxDyZWbP7JyzMyMGP8DhjyBWl0QSBS8Cyv2hqjc11fr4QVEGN4IuqE/YmDL4TjywxlQE +csyFZ3ySxA6ay2A+aO1YJb72H3CkIldLGKrTVSDBa/6ivsufgma0QvLbULJeNZTbNBij2Y4+DWUU +MhkKGPoQSkFYQ5mENqPON1jN+AP4Q9s0Sdfp9rSzjgHt/pmq+BjKUJ3jepqqOPeUuQLt1BH3peAs +SLaIgU4EX4KQq9ThPJR86hAGl9QDPwoCTXsNResMWmvTMtdr7oJqjRGp1GfEKPhySv+ig6mZDcXo +GaVOUZZVK95aqe0MnmUUi/B2TT8/InZqd8WJm655F10PWvHbtWk5nTNip7k9OqmXX0aTIk53s3DF +HSIRW7U0HbnUd3KRl+QIqoLxFBimB9yvvgvPqtWu4hJz3jvrIOdGFQdMcNHylRiakAUcnR4sDUvE +KTx2xSQZDUXP4iiPpTViJZcJcV3qL1QLM59+K/mlhPW7SJi2e0jrU5Z3WHM0t2v+M4BbGoSETeWK +wQVxHkaccaFaMxFC9grlKrkiNhz/CLMIJdroFAR2npjGErnkFNyYldwNF5aCqKxnayZPaBlhV/RP +4tTaemYrKZNPZY8XASlJhEpuiNi4Yy3UU0cEcMGfT1Lig3gHiFZfGZsk62Ytkjewa9KLW9azz3oR +vdm1bqtDR6kf3RN/Ae5WjHevXm327f2Jvgil5P7RebZjGCTVx3jexHOnj6nv1iJ6A7wW0SY2Ab3+ +Ma5abJJjXC+w+s1gS184ijoPW0m5ix8eSlOnKh43oVyGb1JT1Bkq83uNYVJG/Xp9KJFgEmot7fVM +HFn0flWpl80gRVUmia5medl98O5GU/3ko2k1l/8ymlabmpOSVGs3e4ynGfVoDZlbit5ZLyvVVmEX +6xoRhXt0sdwR4pD9q/JkE4ulXmCH7V/5cikpVxu3mzfnQQAeKgGCtW36ZGV5gcMFo/YB1DRovay6 +jZLo9xQYBz8j5YjRn5CnARLkCYvsPljtzrw7N+ea5nbbpEPKsX577CR7GnEBhwd6uU0kP2i9/sPY ++gcZbzYwPxYAAA==#> +#endregion + + +#---------------------------------------------- +#region Application Functions +#---------------------------------------------- + +#endregion Application Functions + +#---------------------------------------------- +# Generated Form Function +#---------------------------------------------- +function Call-FirstForm4-tabs_psf { + + #---------------------------------------------- + #region Import the Assemblies + #---------------------------------------------- + [void][reflection.assembly]::Load('System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') + [void][reflection.assembly]::Load('System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') + [void][reflection.assembly]::Load('System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') + #endregion Import Assemblies + + #---------------------------------------------- + #region Generated Form Objects + #---------------------------------------------- + [System.Windows.Forms.Application]::EnableVisualStyles() + $form1 = New-Object 'System.Windows.Forms.Form' + $DHCP = New-Object 'System.Windows.Forms.TabControl' + $tabpage1 = New-Object 'System.Windows.Forms.TabPage' + $flowlayoutControls1 = New-Object 'System.Windows.Forms.FlowLayoutPanel' + $labelDHCPServerName = New-Object 'System.Windows.Forms.Label' + $labelVcenterServerName = New-Object 'System.Windows.Forms.Label' + $labelVCenterUserName = New-Object 'System.Windows.Forms.Label' + $labelVCenterPassword = New-Object 'System.Windows.Forms.Label' + $DHCPserverBox = New-Object 'System.Windows.Forms.TextBox' + $VCenterServerBox = New-Object 'System.Windows.Forms.TextBox' + # $VCenterUserName = New-Object 'System.Windows.Forms.TextBox' + # $VCenterUserPassword = New-Object 'System.Windows.Forms.TextBox' + # $CheckBoxUseWindowsLogin = New-Object 'System.Windows.Forms.CheckBox' + $buttonConnect = New-Object 'System.Windows.Forms.Button' + $buttonVMHostInfo = New-Object 'System.Windows.Forms.Button' + $ButtonScopeStats = New-Object 'System.Windows.Forms.Button' + # $ButtonScopes1 = New-Object 'System.Windows.Forms.Button' + $ButtonTest = New-Object 'System.Windows.Forms.Button' + $Output = New-Object 'System.Windows.Forms.TextBox' + $tabpage2 = New-Object 'System.Windows.Forms.TabPage' + $panel1 = New-Object 'System.Windows.Forms.Panel' + $Connect = New-Object 'System.Windows.Forms.Button' + $InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState' + $comboboxScopes = New-Object 'System.Windows.Forms.ComboBox' + $ButtonSelect = New-Object 'System.Windows.Forms.Button' + $labelScopeSelected = New-Object 'System.Windows.Forms.Label' + $labelCurrentScope = New-Object 'System.Windows.Forms.Label' + $labelConnectedDHCPServer = New-Object 'System.Windows.Forms.Label' + $labelDHCPServerStatus = New-Object 'System.Windows.Forms.Label' + $radioDisplay = New-Object 'System.Windows.Forms.RadioButton' + $radioGridview = New-Object 'System.Windows.Forms.RadioButton' + $radioCSV = New-Object 'System.Windows.Forms.RadioButton' + $ButtonAvailableIPAddresses = New-Object 'System.Windows.Forms.Button' + $ButtonExclusionList = New-Object 'System.Windows.Forms.Button' + $ButtonReservationList = New-Object 'System.Windows.Forms.Button' + #endregion Generated Form Objects + + #---------------------------------------------- + # User Generated Script + #---------------------------------------------- + + $form1_Load={ + #TODO: Initialize Form Controls here + #$DefaultCompName = $env:COMPUTERNAME + #$Output.Text = $DefaultCompName + $Global:DisplayType = "OnScreen" + NA-VCconn + #NA-TestOutput + } +#################################################################################################################################### + $flowlayoutControls1_Paint=[System.Windows.Forms.PaintEventHandler]{ + #Event Argument: $_ = [System.Windows.Forms.PaintEventArgs] + #TODO: Place custom script here + + } +#################################################################################################################################### + $Output_TextChanged={ + #TODO: Place custom script here + + } +#################################################################################################################################### + $comboboxScopes_SelectedIndexChanged={ + #TODO: Place custom script here + + + } +#################################################################################################################################### + $labelCurrentScope_Click={ + + } +#################################################################################################################################### + $labelConnectedDHCPServer_Click={} +#################################################################################################################################### + $labelDHCPServerStatus_Click={} +#################################################################################################################################### + $DHCPserverBox_TextChanged={ + #TODO: Place custom script here + } +#################################################################################################################################### + $VCenterServerBox_TextChanged={} +#################################################################################################################################### +<# + $VCenterUserName_TextChanged={ + + } + + $VCenterUserPassword_TextChanged={ + + } + + $CheckBoxUseWindowsLogin_CheckedChanged={ + + If ($CheckBoxUseWindowsLogin.Checked -eq $true) { + $Output.Text = "Checkbox Checked" + } + } +#> + $buttonConnect_Click={ + #TODO: Place custom script here + If (!$DHCPserverBox.Text) { + $Output.Text = "###### Please enter DHCP server name in the Box ###### " + } + + Else { + $Output.Text = "**** Locating DHCP Server: $($DHCPserverBox.text.ToUpper()) ****" + $PingDHCPServer = Test-Connection -ComputerName $DHCPserverBox.text -Count 1 -ErrorAction SilentlyContinue + If (!$PingDHCPServer) { $Output.Text = "#### DHCP Server: $($DHCPserverBox.text.ToUpper()) is not accessible - Please Check the Name! ####" } + Else { + NA-Server-Connection 1 ($DHCPserverBox.text) + NA-GetScopes + } + } + + + } + +#################################################################################################################################### + $ButtonAvailableIPAddresses_Click={ + If ($labelScopeSelected.Text -ne $Global:ScopeValue) { + If (Get-PSSession) { + NA-Get-DHCPinfo -Option AvailableIPAddresses -ScopeSend ($labelScopeSelected.Text) -DisplayOption $Global:DisplayType + } + Else { $Output.Text = "### Not Connected to DHCP Server - Please enter DHCP server name and Connect ###" } + } + } +#################################################################################################################################### + $ButtonExclusionList_Click={ + + #$Output.Text = $Global:DisplayType + If ($labelScopeSelected.Text -ne $Global:ScopeValue) { + If (Get-PSSession) { + NA-Get-DHCPinfo -Option ExclusionList -ScopeSend ($labelScopeSelected.Text) -DisplayOption $Global:DisplayType + } + Else { $Output.Text = "### Not Connected to DHCP Server - Please enter DHCP server name and Connect ###" } + } + Else { $Output.Text = "### Scope Not Found! -- Please Select a Scope from the List ###"} + + } +#################################################################################################################################### + $ButtonReservationList_Click={ + + If ($labelScopeSelected.Text -ne $Global:ScopeValue) { + If (Get-PSSession) { + NA-Get-DHCPinfo -Option ReservationList -ScopeSend ($labelScopeSelected.Text) -DisplayOption $Global:DisplayType + } + Else { $Output.Text = "### Not Connected to DHCP Server - Please enter DHCP server name and Connect ###" } + } + Else { $Output.Text = "### Scope Not Found! -- Please Select a Scope from the List ###"} + + }#end Button + +#################################################################################################################################### + $buttonVMHostInfo_Click={ + + If ( $Global:VCenterConnectionStatus -eq $False) { $Output.Text = "### Please Connect to VCenter Server First ###" } + + Else { + $Output.Text = "Geting VM Host Information ...... Please wait!" + $VMHostInformation = Get-VMHost | select name,build,model,@{Name="MemoryTotalGB";Expression={"{0:N2}" -f $_.memorytotalgb}},@{Name="MemoryUsageGB";Expression={"{0:N2}" -f $_.memoryusageGb}} | FT -AutoSize | Out-String + $Output.Text = $VMHostInformation + } + } + + +#################################################################################################################################### + $ButtonScopeStats_Click={ + + If (Get-PSSession) { + + Invoke-Command -Session $Global:Session { $Get_dhcpScopeStats = Get-DhcpServerV4ScopeStatistics } + $DhcpScopeStats = Invoke-Command -Session $Global:Session { $Get_dhcpScopeStats } + + If ($radioGridview.Checked) { + $Output.Text = $DhcpScopeStats | select ScopeID,Free,InUse,@{n="PercentageInUse";e={[Math]::Round($_.PercentageInUse,2)}},Reserved,Pending,SuperScopeName | Out-GridView #ft -AutoSize | Out-String + } + Else { + $Output.Text = $DhcpScopeStats | select ScopeID,Free,InUse,@{n="PercentageInUse";e={[Math]::Round($_.PercentageInUse,2)}},Reserved,Pending,SuperScopeName | ft -AutoSize | Out-String + } + }#end If + + Else { + $Output.Text = "No Connection to DHCP exists - Cannot proceed!" + }#end Else + + } +#################################################################################################################################### + + $ButtonSelect_Click={ + [Bool]$Yes = $False + $Global:Scope | % { $IP = $_; $CmboIP = $comboboxScopes.Text; If ($IP -eq $CmboIP) { $Yes = $True } } + + If ($Yes) { + $labelScopeSelected.Text = $comboboxScopes.Text + } + Else { $Output.Text = "Invalid IP Selection - Try Again!"} + # NA-GetScopes + } +#################################################################################################################################### + +<# + $ButtonScopes1_Click={ + + $Output.Text = "Hello" + #NA-GetScopes + } +#> + + + +#################################################################################################################################### + $radioDisplay_SelectedIndexChanged={ + $Global:DisplayType = "OnScreen" + #$Output.Text = $DisplayType + } +#################################################################################################################################### + $radioGridview_SelectedIndexChanged={ + $Global:DisplayType = "GridView" + + #$Output.Text = $DisplayType + } +#################################################################################################################################### + $radioCSV_SelectedIndexChanged={ + $Global:DisplayType = "CSV" + #$Output.Text = $DisplayType + } +#################################################################################################################################### + $tabpage2_SelectedIndexChanged={ + #TODO: Place custom script here +[System.Windows.Forms.MessageBox]::Show("This is Error","Error Window",'OK', 'Error') + } +#################################################################################################################################### + $tabpage1_SelectedIndexChanged={ + + } +#################################################################################################################################### + $Connect_Click={ + #TODO: Place custom script here + #$Output.Text = $VCenterUserName.Text + + $Global:VC = $VCenterServerBox.Text + #$VCuser = $VCenterUserName.Text + #$VCpwd = $VCenterUserPassword.text + + NA-AddPSsnapin + + If (!$VCenterServerBox.text) { $Output.Text = "###### Please Enter VCenter Server Name in the Box ######!!!!"} + + Else { + $CheckVCenterConnection = Test-Connection -ComputerName $VCenterServerBox.text -Count 1 -ErrorAction SilentlyContinue + + If (!$CheckVCenterConnection) { $Output.Text = "VCenter Server: $VC is not accessible. Please Check Server Name!"} + + Else { + NA-VCenterConnection -VCenterServer $Global:VC -ConnState Connect + + }#end Else + }#end Else + + + #$Test = Get-VM Catlbi01 | select * + #$Output.text = $Test | Out-String + + }#End $Connect_Click +#################################################################################################################################### + + # --End User Generated Script-- + #---------------------------------------------- + #region Generated Events + #---------------------------------------------- + + $Form_StateCorrection_Load= + { + #Correct the initial state of the form to prevent the .Net maximized form issue + $form1.WindowState = $InitialFormWindowState + } + + $Form_Cleanup_FormClosed= + { + #Remove all event handlers from the controls + try + { + $DHCPserverBox.remove_TextChanged($DHCPserverBox_TextChanged) + $flowlayoutControls1.remove_Paint($flowlayoutControls1_Paint) + $VCenterServerBox.remove_TextChanged($VCenterServerBox_TextChanged) + # $VCenterUserName.remove_TextChanged($VCenterUserName_TextChanged) + # $VCenterUserPassword.remove_TextChanged($VCenterUserPassword_TextChanged) + # $CheckBoxUseWindowsLogin.remove_TextChanged($CheckBoxUseWindowsLogin_CheckedChanged) + $buttonConnect.remove_Click($buttonConnect_Click) + $ButtonAvailableIPAddresses.remove_Click($ButtonAvailableIPAddresses_Click) + $ButtonExclusionList.remove_Click($ButtonExclusionList_Click) + $ButtonReservationList.remove_Click($ButtonReservationList_Click) + $buttonVMHostInfo.remove_Click($buttonVMHostInfo_Click) + $ButtonScopeStats.remove_Click($ButtonScopeStats_Click) + $ButtonSelect.remove_Click($ButtonSelect_Click) + # $ButtonScopes1.remove_Click($ButtonScopes_Click) + $Output.remove_TextChanged($Output_TextChanged) + $Connect.remove_Click($Connect_Click) + $tabpage2.remove_Click($tabpage2_Click) + $panel1.remove_Paint($panel1_Paint) + $form1.remove_Load($form1_Load) + $form1.remove_Load($Form_StateCorrection_Load) + $form1.remove_FormClosed($Form_Cleanup_FormClosed) + $comboboxScopes.remove_SelectedIndexChanged($comboboxScopes_SelectedIndexChanged) + $radioDisplay.remove_CheckedChanged($radioDisplay_SelectedIndexChanged) + $radioGridview.remove_CheckedChanged($radioGridview_SelectedIndexChanged) + $radioCSV.remove_CheckedChanged($radioCSV_SelectedIndexChanged) + #$Output.Text = "Closing Connection to DHCP Server" + NA-Server-Connection 0 + NA-VCenterConnection -ConnState Disconnect + NA-ClearGlobalVariables + #Write-Host "bye bye" + # Close VCenter connection + } + catch [Exception] + { } + } + + $panel1_Paint=[System.Windows.Forms.PaintEventHandler]{ + #Event Argument: $_ = [System.Windows.Forms.PaintEventArgs] + #TODO: Place custom script here + + } + + + #endregion Generated Events + + #---------------------------------------------- + #region Generated Form Code + #---------------------------------------------- + $form1.SuspendLayout() + $DHCP.SuspendLayout() + $tabpage1.SuspendLayout() + $tabpage2.SuspendLayout() + $flowlayoutControls1.SuspendLayout() + # + # form1 + # + $form1.Controls.Add($DHCP) + $form1.Controls.Add($Output) + $form1.Controls.Add($flowlayoutControls1) + $form1.AutoScaleDimensions = '6, 13' + $form1.AutoScaleMode = 'Font' + $form1.ClientSize = '921, 644' + $form1.Name = 'form1' + $form1.Text = 'Form' + $form1.add_Load($form1_Load) + # + # DHCP + # + $DHCP.Controls.Add($tabpage1) + $DHCP.Controls.Add($tabpage2) + $DHCP.Location = '139, 10' + $DHCP.Name = 'DHCP' + $DHCP.SelectedIndex = 0 + $DHCP.Size = '754, 237' + $DHCP.TabIndex = 0 + # + # tabpage1 + # + $tabpage1.Controls.Add($labelDHCPServerName) + $tabpage1.Controls.Add($labelScopeSelected) + $tabpage1.Controls.Add($labelCurrentScope) + $tabpage1.Controls.Add($labelConnectedDHCPServer) + $tabpage1.Controls.Add($labelDHCPServerStatus) + $tabpage1.Controls.Add($DHCPserverBox) + $tabpage1.Controls.Add($buttonConnect) + $tabpage1.Controls.Add($ButtonScopeStats) + $tabpage1.Controls.Add($ButtonSelect) + $tabpage1.Controls.Add($comboboxScopes) + $tabpage1.Controls.Add($radioDisplay) + $tabpage1.Controls.Add($radioGridview) + $tabpage1.Controls.Add($radioCSV) + $tabpage1.Controls.Add($flowlayoutControls1) + $tabpage1.Controls.Add($ButtonReservationList) + # $tabpage1.Controls.Add($ButtonScopes1) + # $tabpage1.Controls.Add($Output) + $tabpage1.Location = '4, 22' + $tabpage1.Name = 'tabpage1' + $tabpage1.Padding = '3, 3, 3, 3' + $tabpage1.Size = '754, 237' + $tabpage1.TabIndex = 0 + $tabpage1.Text = 'DHCP' + $tabpage1.UseVisualStyleBackColor = $True + # + # flowlayoutpanel1 + # + $flowlayoutControls1.Controls.Add($ButtonAvailableIPAddresses) + $flowlayoutControls1.Controls.Add($ButtonExclusionList) + $flowlayoutControls1.Controls.Add($ButtonReservationList) + $flowlayoutControls1.BackColor = 'InactiveCaption' + $flowlayoutControls1.BorderStyle = 'FixedSingle' + $flowlayoutControls1.Location = '393, 7' + $flowlayoutControls1.Name = 'flowlayoutpanel1' + $flowlayoutControls1.Padding = '4, 4, 4, 4' + $flowlayoutControls1.Size = '200, 190' + $flowlayoutControls1.TabIndex = 0 + $flowlayoutControls1.add_Paint($flowlayoutControls1_Paint) + # + # labelDHCPServerName + # + $labelDHCPServerName.AutoSize = $True + $labelDHCPServerName.Location = '16, 11' + $labelDHCPServerName.Name = 'labelDHCPServerName' + $labelDHCPServerName.Size = '102, 13' + $labelDHCPServerName.TabIndex = 3 + $labelDHCPServerName.Text = 'DHCP Server Name' + # + # labelScopeSelected + # + $labelScopeSelected.AutoSize = $True + $labelScopeSelected.Location = '310, 31' + $labelScopeSelected.Name = 'ScopeSelected' + $labelScopeSelected.Size = '102, 13' + $labelScopeSelected.TabIndex = 12 + #$labelScopeSelected.Text = '----' + $Global:ScopeValue = "----" + $labelScopeSelected.Text = $Global:ScopeValue + # + # labelCurrentScoope + # + $labelCurrentScope.AutoSize = $True + $labelCurrentScope.Location = '230, 31' + $labelCurrentScope.Name = 'CurrentScope' + $labelCurrentScope.Size = '102, 13' + $labelCurrentScope.TabIndex = 13 + $labelCurrentScope.Text = 'Current Scope:' + $labelCurrentScope.add_Click($labelCurrentScope_Click) + # + # labelConnectedDHCPServer + # + $labelConnectedDHCPServer.AutoSize = $True + $labelConnectedDHCPServer.Location = '230, 11' + $labelConnectedDHCPServer.Name = 'DHCPServer' + $labelConnectedDHCPServer.Size = '102, 13' + $labelConnectedDHCPServer.TabIndex = 13 + $labelConnectedDHCPServer.Text = 'DHCP Server:' + $labelConnectedDHCPServer.add_Click($labelConnectedDHCPServer_Click) + # + # labelDHCPServerStatus + # + $labelDHCPServerStatus.AutoSize = $True + $labelDHCPServerStatus.Location = '310, 11' + $labelDHCPServerStatus.Name = 'DHCPServerStatus' + $labelDHCPServerStatus.Size = '102, 13' + $labelDHCPServerStatus.TabIndex = 14 + $labelDHCPServerStatus.Text = '----' + $labelDHCPServerStatus.add_Click($labelDHCPServerStatus_Click) + # + # DHCPserverBox + # + $DHCPserverBox.Location = '20, 30' + $DHCPserverBox.Name = 'DHCPserverBox' + $DHCPserverBox.Size = '100, 20' + $DHCPserverBox.TabIndex = 2 + $DHCPserverBox.add_TextChanged($DHCPserverBox_TextChanged) + # + # comboboxScopes + + + $comboboxScopes.Location = '6, 107' + #$combobox1.MaxDropDownItems = 20 + $comboboxScopes.Text="----" + $comboboxScopes.Name = 'combobox1' + $comboboxScopes.Size = '121, 21' + $comboboxScopes.TabIndex = 1 + $comboboxScopes.add_SelectedIndexChanged($comboboxScopes_SelectedIndexChanged) + $comboboxScopes.AllowDrop = $True + $comboboxScopes.FormattingEnabled = $True + # + # $ButtonSelect + $ButtonSelect.Location = '138, 106' + $ButtonSelect.Name = 'ButtonSelect' + $ButtonSelect.Size = '75, 23' + $ButtonSelect.TabIndex = 13 + $ButtonSelect.Text = 'Select' + $ButtonSelect.UseVisualStyleBackColor = $True + $ButtonSelect.add_Click($ButtonSelect_Click) + # + # radioDisplay + # + $radioDisplay.Location = '6, 135' + $radioDisplay.Checked = $True + $radioDisplay.Name = 'Display' + $radioDisplay.Size = '77, 24' + $radioDisplay.TabIndex = 14 + $radioDisplay.TabStop = $True + $radioDisplay.Text = 'OnScreen' + $radioDisplay.UseVisualStyleBackColor = $True + $radioDisplay.add_CheckedChanged($radioDisplay_SelectedIndexChanged) + $form1.ResumeLayout() + # + # radioGridview + # + $radioGridview.Location = '84, 135' + $radioGridview.Name = 'Gridview' + $radioGridview.Size = '77, 24' + $radioGridview.TabIndex = 15 + $radioGridview.TabStop = $True + $radioGridview.Text = 'GridView' + $radioGridview.UseVisualStyleBackColor = $True + $radioGridview.add_CheckedChanged($radioGridview_SelectedIndexChanged) + # + # radioCSV + # + $radioCSV.Location = '162, 135' + $radioCSV.Name = 'CSV' + $radioCSV.Size = '77, 24' + $radioCSV.TabIndex = 16 + $radioCSV.TabStop = $True + $radioCSV.Text = 'CSV' + $radioCSV.UseVisualStyleBackColor = $True + $radioCSV.add_CheckedChanged($radioCSV_SelectedIndexChanged) + # + # ButtonAvailableIPAddresses + # + $ButtonAvailableIPAddresses.Location = '7, 7' + $ButtonAvailableIPAddresses.Name = 'AvailableIPAddresses' + $ButtonAvailableIPAddresses.Size = '126, 23' + $ButtonAvailableIPAddresses.TabIndex = 16 + $ButtonAvailableIPAddresses.Text = "Available IPs" + $ButtonAvailableIPAddresses.UseVisualStyleBackColor = $True + $ButtonAvailableIPAddresses.add_Click($ButtonAvailableIPAddresses_Click) + $flowlayoutControls1.ResumeLayout() + # + # ButtonExclusionList + # + $ButtonExclusionList.Location = '7, 36' + $ButtonExclusionList.Name = 'ExclusionList' + $ButtonExclusionList.Size = '126, 23' + $ButtonExclusionList.TabIndex = 17 + $ButtonExclusionList.Text = "Exclusion List" + $ButtonExclusionList.UseVisualStyleBackColor = $True + $ButtonExclusionList.add_Click($ButtonExclusionList_Click) + $flowlayoutControls1.ResumeLayout() + # + # ButtonReservationList + $ButtonReservationList.Location = '7, 66' + $ButtonReservationList.Name = 'Reservations' + $ButtonReservationList.Size = '126, 23' + $ButtonReservationList.TabIndex = 18 + $ButtonReservationList.Text = "Reservations" + $ButtonReservationList.add_Click($ButtonReservationList_Click) + $ButtonReservationList.UseVisualStyleBackColor = $True + $flowlayoutControls1.ResumeLayout() + # + # + # VCenterServerBox + # + $VCenterServerBox.Location = '8, 26' + $VCenterServerBox.Name = 'VCenterServerBox' + $VCenterServerBox.Size = '100, 20' + $VCenterServerBox.TabIndex = 6 + $VCenterServerBox.add_TextChanged($VCenterServerBox_TextChanged) + # + # VCenterUserName + <# + $VCenterUserName.Location = '140, 28' + $VCenterUserName.Name = 'VCenterUserName' + $VCenterUserName.Size = '132, 20' + $VCenterUserName.TabIndex = 7 + $VCenterUserName.add_TextChanged($VCenterUserName_TextChanged) + #> + # VCenterUserPassword + <# + $VCenterUserPassword.Location = '278, 28' + $VCenterUserPassword.Name = 'VCenterUserPassword' + $VCenterUserPassword.Size = '132, 20' + $VCenterUserPassword.TabIndex = 8 + $VCenterUserPassword.add_TextChanged($VCenterUserPassword_TextChanged) + #> + # CheckBoxUseWindowsLogin + <# + $CheckBoxUseWindowsLogin.Location = '518, 30' + $CheckBoxUseWindowsLogin.Name = 'CheckBoxUseWindowsLogin' + $CheckBoxUseWindowsLogin.Size = '123, 17' + $CheckBoxUseWindowsLogin.TabIndex = 9 + $CheckBoxUseWindowsLogin.Text = 'Use Windows Login' + $CheckBoxUseWindowsLogin.add_TextChanged($CheckBoxUseWindowsLogin_CheckedChanged) + #> + # buttonConnect + # + $buttonConnect.Location = '138, 28' + $buttonConnect.Name = 'buttonConnect' + $buttonConnect.Size = '75, 23' + $buttonConnect.TabIndex = 1 + $buttonConnect.Text = 'Connect' + $buttonConnect.UseVisualStyleBackColor = $True + $buttonConnect.add_Click($buttonConnect_Click) + # + # ButtonScopeStats + $ButtonScopeStats.Location = '138, 60' + $ButtonScopeStats.Name = 'ButtonScopeStats' + $ButtonScopeStats.Size = '75, 23' + $ButtonScopeStats.TabIndex = 2 + $ButtonScopeStats.Text = 'Scope Stats' + $ButtonScopeStats.UseVisualStyleBackColor = $True + $ButtonScopeStats.add_Click($ButtonScopeStats_Click) + # + + <# ButtonScopes + $ButtonScopes1.Location = '138, 92' + $ButtonScopes1.Name = 'ButtonScopes' + $ButtonScopes1.Size = '75, 23' + $ButtonScopes1.TabIndex = 4 + $ButtonScopes1.Text = 'Get-Scopes' + $ButtonScopes1.UseVisualStyleBackColor = $True + $ButtonScopes1.add_Click($ButtonScopes1_Click) + #> + + + + + # Output + # + $Output.Location = '139, 280' + $Output.Multiline = $True + $Output.Name = 'Output' + $Output.ScrollBars = 'Both' + $Output.Font = 'Consolas, 8.25pt' + $Output.WordWrap = $False + $Output.Size = '754, 335' + $Output.TabIndex = 0 + $Output.add_TextChanged($Output_TextChanged) + # + # tabpage2 + # + $tabpage2.Controls.Add($Connect) + $tabpage2.Controls.Add($buttonVMHostInfo) + $tabpage2.Controls.Add($panel1) + $tabpage2.Controls.Add($labelVcenterServerName) + $tabpage2.Controls.Add($VCenterServerBox) + #$tabpage2.Controls.Add($VCenterUserName) + #$tabpage2.Controls.Add($VCenterUserPassword) + #$tabpage2.Controls.Add($CheckBoxUseWindowsLogin) + $tabpage2.Controls.Add($labelVCenterUserName) + $tabpage2.Controls.Add($labelVCenterPassword) + + $tabpage2.Location = '4, 22' + $tabpage2.Name = 'tabpage2' + $tabpage2.Padding = '3, 3, 3, 3' + $tabpage2.Size = '754, 237' + $tabpage2.TabIndex = 1 + $tabpage2.Text = 'VCenter' + $tabpage2.UseVisualStyleBackColor = $True + $tabpage2.add_Click($tabpage2_Click) + # + # labelDHCPServerName + # + $labelVcenterServerName.AutoSize = $True + $labelVcenterServerName.Location = '8, 6' + $labelVcenterServerName.Name = 'labelVcenterServerName' + $labelVcenterServerName.Size = '100, 20' + $labelVcenterServerName.TabIndex = 3 + $labelVcenterServerName.Text = 'VCenter Server:' + # + + # + <# labelVCenterUserName + # + $labelVCenterUserName.AutoSize = $True + $labelVCenterUserName.Location = '138, 11' + $labelVCenterUserName.Name = 'labelVCenterUserName' + $labelVCenterUserName.Size = '99, 13' + $labelVCenterUserName.TabIndex = 4 + $labelVCenterUserName.Text = 'Domain\Username:' + #> + <# labelVCenterPassword + # + $labelVCenterPassword.AutoSize = $True + $labelVCenterPassword.Location = '275, 11' + $labelVCenterPassword.Name = 'labelVCenterPassword' + $labelVCenterPassword.Size = '56, 13' + $labelVCenterPassword.TabIndex = 5 + $labelVCenterPassword.Text = 'Password:' + #> + + # Connect + # + $Connect.Location = '122, 30' + $Connect.Name = 'Connect' + $Connect.Size = '75, 23' + $Connect.TabIndex = 0 + $Connect.Text = 'Connect' + $Connect.UseVisualStyleBackColor = $True + $Connect.add_Click($Connect_Click) + # + $tabpage2.ResumeLayout() + $tabpage1.ResumeLayout() + $DHCP.ResumeLayout() + $form1.ResumeLayout() + #endregion Generated Form Code + # + # buttonVMHostInfo + $buttonVMHostInfo.Location = '188, 81' + $buttonVMHostInfo.Name = 'VMHost_Info' + $buttonVMHostInfo.Size = '75, 23' + $buttonVMHostInfo.TabIndex = 9 + $buttonVMHostInfo.Text = 'VMHost Info' + $buttonVMHostInfo.add_Click($buttonVMHostInfo_Click) + + # + #---------------------------------------------- + + # panel1 + # + $panel1.Controls.Add($labelVcenterServerName) + $panel1.Controls.Add($VCenterServerBox) + $panel1.Controls.Add($VCenterUserName) + $panel1.Controls.Add($VCenterUserPassword) + $panel1.Controls.Add($CheckBoxUseWindowsLogin) + $panel1.Controls.Add($labelVCenterUserName) + $panel1.Controls.Add($labelVCenterPassword) + $panel1.BackColor = 'LightSteelBlue' + $panel1.Location = '6, 6' + $panel1.Name = 'panel1' + $panel1.Size = '198, 56' + $panel1.TabIndex = 0 + $panel1.add_Paint($panel1_Paint) + $tabpage2.ResumeLayout() + $tabpage1.ResumeLayout() + $DHCP.ResumeLayout() + $form1.ResumeLayout() + #endregion Generated Form Code + + #---------------------------------------------- + + #Save the initial state of the form + $InitialFormWindowState = $form1.WindowState + #Init the OnLoad event to correct the initial state of the form + $form1.add_Load($Form_StateCorrection_Load) + #Clean up the control events + $form1.add_FormClosed($Form_Cleanup_FormClosed) + #Show the Form + return $form1.ShowDialog() + +} #End Function Call-FirstForm4-tabs_psf + + #################################################################################################################################### + Function NA-GetScopes { + + Invoke-Command -Session $Global:Session { $Get_Scope = Get-DhcpServerv4Scope | select -ExpandProperty ScopeID} + $Global:Scope = Invoke-Command -Session $Global:Session { $Get_Scope } + + $comboboxScopes.Items.Clear() + + # $Global:Scope = Get-Process | select -ExpandProperty ProcessName + + $Global:Scope | % { $comboboxScopes.Items.Add($_) } + + } + + #################################################################################################################################### + Function NA-AddPSsnapin { + + $CheckPsSnapIn = Get-PSSnapin vmw* -ErrorAction SilentlyContinue + + If (!($CheckPsSnapIn)) { + + $Output.Text = "Adding PowerCLI Snap-in - Please Wait ...." + Add-PSSnapin vmw* + $CheckPsSnapIn = Get-PSSnapin vmw* -ErrorAction SilentlyContinue + + If ($CheckPsSnapIn) { + + $Output.Text = "Done!" + }#end If + }#end If + + } + #################################################################################################################################### + Function NA-VCconn { + $Global:VCenterConnectionStatus = $False + #$Output.Text = $Global:VCenterConnectionStatus + $Output.Text = "Welcome" + } + #################################################################################################################################### + Function NA-TestOutput { + $Output.Text = "This is Working!!!" + } + #################################################################################################################################### + Function NA-VCenterConnection ($VCenterServer, $ConnState) { + + #If (Get-VMHost -ErrorAction SilentlyContinue) { $Output.text = "Checking Status of VCenter Connection.....!" ;$Output.text = "Already Connected to VCenter: $VCenterServer" } + + Switch($ConnState) { + Connect { $T = $DefaultVIServer | select -ExpandProperty IsConnected + If ($T -eq $True) { $Output.text = "Checking Status of VCenter Connection.....!" ;$Output.text = "Already Connected to VCenter: $VCenterServer"; Break } + + Else { + $Output.text = "Connecting to VCenter ..... Please Wait!" + $Cred = Get-Credential -Credential (Get-WMIObject -class Win32_ComputerSystem | select -ExpandProperty username) + + Connect-VIServer -Server $VCenterServerBox.Text -Credential $Cred + + $T = $DefaultVIServer | select -ExpandProperty IsConnected + + If ($T -eq $True) { $Output.text = "Successfully Connected to VCenter: $VCenterServer" + $Global:VCenterConnectionStatus = $True } + + Else { $Output.text = "Failed to Connect to VCenter $VCenterServer - Please Try Again!" } + }#end Else + } + + Disconnect { If ($Global:VCenterConnectionStatus -eq $True) { $Global:VCenterConnectionStatus = $False ;Disconnect-VIServer -Server $Global:VC -Force -Confirm:$false} + Else { Break } + } + + }#end Switch + + + + }#end Function +#################################################################################################################################### + Function NA-Get-DHCPinfo ($Option,$ScopeSend,$DisplayOption) { + + Begin { } + + Process { + Switch($Option) + { + ExclusionList { $PickScope = $ScopeSend #$labelScopeSelected.Text #$comboboxScopes.Text + #$Output.Text = $PickScope + Invoke-Command -Session $Global:Session { Param($PickScope) $Get_Exclusion = Get-DhcpServerV4ExclusionRange -ScopeID $PickScope | sort StartRange } -ArgumentList $PickScope + $Exclusion = Invoke-Command -Session $Global:Session { $Get_Exclusion } + + If ($Exclusion) { + + Switch($DisplayOption) { + "OnScreen" { $Output.Text = $Exclusion | select ScopeID,StartRange,EndRange | ft -AutoSize | Out-String } + "GridView" { $Output.Text = $Exclusion | select ScopeID,StartRange,EndRange | Out-GridView } + "CSV" { $Output.Text = "This Option is not yet Available!!!!!!!!!!" } + }#end Switch + + + }#end If + + Else { $Output.Text = "#### No Exclusions Found for the Scope: $PickScope ####" } + + }#end ExclusionList + + ReservationList { $PickScope = $ScopeSend + Invoke-Command -Session $Global:Session { Param($PickScope) $Get_Reservation = Get-DhcpServerV4Reservation -ScopeID $PickScope | Sort IPAddress } -ArgumentList $PickScope + $Res = Invoke-Command -Session $Global:Session { $Get_Reservation } + # + If ($Res) { + + Switch($DisplayOption) { + "OnScreen" { $Output.Text = $Res | Select IPAddress,ClientID,Name,Description | Ft -AutoSize | Out-String } + "GridView" { $Output.Text = $Res | Select IPAddress,ClientID,Name,Description | Out-GridView } + "CSV" { $Output.Text = "This Option is not yet Available!!!!!!!!!!" } + }#end Switch + + + }#end If + + Else { $Output.Text = "#### No Reservations Found for the Scope: $PickScope ####" } + + + + + + + }#end ReservationList + + + AddDHCPreservation { $PickScope = $ScopeSend + NA-CollectDHCPReservationInfo + + $Res_Name = $Global:SendDHCPreservationInfo[0] + $Res_MAC = $Global:SendDHCPreservationInfo[1] + $Res_IP = $Global:SendDHCPreservationInfo[2] + $Res_Description = $Global:SendDHCPreservationInfo[3] + + Invoke-Command -Session $Global:Session { Param($PickScope,$Res_Name,$Res_MAC,$Res_IP,$Res_Description) $ADD_Reservation = Add-DhcpServerv4Reservation -ScopeID $PickScope -IPAddress $Res_IP -ClientID $Res_MAC -Name $Res_Name -Description $Res_Description } -ArgumentList $PickScope,$Res_Name,$Res_MAC,$Res_IP,$Res_Description + + Write-Host "" + NA-Verify -VerifyCode VerifyDHCPreservation -DHCPscope $PickScope + + NA-ClearGlobalVariables + NA-RunAgain + } + + + DHCPscopes { NA-Get-CurrentIPv4Scopes + Invoke-Command -Session $Global:Session { Param($PickScope) $Get_Scope = Get-DhcpServerv4Scope -ScopeID $PickScope } + $Global:Scope = Invoke-Command -Session $Global:Session { $Get_Scope } + #Write-Host "Current Scope on DHCP Server:" + $Scope | select scopeid,subnetmask,name,state,startrange,endrange,leaseduration | ft -AutoSize + NA-ClearGlobalVariables + NA-RunAgain + } + + AvailableIPAddresses { $PickScope = $ScopeSend + Invoke-Command -Session $Global:Session { Param($PickScope) $Get_AvailableIPs = Get-DhcpServerV4FreeIPAddress -ScopeID $PickScope -NumAddress 254 } -ArgumentList $PickScope + $FreeIP = Invoke-Command -Session $Global:Session { $Get_AvailableIPs } + $FreeIPCount = $FreeIP.count + #P + + If ($FreeIP) { + Switch($DisplayOption) { + "OnScreen" { $Output.Text = $FreeIP | ft -AutoSize | Out-String } + "GridView" { $Output.Text = $FreeIP | Out-GridView } + "CSV" { $Output.Text = "This Option is not yet Available!!!!!!!!!!" } + }#end Switch + } + Else { $Output.Text = "#### No Available IP Addresses Found for the Scope: $PickScope ####" } + + } + + DhcpLease { NA-Get-CurrentIPv4Scopes + $PickScope = $Global:SendScope + Invoke-Command -Session $Global:Session { Param($PickScope) $Get_dhcpLease = Get-DhcpserverV4Lease -ScopeID $PickScope } -ArgumentList $PickScope + $DhcpLease = Invoke-Command -Session $Global:Session { $Get_dhcpLease } + $DhcpLease | Select IPAddress,ScopeID,ClientID,Hostname,AddressState, LeaseExpiryTime | Ft -Wrap + NA-ClearGlobalVariables + NA-RunAgain + } + DhcpScopeStats { Invoke-Command -Session $Global:Session { $Get_dhcpScopeStats = Get-DhcpServerV4ScopeStatistics } + $DhcpScopeStats = Invoke-Command -Session $Global:Session { $Get_dhcpScopeStats } + $DhcpScopeStats | select ScopeID,Free,InUse,@{n="PercentageInUse";e={[Math]::Round($_.PercentageInUse,2)}},Reserved,Pending,SuperScopeName | Ft -AutoSize + NA-ClearGlobalVariables + NA-RunAgain + } + DhcpServerStats { Invoke-Command -Session $Global:Session {$Get_DhcpServerStats = Get-DhcpServerV4Statistics } + $DhcpServerStats = Invoke-Command -Session $Global:Session { $Get_DhcpServerStats } + $DhcpServerStats | Fl + NA-ClearGlobalVariables + NA-RunAgain + } + + PingDHCPexclusion { Write-Host "This option is not yet available ....!!" -ForegroundColor Red -BackgroundColor White + #NA-Verify -VerifyCode VerifyDHCPreservation -DHCPscope '172.27.144.0' + NA-Menu + } + + Test { Invoke-Command -Session $Global:Session { $Name = $env:COMPUTERNAME } + $N = Invoke-Command -Session $Global:Session { $Name } + } + test2 { $Loc = Get-Location + Set-Location "H:\Documents\Scripts-Nabil\PowerShell\_Forms-Test" + .\temp-form.ps1 + Set-Location $Loc + NA-RunAgain} + + + }#end Switch + }#end Process + }#end Function + +################################################################################################################## + Function NA-Server-Connection ($SvrConn,$Server) { + Switch($SvrConn) { + 0 { Write-Debug "Closing Connection"; Get-PSSession | Remove-PSSession + Write-Host "Good Bye !" -ForegroundColor Cyan } + + 1 { $Output.text = "Creating Connection to Server: $Server" | Out-String; $Global:Session = New-PSSession -ComputerName $Server + Invoke-Command -Session $Global:Session { Import-Module dhcpserver } + + If (Get-Pssession) { + $Output.Text = "Successfully Connected to Server: $Server" + $labelDHCPServerStatus.Text = $Server + }#end If + + }#end 1 + + }#end Switch + }#end Function +################################################################################################################### + Function NA-ClearGlobalVariables { + $Global:DisplayType = "" + $Global:Session = "" + $Global:Scope = "" + $Global:VCenterConnectionStatus = "" + $Global:VC = "" + $VCuser = "" + $VCpwd = "" + + } +################################################################################################################### + + +#Call the form +Call-FirstForm4-tabs_psf | Out-Null diff --git a/dump/SCCM-Tool/Forms/Form-Examples/Form-Calendar.ps1 b/dump/SCCM-Tool/Forms/Form-Examples/Form-Calendar.ps1 new file mode 100644 index 0000000..e332957 --- /dev/null +++ b/dump/SCCM-Tool/Forms/Form-Examples/Form-Calendar.ps1 @@ -0,0 +1,43 @@ +[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") +[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") + +$objForm = New-Object Windows.Forms.Form + +$objForm.Text = "Select a Date" +$objForm.Size = New-Object Drawing.Size @(490,250) +$objForm.StartPosition = "CenterScreen" + +$objForm.KeyPreview = $True + +$objForm.Add_KeyDown({ + if ($_.KeyCode -eq "Enter") + { + $script:dtmDate=$objCalendar.SelectionStart + $objForm.Close() + } + }) + +$objForm.Add_KeyDown({ + if ($_.KeyCode -eq "Escape") + { + $objForm.Close() + } + }) + +$objCalendar = New-Object System.Windows.Forms.MonthCalendar +$objCalendar.Text = "Start" +$objCalendar.ShowTodayCircle = $False +$objCalendar.MaxSelectionCount = 1 +$objForm.Controls.Add($objCalendar) + +$objForm.Topmost = $True + +$objForm.Add_Shown({$objForm.Activate()}) +[void] $objForm.ShowDialog() + +if ($dtmDate) + { + Write-Host "Date selected: $dtmDate" + } + +$objForm.Dispose() \ No newline at end of file diff --git a/dump/SCCM-Tool/Forms/Form-Examples/Form-Example-1.ps1 b/dump/SCCM-Tool/Forms/Form-Examples/Form-Example-1.ps1 new file mode 100644 index 0000000..d116880 --- /dev/null +++ b/dump/SCCM-Tool/Forms/Form-Examples/Form-Example-1.ps1 @@ -0,0 +1,489 @@ +############################# +# Developed by Tinniam V Ganesh +# Date 24 Apr 2012 +# Powershell GUI generated by Primal Forms CE from Sapien Technologies (http://www.sapien.com/) +######################################################################################################### +function Get-SysInfo ($strComputer) +{ + write-host “reached here” + $statusBar1.Text =”Working …” + if ($radiobutton1.checked -eq $True) + { + $wmi = Get-WmiObject Win32_ComputerSystem -Namespace “root\CIMV2" -ComputerName $strComputer|Export-csv -force “test.csv” + } + else + { + $wmi =Get-WmiObject Win32_ComputerSystem -Namespace “root\CIMV2" -ComputerName $strComputer|ConvertTo-Html|out-file -append “test.html” + } + + $statusBar1.Text =”Done.” +} + +#*============================================================================= +Function Get-BIOSInfo ($strComputer) +{ + $statusBar1.Text =”Working …” + if ($radiobutton1.checked -eq $True) + { + $wmi = Get-WmiObject Win32_BIOS -Namespace “root\CIMV2" -computername $strComputer|Export-csv -force “test.csv” + } + else + { + $wmi = Get-WmiObject Win32_BIOS -Namespace “root\CIMV2" -computername $strComputer|ConvertTo-Html|out-file -append “test.html” + } + + $statusBar1.Text =”Done.” + } + +Function Get-OSInfo { + $statusBar1.Text =”Working …” + if ($radiobutton1.checked -eq $True) + { + $wmi = Get-WmiObject Win32_OperatingSystem -Namespace “root\CIMV2" -Computername $strComputer|Export-csv -force “test.csv” + } + else + { + $wmi = Get-WmiObject Win32_OperatingSystem -Namespace “root\CIMV2" -Computername $strComputer|out-file -append “test.html” + } + + $statusBar1.Text =”Done.” +} + +Function Get-CPUInfo { + $statusBar1.Text =”Working …” + if ($radiobutton1.checked -eq $True) + { + $wmi = Get-WmiObject Win32_Processor -Namespace “root\CIMV2" -Computername $strComputer|Export-csv -force “test.csv” + } + else + { + $wmi = Get-WmiObject Win32_Processor -Namespace “root\CIMV2" -Computername $strComputer|out-file -append “test.html” + } + + $statusBar1.Text =”Done.” +} + +Function Get-DiskInfo { + + $statusBar1.Text =”Working …” + if ($radiobutton1.checked -eq $True) + { + $wmi = Get-WmiObject Win32_DiskDrive -Namespace “root\CIMV2" -ComputerName $strComputer|Export-csv -force “test.csv” + } + else + { + $wmi = Get-WmiObject Win32_DiskDrive -Namespace “root\CIMV2" -ComputerName $strComputer|out-file -append “test.html” + } + + $statusBar1.Text =”Done.” +} + +Function Get-NetworkInfo { + + $statusBar1.Text =”Working …” + if ($radiobutton1.checked -eq $True) + { + $wmi = Get-WmiObject Win32_NetworkAdapterConfiguration -Namespace “root\CIMV2" -ComputerName $strComputer | where{$_.IPEnabled -eq “True”}|Export-csv -noclobber “test.csv” + } + else + { + $wmi = Get-WmiObject Win32_NetworkAdapterConfiguration -Namespace “root\CIMV2" -ComputerName $strComputer | where{$_.IPEnabled -eq “True”}|out-file -append “test.html” + } + + $statusBar1.Text =”Done.” +} + +#Generated Form Function +function GenerateForm { +######################################################################## +# Code Generated By: SAPIEN Technologies PrimalForms (Community Edition) v1.0.10.0 +# Generated On: 4/24/2012 2:46 PM +# Generated By: tvganesh +######################################################################## + +#region Import the Assemblies +[reflection.assembly]::loadwithpartialname(“System.Windows.Forms”) | Out-Null +[reflection.assembly]::loadwithpartialname(“System.Drawing”) | Out-Null +#endregion + +#region Generated Form Objects +$form1 = New-Object System.Windows.Forms.Form +$statusBar1 = New-Object System.Windows.Forms.StatusBar +$label2 = New-Object System.Windows.Forms.Label +$button3 = New-Object System.Windows.Forms.Button +$button2 = New-Object System.Windows.Forms.Button +$tabControl1 = New-Object System.Windows.Forms.TabControl +$tabControl = New-Object System.Windows.Forms.TabPage +$groupBox1 = New-Object System.Windows.Forms.GroupBox +$radioButton2 = New-Object System.Windows.Forms.RadioButton +$radioButton1 = New-Object System.Windows.Forms.RadioButton +$label1 = New-Object System.Windows.Forms.Label +$textBox1 = New-Object System.Windows.Forms.TextBox +$comboBox1 = New-Object System.Windows.Forms.ComboBox +$Database = New-Object System.Windows.Forms.TabPage +$tabPage1 = New-Object System.Windows.Forms.TabPage +$tabPage2 = New-Object System.Windows.Forms.TabPage +$button1 = New-Object System.Windows.Forms.Button +$fontDialog1 = New-Object System.Windows.Forms.FontDialog +$InitialFormWindowState = New-Object System.Windows.Forms.FormWindowState +#endregion Generated Form Objects + +#———————————————- +#Generated Event Script Blocks +#———————————————- +#Provide Custom Code for events specified in PrimalForms. +$button3_OnClick= +{ + $form1.Close() + +} + +$button2_OnClick= +{ + $textBox1.text=”" + # Set to the first item + $comboBox1.SelectedIndex = 0; + +} + +$handler_button1_Click= +{ + $x = $textbox1.text + $vals = $x.split(“,”) + forEach($strComputer in $vals) +{ +switch($combobox1.selectedItem) + { + “SysInfo” {Get-SysInfo ($strComputer)} + “BiosInfo” {Get-BiosInfo($strComputer)} + “CPUInfo” {Get-cpuInfo($strComputer)} + “DiskInfo” {Get-diskInfo($strComputer)} + “OSInfo” {Get-OSInfo($strCOmputer)} + “NetworkInfo” {Get-NetworkInfo($strComputer)} + } +} +} + +$OnLoadForm_StateCorrection= +{#Correct the initial state of the form to prevent the .Net maximized form issue +$form1.WindowState = $InitialFormWindowState +} + +#———————————————- +#region Generated Form Code +$System_Drawing_Size = New-Object System.Drawing.Size +$System_Drawing_Size.Height = 444 +$System_Drawing_Size.Width = 704 +$form1.ClientSize = $System_Drawing_Size +$form1.DataBindings.DefaultDataSourceUpdateMode = 0 +$form1.Name = “form1" +$form1.Text = “Primal Form” + +$statusBar1.DataBindings.DefaultDataSourceUpdateMode = 0 +$System_Drawing_Point = New-Object System.Drawing.Point +$System_Drawing_Point.X = 0 +$System_Drawing_Point.Y = 422 +$statusBar1.Location = $System_Drawing_Point +$statusBar1.Name = “statusBar1" +$System_Drawing_Size = New-Object System.Drawing.Size +$System_Drawing_Size.Height = 22 +$System_Drawing_Size.Width = 704 +$statusBar1.Size = $System_Drawing_Size +$statusBar1.TabIndex = 8 +$statusBar1.Text = “Ready” + +$form1.Controls.Add($statusBar1) + +$label2.DataBindings.DefaultDataSourceUpdateMode = 0 +$label2.Font = New-Object System.Drawing.Font(“Microsoft Sans Serif”,14.25,1,3,1) + +$System_Drawing_Point = New-Object System.Drawing.Point +$System_Drawing_Point.X = 205 +$System_Drawing_Point.Y = 22 +$label2.Location = $System_Drawing_Point +$label2.Name = “label2" +$System_Drawing_Size = New-Object System.Drawing.Size +$System_Drawing_Size.Height = 34 +$System_Drawing_Size.Width = 341 +$label2.Size = $System_Drawing_Size +$label2.TabIndex = 7 +$label2.Text = “Windows Resource Management” + +$form1.Controls.Add($label2) +$button3.DataBindings.DefaultDataSourceUpdateMode = 0 + +$System_Drawing_Point = New-Object System.Drawing.Point +$System_Drawing_Point.X = 439 +$System_Drawing_Point.Y = 343 +$button3.Location = $System_Drawing_Point +$button3.Name = “button3" +$System_Drawing_Size = New-Object System.Drawing.Size +$System_Drawing_Size.Height = 23 +$System_Drawing_Size.Width = 75 +$button3.Size = $System_Drawing_Size +$button3.TabIndex = 6 +$button3.Text = “Exit” +$button3.UseVisualStyleBackColor = $True +$button3.add_Click($button3_OnClick) + +$form1.Controls.Add($button3) +$button2.DataBindings.DefaultDataSourceUpdateMode = 0 + +$System_Drawing_Point = New-Object System.Drawing.Point +$System_Drawing_Point.X = 330 +$System_Drawing_Point.Y = 343 +$button2.Location = $System_Drawing_Point +$button2.Name = “button2" +$System_Drawing_Size = New-Object System.Drawing.Size +$System_Drawing_Size.Height = 23 +$System_Drawing_Size.Width = 75 +$button2.Size = $System_Drawing_Size +$button2.TabIndex = 5 +$button2.Text = “Cancel” +$button2.UseVisualStyleBackColor = $True +$button2.add_Click($button2_OnClick) + +$form1.Controls.Add($button2) + +$tabControl1.DataBindings.DefaultDataSourceUpdateMode = 0 +$System_Drawing_Point = New-Object System.Drawing.Point +$System_Drawing_Point.X = 136 +$System_Drawing_Point.Y = 83 +$tabControl1.Location = $System_Drawing_Point +$tabControl1.Name = “tabControl1" +$tabControl1.SelectedIndex = 0 +$tabControl1.ShowToolTips = $True +$System_Drawing_Size = New-Object System.Drawing.Size +$System_Drawing_Size.Height = 231 +$System_Drawing_Size.Width = 453 +$tabControl1.Size = $System_Drawing_Size +$tabControl1.TabIndex = 4 + +$form1.Controls.Add($tabControl1) +$tabControl.DataBindings.DefaultDataSourceUpdateMode = 0 +$System_Drawing_Point = New-Object System.Drawing.Point +$System_Drawing_Point.X = 4 +$System_Drawing_Point.Y = 22 +$tabControl.Location = $System_Drawing_Point +$tabControl.Name = “tabControl” +$System_Windows_Forms_Padding = New-Object System.Windows.Forms.Padding +$System_Windows_Forms_Padding.All = 3 +$System_Windows_Forms_Padding.Bottom = 3 +$System_Windows_Forms_Padding.Left = 3 +$System_Windows_Forms_Padding.Right = 3 +$System_Windows_Forms_Padding.Top = 3 +$tabControl.Padding = $System_Windows_Forms_Padding +$System_Drawing_Size = New-Object System.Drawing.Size +$System_Drawing_Size.Height = 205 +$System_Drawing_Size.Width = 445 +$tabControl.Size = $System_Drawing_Size +$tabControl.TabIndex = 0 +$tabControl.Text = “Basic Commands” +$tabControl.UseVisualStyleBackColor = $True + +$tabControl1.Controls.Add($tabControl) + +$groupBox1.DataBindings.DefaultDataSourceUpdateMode = 0 +$System_Drawing_Point = New-Object System.Drawing.Point +$System_Drawing_Point.X = 271 +$System_Drawing_Point.Y = 123 +$groupBox1.Location = $System_Drawing_Point +$groupBox1.Name = “groupBox1" +$System_Drawing_Size = New-Object System.Drawing.Size +$System_Drawing_Size.Height = 49 +$System_Drawing_Size.Width = 124 +$groupBox1.Size = $System_Drawing_Size +$groupBox1.TabIndex = 3 +$groupBox1.TabStop = $False +$groupBox1.Text = “Save As” + +$tabControl.Controls.Add($groupBox1) + +$radioButton2.DataBindings.DefaultDataSourceUpdateMode = 0 + +$System_Drawing_Point = New-Object System.Drawing.Point +$System_Drawing_Point.X = 48 +$System_Drawing_Point.Y = 19 +$radioButton2.Location = $System_Drawing_Point +$radioButton2.Name = “radioButton2" +$System_Drawing_Size = New-Object System.Drawing.Size +$System_Drawing_Size.Height = 24 +$System_Drawing_Size.Width = 104 +$radioButton2.Size = $System_Drawing_Size +$radioButton2.TabIndex = 1 +$radioButton2.TabStop = $True +$radioButton2.Text = “HTML” +$radioButton2.UseVisualStyleBackColor = $True + +$groupBox1.Controls.Add($radioButton2) +$radioButton1.DataBindings.DefaultDataSourceUpdateMode = 0 + +$System_Drawing_Point = New-Object System.Drawing.Point +$System_Drawing_Point.X = 6 +$System_Drawing_Point.Y = 19 +$radioButton1.Location = $System_Drawing_Point +$radioButton1.Name = “radioButton1" +$System_Drawing_Size = New-Object System.Drawing.Size +$System_Drawing_Size.Height = 24 +$System_Drawing_Size.Width = 104 +$radioButton1.Size = $System_Drawing_Size +$radioButton1.TabIndex = 0 +$radioButton1.TabStop = $True +$radioButton1.Text = “CSV” +$radioButton1.UseVisualStyleBackColor = $True +$radioButton1.checked =$True + +$groupBox1.Controls.Add($radioButton1) +$label1.DataBindings.DefaultDataSourceUpdateMode = 0 + +$System_Drawing_Point = New-Object System.Drawing.Point +$System_Drawing_Point.X = 6 +$System_Drawing_Point.Y = 26 +$label1.Location = $System_Drawing_Point +$label1.Name = “label1" +$System_Drawing_Size = New-Object System.Drawing.Size +$System_Drawing_Size.Height = 20 +$System_Drawing_Size.Width = 192 +$label1.Size = $System_Drawing_Size +$label1.TabIndex = 2 +$label1.Text = “Enter comma separated server list” + +$tabControl.Controls.Add($label1) + +$textBox1.DataBindings.DefaultDataSourceUpdateMode = 0 +$System_Drawing_Point = New-Object System.Drawing.Point +$System_Drawing_Point.X = 220 +$System_Drawing_Point.Y = 26 +$textBox1.Location = $System_Drawing_Point +$textBox1.Name = “textBox1" +$System_Drawing_Size = New-Object System.Drawing.Size +$System_Drawing_Size.Height = 20 +$System_Drawing_Size.Width = 203 +$textBox1.Size = $System_Drawing_Size +$textBox1.TabIndex = 1 + +$tabControl.Controls.Add($textBox1) + +$comboBox1.DataBindings.DefaultDataSourceUpdateMode = 0 +$comboBox1.FormattingEnabled = $True +$System_Drawing_Point = New-Object System.Drawing.Point +$System_Drawing_Point.X = 220 +$System_Drawing_Point.Y = 79 +$comboBox1.Location = $System_Drawing_Point +$comboBox1.Name = “comboBox1" +$System_Drawing_Size = New-Object System.Drawing.Size +$System_Drawing_Size.Height = 21 +$System_Drawing_Size.Width = 200 +$comboBox1.Size = $System_Drawing_Size +$comboBox1.TabIndex = 0 + +$commands = @(“SysInfo”,”BIOSInfo”,”OSInfo”,”CPUInfo”,”DiskInfo”,”NetworkInfo”) +ForEach ($command in $commands){ +$comboBox1.items.add($command) +} +$tabControl.Controls.Add($comboBox1) + +# Set to the first item +$comboBox1.SelectedIndex = 0; +$Database.DataBindings.DefaultDataSourceUpdateMode = 0 +$System_Drawing_Point = New-Object System.Drawing.Point +$System_Drawing_Point.X = 4 +$System_Drawing_Point.Y = 22 +$Database.Location = $System_Drawing_Point +$Database.Name = “Database” +$System_Windows_Forms_Padding = New-Object System.Windows.Forms.Padding +$System_Windows_Forms_Padding.All = 3 +$System_Windows_Forms_Padding.Bottom = 3 +$System_Windows_Forms_Padding.Left = 3 +$System_Windows_Forms_Padding.Right = 3 +$System_Windows_Forms_Padding.Top = 3 +$Database.Padding = $System_Windows_Forms_Padding +$System_Drawing_Size = New-Object System.Drawing.Size +$System_Drawing_Size.Height = 205 +$System_Drawing_Size.Width = 445 +$Database.Size = $System_Drawing_Size +$Database.TabIndex = 1 +$Database.Text = “Database” +$Database.UseVisualStyleBackColor = $True + +$tabControl1.Controls.Add($Database) + +$tabPage1.DataBindings.DefaultDataSourceUpdateMode = 0 +$System_Drawing_Point = New-Object System.Drawing.Point +$System_Drawing_Point.X = 4 +$System_Drawing_Point.Y = 22 +$tabPage1.Location = $System_Drawing_Point +$tabPage1.Name = “tabPage1" +$System_Windows_Forms_Padding = New-Object System.Windows.Forms.Padding +$System_Windows_Forms_Padding.All = 3 +$System_Windows_Forms_Padding.Bottom = 3 +$System_Windows_Forms_Padding.Left = 3 +$System_Windows_Forms_Padding.Right = 3 +$System_Windows_Forms_Padding.Top = 3 +$tabPage1.Padding = $System_Windows_Forms_Padding +$System_Drawing_Size = New-Object System.Drawing.Size +$System_Drawing_Size.Height = 205 +$System_Drawing_Size.Width = 445 +$tabPage1.Size = $System_Drawing_Size +$tabPage1.TabIndex = 2 +$tabPage1.Text = “Active Directory” +$tabPage1.UseVisualStyleBackColor = $True + +$tabControl1.Controls.Add($tabPage1) + +$tabPage2.DataBindings.DefaultDataSourceUpdateMode = 0 +$System_Drawing_Point = New-Object System.Drawing.Point +$System_Drawing_Point.X = 4 +$System_Drawing_Point.Y = 22 +$tabPage2.Location = $System_Drawing_Point +$tabPage2.Name = “tabPage2" +$System_Windows_Forms_Padding = New-Object System.Windows.Forms.Padding +$System_Windows_Forms_Padding.All = 3 +$System_Windows_Forms_Padding.Bottom = 3 +$System_Windows_Forms_Padding.Left = 3 +$System_Windows_Forms_Padding.Right = 3 +$System_Windows_Forms_Padding.Top = 3 +$tabPage2.Padding = $System_Windows_Forms_Padding +$System_Drawing_Size = New-Object System.Drawing.Size +$System_Drawing_Size.Height = 205 +$System_Drawing_Size.Width = 445 +$tabPage2.Size = $System_Drawing_Size +$tabPage2.TabIndex = 3 +$tabPage2.Text = “Backup & Restore” +$tabPage2.UseVisualStyleBackColor = $True + +$tabControl1.Controls.Add($tabPage2) + +$button1.DataBindings.DefaultDataSourceUpdateMode = 0 + +$System_Drawing_Point = New-Object System.Drawing.Point +$System_Drawing_Point.X = 226 +$System_Drawing_Point.Y = 343 +$button1.Location = $System_Drawing_Point +$button1.Name = “button1" +$System_Drawing_Size = New-Object System.Drawing.Size +$System_Drawing_Size.Height = 23 +$System_Drawing_Size.Width = 75 +$button1.Size = $System_Drawing_Size +$button1.TabIndex = 0 +$button1.Text = “Submit” +$button1.UseVisualStyleBackColor = $True +$button1.add_Click($handler_button1_Click) + +$form1.Controls.Add($button1) + +$fontDialog1.ShowHelp = $True + +#endregion Generated Form Code + +#Save the initial state of the form +$InitialFormWindowState = $form1.WindowState +#Init the OnLoad event to correct the initial state of the form +$form1.add_Load($OnLoadForm_StateCorrection) +#Show the Form +$form1.ShowDialog()| Out-Null + +} #End Function + +#Call the Function +GenerateForm \ No newline at end of file diff --git a/dump/SCCM-Tool/Forms/Form-Examples/Form-Example-2.ps1 b/dump/SCCM-Tool/Forms/Form-Examples/Form-Example-2.ps1 new file mode 100644 index 0000000..c3fa090 --- /dev/null +++ b/dump/SCCM-Tool/Forms/Form-Examples/Form-Example-2.ps1 @@ -0,0 +1,144 @@ +# Show message box popup. +Add-Type -AssemblyName System.Windows.Forms +$result = [System.Windows.Forms.MessageBox]::Show("My message", "Window Title", [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::None) + +# Show input box popup. +Add-Type -AssemblyName Microsoft.VisualBasic +$inputText = [Microsoft.VisualBasic.Interaction]::InputBox("Enter some value:", "Window Title", "Default value") + +# Show an Open File Dialog and return the file selected by the user. +function Read-OpenFileDialog([string]$InitialDirectory, [switch]$AllowMultiSelect) +{ + Add-Type -AssemblyName System.Windows.Forms + $openFileDialog = New-Object System.Windows.Forms.OpenFileDialog + $openFileDialog.initialDirectory = $InitialDirectory + $openFileDialog.filter = "All files (*.*)| *.*" + if ($AllowMultiSelect) { $openFileDialog.MultiSelect = $true } + $openFileDialog.ShowDialog() > $null + if ($allowMultiSelect) { return $openFileDialog.Filenames } else { return $openFileDialog.Filename } +} + + +# Show an Open Folder Dialog and return the directory selected by the user. +function Read-FolderBrowserDialog([string]$InitialDirectory) +{ + Add-Type -AssemblyName System.Windows.Forms + $openFolderDialog = New-Object System.Windows.Forms.FolderBrowserDialog + $openFolderDialog.ShowNewFolderButton = $true + $openFolderDialog.RootFolder = $InitialDirectory + $openFolderDialog.ShowDialog() + return $openFolderDialog.SelectedPath +} + +# Prompt for multi-line user input: +function Read-MultiLineInputDialog([string]$Message, [string]$WindowTitle, [string]$DefaultText) +{ +<# + .SYNOPSIS + Prompts the user with a multi-line input box and returns the text they enter, or null if they cancelled the prompt. + + .DESCRIPTION + Prompts the user with a multi-line input box and returns the text they enter, or null if they cancelled the prompt. + + .PARAMETER Message + The message to display to the user explaining what text we are asking them to enter. + + .PARAMETER WindowTitle + The text to display on the prompt window's title. + + .PARAMETER DefaultText + The default text to show in the input box. + + .EXAMPLE + $userText = Read-MultiLineInputDialog "Input some text please:" "Get User's Input" + + Shows how to create a simple prompt to get mutli-line input from a user. + + .EXAMPLE + # Setup the default multi-line address to fill the input box with. + $defaultAddress = @' + John Doe + 123 St. + Some Town, SK, Canada + A1B 2C3 + '@ + + $address = Read-MultiLineInputDialog "Please enter your full address, including name, street, city, and postal code:" "Get User's Address" $defaultAddress + if ($address -eq $null) + { + Write-Error "You pressed the Cancel button on the multi-line input box." + } + + Prompts the user for their address and stores it in a variable, pre-filling the input box with a default multi-line address. + If the user pressed the Cancel button an error is written to the console. + + .EXAMPLE + $inputText = Read-MultiLineInputDialog -Message "If you have a really long message you can break it apart`nover two lines with the powershell newline character:" -WindowTitle "Window Title" -DefaultText "Default text for the input box." + + Shows how to break the second parameter (Message) up onto two lines using the powershell newline character (`n). + If you break the message up into more than two lines the extra lines will be hidden behind or show ontop of the TextBox. + + .NOTES + Name: Show-MultiLineInputDialog + Author: Daniel Schroeder (originally based on the code shown at http://technet.microsoft.com/en-us/library/ff730941.aspx) + Version: 1.0 +#> + Add-Type -AssemblyName System.Drawing + Add-Type -AssemblyName System.Windows.Forms + + # Create the Label. + $label = New-Object System.Windows.Forms.Label + $label.Location = New-Object System.Drawing.Size(10,10) + $label.Size = New-Object System.Drawing.Size(280,20) + $label.AutoSize = $true + $label.Text = $Message + + # Create the TextBox used to capture the user's text. + $textBox = New-Object System.Windows.Forms.TextBox + $textBox.Location = New-Object System.Drawing.Size(10,40) + $textBox.Size = New-Object System.Drawing.Size(575,200) + $textBox.AcceptsReturn = $true + $textBox.AcceptsTab = $false + $textBox.Multiline = $true + $textBox.ScrollBars = 'Both' + $textBox.Text = $DefaultText + + # Create the OK button. + $okButton = New-Object System.Windows.Forms.Button + $okButton.Location = New-Object System.Drawing.Size(510,250) + $okButton.Size = New-Object System.Drawing.Size(75,25) + $okButton.Text = "OK" + $okButton.Add_Click({ $form.Tag = $textBox.Text; $form.Close() }) + + # Create the Cancel button. + $cancelButton = New-Object System.Windows.Forms.Button + $cancelButton.Location = New-Object System.Drawing.Size(415,250) + $cancelButton.Size = New-Object System.Drawing.Size(75,25) + $cancelButton.Text = "Cancel" + $cancelButton.Add_Click({ $form.Tag = $null; $form.Close() }) + + # Create the form. + $form = New-Object System.Windows.Forms.Form + $form.Text = $WindowTitle + $form.Size = New-Object System.Drawing.Size(600,310) + $form.FormBorderStyle = 'FixedSingle' + $form.StartPosition = "CenterScreen" + $form.AutoSizeMode = 'GrowAndShrink' + $form.Topmost = $True + $form.AcceptButton = $okButton + $form.CancelButton = $cancelButton + $form.ShowInTaskbar = $true + + # Add all of the controls to the form. + $form.Controls.Add($label) + $form.Controls.Add($textBox) + $form.Controls.Add($okButton) + $form.Controls.Add($cancelButton) + + # Initialize and show the form. + $form.Add_Shown({$form.Activate()}) + $form.ShowDialog() > $null # Trash the text of the button that was clicked. + + # Return the text that the user entered. + return $form.Tag +} \ No newline at end of file diff --git a/dump/SCCM-Tool/Forms/Form-Examples/Form-Example-3.ps1 b/dump/SCCM-Tool/Forms/Form-Examples/Form-Example-3.ps1 new file mode 100644 index 0000000..0880409 --- /dev/null +++ b/dump/SCCM-Tool/Forms/Form-Examples/Form-Example-3.ps1 @@ -0,0 +1,114 @@ +$ErrorActionPreference = "SilentlyContinue" +Import-Module ActiveDirectory +#Generated Form Function +function GenerateForm { +######################################################################## +# Code Generated By: SAPIEN Technologies PrimalForms (Community Edition) v1.0.10.0 +# Generated On: 8/20/2013 12:23 AM +# Generated By: Subsun +######################################################################## + +#region Import the Assemblies +[reflection.assembly]::loadwithpartialname("System.Windows.Forms") | Out-Null +[reflection.assembly]::loadwithpartialname("System.Drawing") | Out-Null +#endregion + +#region Generated Form Objects +$form1 = New-Object System.Windows.Forms.Form +$richTextBox1 = New-Object System.Windows.Forms.RichTextBox +$Find = New-Object System.Windows.Forms.Button +$textBox1 = New-Object System.Windows.Forms.TextBox +$InitialFormWindowState = New-Object System.Windows.Forms.FormWindowState +#endregion Generated Form Objects + +#---------------------------------------------- +#Generated Event Script Blocks +#---------------------------------------------- +#Provide Custom Code for events specified in PrimalForms. +$handler_Find_Click= +{ +#TODO: Place custom script here +$User = Get-Aduser $textBox1.Text -Properties Name,homeDirectory,SamAccountName,CanonicalName | Select Name,homeDirectory,SamAccountName,CanonicalName +If ($User) { +$richTextBox1.Text = $User | FL Name,homeDirectory,SamAccountName,CanonicalName | Out-String +}Else { +$richTextBox1.Text = "Error in finding $($textBox1.Text)" +} +} + +$OnLoadForm_StateCorrection= +{#Correct the initial state of the form to prevent the .Net maximized form issue + $form1.WindowState = $InitialFormWindowState +} + +#---------------------------------------------- +#region Generated Form Code +$System_Drawing_Size = New-Object System.Drawing.Size +$System_Drawing_Size.Height = 212 +$System_Drawing_Size.Width = 477 +$form1.ClientSize = $System_Drawing_Size +$form1.DataBindings.DefaultDataSourceUpdateMode = 0 +$form1.Name = "form1" +$form1.Text = "ADFind" + +$richTextBox1.DataBindings.DefaultDataSourceUpdateMode = 0 +$System_Drawing_Point = New-Object System.Drawing.Point +$System_Drawing_Point.X = 12 +$System_Drawing_Point.Y = 38 +$richTextBox1.Location = $System_Drawing_Point +$richTextBox1.Name = "richTextBox1" +$System_Drawing_Size = New-Object System.Drawing.Size +$System_Drawing_Size.Height = 162 +$System_Drawing_Size.Width = 450 +$richTextBox1.Size = $System_Drawing_Size +$richTextBox1.TabIndex = 2 +$richTextBox1.font = "Courier New" +$richTextBox1.Text = "" + +$form1.Controls.Add($richTextBox1) + + +$Find.DataBindings.DefaultDataSourceUpdateMode = 0 + +$System_Drawing_Point = New-Object System.Drawing.Point +$System_Drawing_Point.X = 353 +$System_Drawing_Point.Y = 8 +$Find.Location = $System_Drawing_Point +$Find.Name = "Find" +$System_Drawing_Size = New-Object System.Drawing.Size +$System_Drawing_Size.Height = 23 +$System_Drawing_Size.Width = 109 +$Find.Size = $System_Drawing_Size +$Find.TabIndex = 1 +$Find.Text = "Find" +$Find.UseVisualStyleBackColor = $True +$Find.add_Click($handler_Find_Click) + +$form1.Controls.Add($Find) + +$textBox1.DataBindings.DefaultDataSourceUpdateMode = 0 +$System_Drawing_Point = New-Object System.Drawing.Point +$System_Drawing_Point.X = 12 +$System_Drawing_Point.Y = 12 +$textBox1.Location = $System_Drawing_Point +$textBox1.Name = "textBox1" +$System_Drawing_Size = New-Object System.Drawing.Size +$System_Drawing_Size.Height = 20 +$System_Drawing_Size.Width = 320 +$textBox1.Size = $System_Drawing_Size +$textBox1.TabIndex = 0 +$form1.Controls.Add($textBox1) + +#endregion Generated Form Code + +#Save the initial state of the form +$InitialFormWindowState = $form1.WindowState +#Init the OnLoad event to correct the initial state of the form +$form1.add_Load($OnLoadForm_StateCorrection) +#Show the Form +$form1.ShowDialog()| Out-Null + +} #End Function + +#Call the Function +GenerateForm diff --git a/dump/SCCM-Tool/Forms/Form-Examples/Form-Test-1.ps1 b/dump/SCCM-Tool/Forms/Form-Examples/Form-Test-1.ps1 new file mode 100644 index 0000000..1176695 --- /dev/null +++ b/dump/SCCM-Tool/Forms/Form-Examples/Form-Test-1.ps1 @@ -0,0 +1,50 @@ +Add-Type -AssemblyName System.Windows.Forms + +$Form = New-Object system.Windows.Forms.Form +$Form.Text = "Sample Form" +$Form.AutoScroll = $True +$Form.width = 500 +$Form.height = 300 +$Form.AutoSize = $True +#$Form.AutoSizeMode = "GrowAndShrink" + # or GrowOnly + +$Form.MinimizeBox = $False +$Form.MaximizeBox = $False +$Form.WindowState = "Normal" + # Maximized, Minimized, Normal + +$Form.SizeGripStyle = "Hide" + # Auto, Hide, Show + +$Form.ShowInTaskbar = $False +#$Form.Opacity = 0.7 + # 1.0 is fully opaque; 0.0 is invisible + +$Form.BackColor = "Lime" + # color names are static properties of System.Drawing.Color + # you can also use ARGB values, such as "#FFFFEBCD" + +$Form.StartPosition = "CenterScreen" + # CenterScreen, Manual, WindowsDefaultLocation, WindowsDefaultBounds, CenterParent + +$Form.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon($PSHome + "\powershell.exe") +#$Font = New-Object System.Drawing.Font("Times New Roman",24,[System.Drawing.FontStyle]::Italic) + # Font styles are: Regular, Bold, Italic, Underline, Strikeout + +#$Form.Font = $Font +$Label = New-Object System.Windows.Forms.Label +$Label.Text = "This form is very simple." +$Label.AutoSize = $True + +$Form.Controls.Add($Label) + +$OKButton = New-Object System.Windows.Forms.Button +$OKButton.Location = New-Object System.Drawing.Size(75,120) +$OKButton.Size = New-Object System.Drawing.Size(75,23) +$OKButton.Text = "Get Service" +$OKButton.Add_Click({$Form.Close()}) +$Form.Controls.Add($OKButton) + + +$Form.ShowDialog() \ No newline at end of file diff --git a/dump/SCCM-Tool/Forms/Form-Examples/Form-Test-button-2.ps1 b/dump/SCCM-Tool/Forms/Form-Examples/Form-Test-button-2.ps1 new file mode 100644 index 0000000..cb71cf4 --- /dev/null +++ b/dump/SCCM-Tool/Forms/Form-Examples/Form-Test-button-2.ps1 @@ -0,0 +1,91 @@ +[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") +[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") + +$Form = New-Object System.Windows.Forms.Form +$Form.Size = New-Object System.Drawing.Size(600,400) + +############################################## Start functions + +function pingInfo { +$wks=$InputBox.text; +$pingResult=Test-Connection -ComputerName $wks -Count 1 | out-string; +$outputBox.text=$pingResult + } #end pingInfo + +############################################## end functions +Function NA-GetHardDriveInfo { + $Computer = $InputBox.Text + $HDInfo = Gwmi Win32_logicaldisk -ComputerName $Computer -Filter "Drivetype = '3'" | ft -AutoSize | Out-String + $outputBox.Text = $HDInfo + + +} + +############################################## Start text fields +Function NA-GetProcess { + $Computer = $InputBox.Text + + $Proc = Get-Process -ComputerName $Computer | % { + + $Obj = New-Object -TypeName PSObject + $Obj | Add-Member -MemberType NoteProperty -Name Handles -Value $_.handles + $Obj | Add-Member -MemberType NoteProperty -Name NPM -Value $_.npm + $Obj | Add-Member -MemberType NoteProperty -Name PM -Value $_.pm + $Obj | Add-Member -MemberType NoteProperty -Name WS -Value $_.WS + $Obj | Add-Member -MemberType NoteProperty -Name VM -Value $_.vm + $Obj | Add-Member -MemberType NoteProperty -Name CPU -Value $_.cpu + $Obj | Add-Member -MemberType NoteProperty -Name ID -Value $_.ID + $Obj | Add-Member -MemberType NoteProperty -Name ProcessName -Value $_.ProcessName + $Obj + + } + $outputBox.Text = $Proc +} +############################################## end functions + +$InputBox = New-Object System.Windows.Forms.TextBox +$InputBox.Location = New-Object System.Drawing.Size(20,50) +$InputBox.Size = New-Object System.Drawing.Size(150,20) +$Form.Controls.Add($InputBox) + +$outputBox = New-Object System.Windows.Forms.TextBox +$outputBox.Location = New-Object System.Drawing.Size(10,150) +$outputBox.Size = New-Object System.Drawing.Size(565,200) +$outputBox.MultiLine = $True +$outputBox.ScrollBars = "Vertical" +$Form.Controls.Add($outputBox) + +############################################## end text fields + +############################################## Start buttons + +$Button = New-Object System.Windows.Forms.Button +$Button.Location = New-Object System.Drawing.Size(400,30) +$Button.Size = New-Object System.Drawing.Size(80,20) +$Button.Text = "Ping" +$Button.Add_Click({pingInfo}) +$Form.Controls.Add($Button) + +############################################## end buttons + + +$Button_HDrive = New-Object System.Windows.Forms.Button +$Button_HDrive.Location = New-Object System.Drawing.Size(400,50) +$Button_HDrive.Size = New-Object System.Drawing.Size(80,20) +$Button_HDrive.Text = "Hard Drive" +$Button_HDrive.Add_Click({NA-GetHardDriveInfo}) +$Form.Controls.Add($Button_HDrive) + +############################################## end button_HDrive + +$Button_Proc = New-Object System.Windows.Forms.Button +$Button_Proc.Location = New-Object System.Drawing.Size(400,70) +$Button_Proc.Size = New-Object System.Drawing.Size(80,20) +$Button_Proc.Text = "Processes" +$Button_Proc.Add_Click({NA-GetProcess}) +$Form.Controls.Add($Button_Proc) + + + +$Form.Add_Shown({$Form.Activate()}) +[void] $Form.ShowDialog() \ No newline at end of file diff --git a/dump/SCCM-Tool/Forms/Form-Examples/Form-Test-button.ps1 b/dump/SCCM-Tool/Forms/Form-Examples/Form-Test-button.ps1 new file mode 100644 index 0000000..e8f226a --- /dev/null +++ b/dump/SCCM-Tool/Forms/Form-Examples/Form-Test-button.ps1 @@ -0,0 +1,45 @@ +[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") +[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") + +$Form = New-Object System.Windows.Forms.Form +$Form.Size = New-Object System.Drawing.Size(600,400) + +############################################## Start functions + +function pingInfo { +$wks=$InputBox.text; +$pingResult=ping $wks | fl | out-string; +$outputBox.text=$pingResult + } #end pingInfo + +############################################## end functions + +############################################## Start text fields + +$InputBox = New-Object System.Windows.Forms.TextBox +$InputBox.Location = New-Object System.Drawing.Size(20,50) +$InputBox.Size = New-Object System.Drawing.Size(150,20) +$Form.Controls.Add($InputBox) + +$outputBox = New-Object System.Windows.Forms.TextBox +$outputBox.Location = New-Object System.Drawing.Size(10,150) +$outputBox.Size = New-Object System.Drawing.Size(565,200) +$outputBox.MultiLine = $True +$outputBox.ScrollBars = "Vertical" +$Form.Controls.Add($outputBox) + +############################################## end text fields + +############################################## Start buttons + +$Button = New-Object System.Windows.Forms.Button +$Button.Location = New-Object System.Drawing.Size(400,30) +$Button.Size = New-Object System.Drawing.Size(110,80) +$Button.Text = "Ping" +$Button.Add_Click({pingInfo}) +$Form.Controls.Add($Button) + +############################################## end buttons + +$Form.Add_Shown({$Form.Activate()}) +[void] $Form.ShowDialog() \ No newline at end of file diff --git a/dump/SCCM-Tool/Forms/Form-Examples/Form-WebBrowser.ps1 b/dump/SCCM-Tool/Forms/Form-Examples/Form-WebBrowser.ps1 new file mode 100644 index 0000000..0e77d71 --- /dev/null +++ b/dump/SCCM-Tool/Forms/Form-Examples/Form-WebBrowser.ps1 @@ -0,0 +1,165 @@ +#======================================================================== +# Code Generated By: SAPIEN Technologies, Inc., PowerShell Studio 2012 v3.1.13 +# Generated On: 12/18/2012 2:15 PM +# Generated By: James Vierra +# Organization: Designed Systems & Services +#======================================================================== +#---------------------------------------------- +#region Application Functions +#---------------------------------------------- +function OnApplicationLoad { + #Note: This function is not called in Projects + #Note: This function runs before the form is created + #Note: To get the script directory in the Packager use: Split-Path $hostinvocation.MyCommand.path + #Note: To get the console output in the Packager (Windows Mode) use: $ConsoleOutput (Type: System.Collections.ArrayList) + #Important: Form controls cannot be accessed in this function + #TODO: Add snapins and custom code to validate the application load + + return $true #return true for success or false for failure +} +function OnApplicationExit { + #Note: This function is not called in Projects + #Note: This function runs after the form is closed + #TODO: Add custom code to clean up and unload snapins when the application exits + + $script:ExitCode = 0 #Set the exit code for the Packager +} +#endregion Application Functions +#---------------------------------------------- +# Generated Form Function +#---------------------------------------------- +function Call-Demo-WebBrowserCtl_pff { + #---------------------------------------------- + #region Import the Assemblies + #---------------------------------------------- + [void][reflection.assembly]::LoadWithPartialName("System.Windows.Forms") + [void][reflection.assembly]::Load("System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a") + [void][reflection.assembly]::Load("System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089") + [void][reflection.assembly]::Load("System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089") + [void][reflection.assembly]::Load("System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089") + [void][reflection.assembly]::Load("System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a") + [void][reflection.assembly]::Load("System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089") + #endregion Import Assemblies + #---------------------------------------------- + #region Generated Form Objects + #---------------------------------------------- + [System.Windows.Forms.Application]::EnableVisualStyles() + $form1 = New-Object 'System.Windows.Forms.Form' + $buttonGetElement = New-Object 'System.Windows.Forms.Button' + $webbrowser1 = New-Object 'System.Windows.Forms.WebBrowser' + $buttonOK = New-Object 'System.Windows.Forms.Button' + $InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState' + #endregion Generated Form Objects + #---------------------------------------------- + # User Generated Script + #---------------------------------------------- + + + + + + + + $FormEvent_Load={ + #TODO: Initialize Form Controls here + $webbrowser1.navigate("http://www.google.com") + } + + $buttonGetElement_Click={ + #TODO: Place custom script here + $el=$webbrowser1.Document.GetElementById('gstyle') + [System.Windows.Forms.MessageBox]::Show($el.InnerHtml) + + } + + # --End User Generated Script-- + #---------------------------------------------- + #region Generated Events + #---------------------------------------------- + + $Form_StateCorrection_Load= + { + #Correct the initial state of the form to prevent the .Net maximized form issue + $form1.WindowState = $InitialFormWindowState + } + + $Form_Cleanup_FormClosed= + { + #Remove all event handlers from the controls + try + { + $buttonGetElement.remove_Click($buttonGetElement_Click) + $form1.remove_Load($FormEvent_Load) + $form1.remove_Load($Form_StateCorrection_Load) + $form1.remove_FormClosed($Form_Cleanup_FormClosed) + } + catch [Exception] + { } + } + #endregion Generated Events + #---------------------------------------------- + #region Generated Form Code + #---------------------------------------------- + # + # form1 + # + $form1.Controls.Add($buttonGetElement) + $form1.Controls.Add($webbrowser1) + $form1.Controls.Add($buttonOK) + $form1.AcceptButton = $buttonOK + $form1.ClientSize = '520, 475' + $form1.FormBorderStyle = 'FixedDialog' + $form1.MaximizeBox = $False + $form1.MinimizeBox = $False + $form1.Name = "form1" + $form1.StartPosition = 'CenterScreen' + $form1.Text = "Form" + $form1.add_Load($FormEvent_Load) + # + # buttonGetElement + # + $buttonGetElement.Location = '50, 438' + $buttonGetElement.Name = "buttonGetElement" + $buttonGetElement.Size = '84, 24' + $buttonGetElement.TabIndex = 2 + $buttonGetElement.Text = "Get Element" + $buttonGetElement.UseVisualStyleBackColor = $True + $buttonGetElement.add_Click($buttonGetElement_Click) + # + # webbrowser1 + # + $webbrowser1.Location = '39, 127' + $webbrowser1.MinimumSize = '20, 20' + $webbrowser1.Name = "webbrowser1" + $webbrowser1.Size = '569, 385' + $webbrowser1.TabIndex = 1 + # + # buttonOK + # + $buttonOK.Anchor = 'Bottom, Right' + $buttonOK.DialogResult = 'OK' + $buttonOK.Location = '433, 440' + $buttonOK.Name = "buttonOK" + $buttonOK.Size = '75, 23' + $buttonOK.TabIndex = 0 + $buttonOK.Text = "OK" + $buttonOK.UseVisualStyleBackColor = $True + #endregion Generated Form Code + #---------------------------------------------- + #Save the initial state of the form + $InitialFormWindowState = $form1.WindowState + #Init the OnLoad event to correct the initial state of the form + $form1.add_Load($Form_StateCorrection_Load) + #Clean up the control events + $form1.add_FormClosed($Form_Cleanup_FormClosed) + #Show the Form + return $form1.ShowDialog() +} #End Function +#Call OnApplicationLoad to initialize +if((OnApplicationLoad) -eq $true) +{ + #Call the form + Call-Demo-WebBrowserCtl_pff | Out-Null + #Perform cleanup + OnApplicationExit +} \ No newline at end of file diff --git a/dump/SCCM-Tool/Forms/Form-Examples/ListView.ps1 b/dump/SCCM-Tool/Forms/Form-Examples/ListView.ps1 new file mode 100644 index 0000000..08f98e4 Binary files /dev/null and b/dump/SCCM-Tool/Forms/Form-Examples/ListView.ps1 differ diff --git a/dump/SCCM-Tool/Forms/Services-Tool-18.ps1 b/dump/SCCM-Tool/Forms/Services-Tool-18.ps1 new file mode 100644 index 0000000..82949d0 --- /dev/null +++ b/dump/SCCM-Tool/Forms/Services-Tool-18.ps1 @@ -0,0 +1,1041 @@ +#------------------------------------------------------------------------ +# Source File Information (DO NOT MODIFY) +# Source ID: cfd5eaf9-beed-4b19-b790-f40186f5782a +# Source File: test-tools.psf +#------------------------------------------------------------------------ +#region File Recovery Data (DO NOT MODIFY) +<#RecoveryData: +Gw8AAB+LCAAAAAAABADVl19v2jAUxd8n7TtEeWZAApQyhUglbaVp7VqNrtsbcpxL69WxkeO0ZJ9+ +dgKUQWicliJNSCh/jnOP/Ts3VrzvgPkjiOwUSWSpg4RwNrTdpmP7Hz9YlnclyB1hiJ4TCt9QDL6E +RH6SnNOkOUumXmtLUAwLfwOWlsxmMLTHWSIhbv4kLOJPSfOci7j4b1hltxrW7cJHt9nWv4YVpFSm +AoYMUikQbVjXaUgJ/grZDX8ANgz7fdTDvSNn0OlC+3hgW0xZGdpT9TzHtvA9oZFQOjvgTArlvZid +Mnot+AyEzBYDTlLJxxhROCUxMG1CSY8altPxWktp1dBLHoHtn6tKlWMCSoDJMfmjBvSdbsPqOm7l +IL3Ktp9PrVJ7A3OpvYh4W3r2qGovdBccRYtnTvSx18rvLqXVOC9QCPTdeY5BqIy+BHQHl3yFb0QK +W8uwPeCCYySVXdt3XEV+G8guJIU7A3lhp+uU5qoEIgq/sAjmKokm6hx54eVzmX6duwogfliqJ/nZ +BvpWwd48Cbr+iM/fPQtXqZylsl4WNtB22wbrean8EUqYeYCKNBT+TNKAlWk6QkIZH3F5bxygo4Fa +PrdjEtDnCPWqIqH5BfeI3UG0nMRk7dr/Eo8i0jmKN0TEHdTsfn1sDNBpa4AmIXzmV7IR1WYQ8Djk +h4CAdaGQz1/cg7dnq20gKQm7O2MopDqI9d/dg04tfCur5vRc9QJ3TfTP9Ep7db37xkAVPIhy/aoN +V+YmZfff2pKjVErODtKRBL++HZ2+Wu7jWv2oyhnj7Gua9bZjI/ar7djMzI8EbkmSIjqWGYURwg8B +p1zs7oAd27mqVrmf/3tykiQQK5KQLLWLK5kfJ5gLSsI9pMFrrZ66WaXI3yFq7D3j1RX1B9ZhCgn0 +pN6cr6nV7kx70/7UcaJeG3VQda1fMT3InAIuYP+FVqdF5L3W+sew/xcQ1MXoGw8AAA==#> +#endregion + +<# + .NOTES + + .DESCRIPTION + GUI script generated by PowerShell Studio 2016 +#> +#---------------------------------------------- +#region Application Functions +#---------------------------------------------- + +#endregion Application Functions + +#---------------------------------------------- +# Generated Form Function +#---------------------------------------------- +function Show-test-tools_psf { + + #---------------------------------------------- + #region Import the Assemblies + #---------------------------------------------- + [void][reflection.assembly]::Load('System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') + [void][reflection.assembly]::Load('System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') + [void][reflection.assembly]::Load('System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') + #endregion Import Assemblies + + #---------------------------------------------- + #region Generated Form Objects + #---------------------------------------------- + [System.Windows.Forms.Application]::EnableVisualStyles() + $form1 = New-Object 'System.Windows.Forms.Form' + $panel1 = New-Object 'System.Windows.Forms.Panel' + + $Progressbar = New-Object 'System.Windows.Forms.ProgressBar' + $Services = New-Object 'System.Windows.Forms.Label' + $Output = New-Object 'System.Windows.Forms.TextBox' + $ServerName = New-Object 'System.Windows.Forms.TextBox' + $combobox1 = New-Object 'System.Windows.Forms.ComboBox' + $ButtonConnectServer = New-Object 'System.Windows.Forms.Button' + $ButtonDisplayServices = New-Object 'System.Windows.Forms.Button' + $ButtonServiceStatus = New-Object 'System.Windows.Forms.Button' + $ButtonServiceStart = New-Object 'System.Windows.Forms.Button' + $ButtonServiceStop = New-Object 'System.Windows.Forms.Button' + $ButtonServiceRestart = New-Object 'System.Windows.Forms.Button' + $ButtonServiceAutomatic = New-Object 'System.Windows.Forms.Button' + $ButtonServiceDisabled = New-Object 'System.Windows.Forms.Button' + $ButtonServiceManual = New-Object 'System.Windows.Forms.Button' + $labelServerOS = New-Object 'System.Windows.Forms.Label' + $labelDisplayOS = New-Object 'System.Windows.Forms.Label' + $labelServerIP = New-Object 'System.Windows.Forms.Label' + $labelDisplayIP = New-Object 'System.Windows.Forms.Label' + $labelServerDomain = New-Object 'System.Windows.Forms.Label' + $labelDisplayDomain = New-Object 'System.Windows.Forms.Label' + $labelServerType = New-Object 'System.Windows.Forms.Label' + $labelDisplayServerInfo = New-Object 'System.Windows.Forms.Label' + $labelFilterService = New-Object 'System.Windows.Forms.Label' + $ComboboxServiceStartMode = New-Object 'System.Windows.Forms.ComboBox' + $ComboboxServiceState = New-Object 'System.Windows.Forms.ComboBox' + + $labelProcProcesses = New-Object 'System.Windows.Forms.Label' + $ButtonProcDisplay = New-Object 'System.Windows.Forms.Button' + $ButtonProcStatus = New-Object 'System.Windows.Forms.Button' + $ButtonKillProcess = New-Object 'System.Windows.Forms.Button' + $ComboboxProc = New-Object 'System.Windows.Forms.ComboBox' + $ComboboxProcSort = New-Object 'System.Windows.Forms.ComboBox' + + $InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState' + + $Global:ServerName = "" + $Global:ServiceStatus = "" + $Global:Serv = "" + $Global:Proc = "" + $Global:ProcessStatus = "" + $Global:StartMode = "" + + #NA-ClearGlobalVariables + #$Output.text = $Global:proc | ft -AutoSize | Out-String + #$combobox1.Text = $env:COMPUTERNAME | Out-String + #endregion Generated Form Objects + + #---------------------------------------------- + # User Generated Script + #---------------------------------------------- + + $Progressbar_Click={} + + $combobox1_SelectedIndexChanged={ + #TODO: Place custom script here + + } + $ComboboxServiceStartMode_SelectedIndexChanged={ + NA-Load-Service + $Global:StartMode = $Global:Serv | select DisplayName,Name,ProcessID,StartMode,State,Status | ? { $_.StartMode -eq $ComboboxServiceStartMode.text } + + NA-Populate-DropDowns -DropDownName ServiceState + + $Output.Text = $Global:Serv | select DisplayName,Name,ProcessID,StartMode,State,Status | ? { $_.StartMode -eq $ComboboxServiceStartMode.text } |ft -AutoSize | Out-String + + } + $ComboboxServiceState_SelectedIndexChanged={ + $Output.Text = $Global:StartMode | ? {$_.state -eq $ComboboxServiceState.Text } | ft -AutoSize | Out-String + #$Output.Text = $ComboboxServiceState.Text + } +################################################################################################################################################################################### + $ButtonConnectServer_Click={ + + $combobox1.Items.Clear() + $combobox1.Refresh() + $ComboboxProc.Items.Clear() + $ComboboxServiceStartMode.Items.Clear() + # $Progressbar.Visible = $True + If ($ServerName.Text -ne "-*-" -or $ServerName.Text -ne "") { + + $Global:ServerName = $ServerName.Text + $CheckConn = NA-TestConnection -Computer $ServerName.Text + + If ($CheckConn -eq '1') + { + NA-Populate-DropDowns -DropDownName Service + NA-Populate-DropDowns -DropDownName Process + NA-Populate-DropDowns -DropDownName Sort + NA-Populate-DropDowns -DropDownName FilterStartMode + #NA-Load-Service + #NA-Load-Process + NA-ServerInfo + + } + Else + { + $Global:ServerName = "" + NA-Messages -MessageType ServerNotFound + #$Output.Text = "Server NOT Found. Please Check Server Name ...... !" | Out-String + } + }#end If + Else { NA-Messages -MessageType ServerNotFound } + $Progressbar.Visible = $False + } +################################################################################################################################################################################### + $ButtonDisplayServices_Click={ + + If ($Global:ServerName) { + + NA-Load-Service + #$Output.Text = $Global:Serv | select PsComputerName,Name,ProcessID,StartMode,State,Status | ft -AutoSize| Out-String + } + Else { NA-Messages -MessageType ConnectServer } + } + + $ButtonServiceStatus_Click={ + If ($combobox1.Text -ne "" -and $combobox1.Text -notlike "--*" -and ($Global:ServerName)) { + NA-Service-Status + #$Output.Text = $Global:ServiceStatus | ft -AutoSize | Out-String + } + Else { NA-Messages -MessageType ServiceStatus } + } + + + $ButtonServiceStart_Click={ + + If ($combobox1.Text -ne "" -and $combobox1.Text -notlike "--*" -and ($Global:ServerName)) { + NA-StartService + } + Else { NA-Messages -MessageType ServiceStatus } + } + + $ButtonServiceStop_Click={ + If ($combobox1.Text -ne "" -and $combobox1.Text -notlike "--*" -and ($Global:ServerName)) { + NA-Service-Status + NA-Service-State -State Stopped + } + Else { NA-Messages -MessageType ServiceStatus } + } + + $ButtonServiceRestart_Click={ + NA-Service-Status + If ($Global:ServiceStatus.state -eq "Running") { + $Output.Text = "Re-Starting Service: $($combobox1.Text) ...... Please Wait! " + Restart-Service $combobox1.Text + Start-Sleep -Seconds 3 + $Output.Text = Gwmi Win32_Service -ComputerName $Global:ServerName | ? {$_.DisplayName -eq $combobox1.Text} | select name,displayname,state,startmode | ft -AutoSize | Out-String + } + Elseif ($Global:ServiceStatus.startmode -eq "Disabled") { + $Output.Text = "The Service: $($Global:ServiceStatus.name) is currently Disabled.....!!" + } + Elseif ($Global:ServiceStatus.state -eq "Stopped") { + $Output.Text = "The Service: $($Global:ServiceStatus.name) is currently NOT Running.....!!" + } + Else { NA-Messages -MessageType ServiceStatus} + + } + + $ButtonServiceAutomatic_Click={ + If ($combobox1.Text -ne "" -and $combobox1.Text -notlike "--*" -and ($Global:ServerName)) { + NA-Service-State -State Automatic + } + Else { NA-Messages -MessageType ServiceStatus } + } + + $ButtonServiceDisabled_Click={ + If ($combobox1.Text -ne "" -and $combobox1.Text -notlike "--*" -and ($Global:ServerName)) { + NA-Service-State -State Disabled + } + Else { NA-Messages -MessageType ServiceStatus } + } + $ButtonServiceManual_Click={ + If ($combobox1.Text -ne "" -and $combobox1.Text -notlike "--*" -and ($Global:ServerName)) { + NA-Service-State -State Manual + } + Else { NA-Messages -MessageType ServiceStatus } + } + + $labelServerOS_Click={} + $labelDisplayOS_Click={} + $labelServerIP_Click={} + $labelDisplayIP_Click={} + $labelServerDomain_Click={} + $labelDisplayDomain_Click={} + $labelServerType_Click={} + $labelDisplayServerInfo_Click={} + $labelFilterService_Click={} + + + $form1_Load={ + #TODO: Place custom script here + + } + + $ServerName1_Click={ + #TODO: Place custom script here + + } + + $Server_Click={ + #TODO: Place custom script here + + } + + $Output_TextChanged={ + #TODO: Place custom script here + + } + +######################################################################################################################################### + $labelProcProcesses_Click={} + + $ButtonProcDisplay_Click={ + If ($Global:ServerName) { + NA-Load-Process + #$Output.Text = $Global:Proc | ft -AutoSize | Out-String + } + Else { NA-Messages -MessageType ConnectServer } + } + + $ButtonProcStatus_Click={ NA-Process-Status <#; $Output.Text = $Global:ProcessStatus | ft -AutoSize | Out-String #>} + + $ButtonKillProcess_Click={ + If ($ComboboxProc.Text -ne "" -and $ComboboxProc.Text -notlike "--*" -and ($Global:ServerName)) { + NA-KillProcess -ProcessSelected ($ComboboxProc.text)} + Else { NA-Messages -MessageType ProcessStatus } + } + + $ComboboxProc_SelectedIndexChanged={} + $ComboboxProcSort_SelectedIndexChanged={ $Output.text = $Global:Proc | sort $ComboboxProcSort.text | ft -AutoSize | Out-String} + + +######################################################################################################################################### + function NA-ServerInfo + { + $OS = Gwmi win32_Operatingsystem -ComputerName $Global:ServerName | select -ExpandProperty caption + $labelDisplayOS.Text = $OS | Out-String + + $IP = Test-Connection -ComputerName $Global:ServerName -Count 1 -ErrorAction SilentlyContinue | select -ExpandProperty IPV4Address + $labelDisplayIP.text = $IP.IPAddressToString | Out-String + + $GetMachineInfo = Gwmi win32_Computersystem -ComputerName $Global:ServerName | Select model,domain + + $Domain = ($GetMachineInfo.domain).toupper() + $labelDisplayDomain.Text = $Domain | Out-String + + Switch -Wildcard ($GetMachineInfo.model) { + "Vmware*" { $labelDisplayServerInfo.Text = "VMWare VM"} + "Virtual*" { $labelDisplayServerInfo.Text = "Hyper-V VM"} + Default { $labelDisplayServerInfo.Text = "Physical Server"} + } + + + } +######################################################################################################################################### + function NA-Load-Service + { + #Param ($Computer) + #$combobox1.Items.Clear() + #$Global:Serv = "" + #$Global:Serv = Get-Service -ComputerName $Global:ServerName | sort displayname # | select -ExpandProperty displayname + #$Global:Serv = Gwmi Win32_Service -ComputerName $Global:ServerName | sort displayname + + $Output.Text = $Global:Serv | select PsComputerName,Name,ProcessID,StartMode,State,Status | ft -AutoSize| Out-String + + #$Global:Serv | % { $combobox1.Items.Add($_.displayname) } + + + + } +######################################################################################################################################### + function NA-Service-Status + { + + If ($combobox1.Text -ne "" -and $combobox1.Text -notlike "--*" -and ($Global:ServerName)) { + + $Global:ServiceStatus = Gwmi Win32_Service -ComputerName $Global:ServerName | ? {$_.DisplayName -eq $combobox1.Text} + + $Output.Text = $Global:ServiceStatus | select PsComputerName,Name,ProcessID,StartMode,State,Status | ft -AutoSize | Out-String + } + Else { + NA-Messages -MessageType ServiceStatus + #$Output.Text = "Please Select a Service or Connect to a Server ... !" + } + } +######################################################################################################################################### + function NA-Service-State + { + Param($State) + + #$SelectedService = Get-Service -ComputerName $Global:ServerName -DisplayName $combobox1.Text | select -ExpandProperty name + + + #$Global:ServiceStatus + + Switch($State) + { + Automatic { $Global:ServiceStatus.changestartmode("Automatic") } + Manual { $Global:ServiceStatus.changestartmode("Manual") } + Disabled { $Global:ServiceStatus.stopservice();$Global:ServiceStatus.changestartmode("Disabled") } + Stopped { $Global:ServiceStatus.stopservice() } + } + + + NA-Service-Status + $Output.Text = $Global:ServiceStatus | select name,displayname,state,startmode | ft -AutoSize | Out-String + } + +######################################################################################################################################### +######################################################################################################################################### + function NA-Load-Process { + + <# + $ComboboxProc.Items.Clear() + $Global:Proc = Invoke-Command -ComputerName $Global:ServerName { Get-Process } + + #$temp = $Global:Proc | select processname,id + + $i = 0 + $Q = @() + + foreach ($P in $Global:Proc) { + $Q += $Global:Proc[$i].ProcessName + " -- ID = " + "$($Global:Proc[$i].ID)" + #$Q += $P[$i].ProcessName + # $Q[$i] + $ComboboxProc.Items.Add($Q[$i]) + $i++ + } + #> + $Output.Text = $Global:Proc | ft -AutoSize | Out-String + #$Output.Text = $Q | Out-String + + } +######################################################################################################################################### + function NA-Process-Status { + + If ($ComboboxProc.Text -ne "" -and $ComboboxProc.Text -notlike "--*" -and ($Global:ServerName)) { + NA-GlobalProcess + $Output.Text = $Global:ProcessStatus | ft -AutoSize | Out-String + # $Output.Text = "You select $($ComboboxProc.text)" + } + Else { + NA-Messages -MessageType ProcessStatus + #$Output.Text = "Please Select a Process or Connect to a Server ... !" + } + } + +######################################################################################################################################### + function NA-KillProcess { + Param($ProcessSelected) + + $output.Text = "Killing Process: $ProcessSelected --- Please Wait..." + + $ProcessSelectedID = ($ProcessSelected.split("="))[-1] + + $TerminateProcess = Gwmi Win32_Process -ComputerName $Global:ServerName -Filter "ProcessID=$ProcessSelectedID" + $TerminateProcess.terminate() | Out-Null + + Start-Sleep -Seconds 3 + + $output.Text = "Done ! -- Re-Loading Process List..." + Start-Sleep -Seconds 3 + + NA-Load-Process + $Output.Text = $Global:Proc | ft -AutoSize | Out-String + } + +######################################################################################################################################### + function NA-GlobalProcess { + #$Proc = $ComboboxProc.text + $Proc = ($ComboboxProc.text.split("="))[-1] + #$output.Text = $Proc + $Global:ProcessStatus = Invoke-Command -ComputerName $Global:ServerName { Param($Proc) Gwmi Win32_Process | ? { $_.ProcessID -eq $Proc} } -ArgumentList $Proc + + } +######################################################################################################################################### +######################################################################################################################################### + function NA-TestConnection + { + param ($Computer) + + If (!$Computer) {$Output.Text = "Please Enter Server Name in the Box!!" | Out-String} + + Else { + $TConn = Test-Connection -ComputerName $Computer -Count 1 -ErrorAction SilentlyContinue + } + If ($TConn) + { + $Output.Text = "Getting information from server: $Computer " + Write-Output '1' + } + Else + { + Write-Output '0' + } + } +######################################################################################################################################### + function NA-StartService + { + + # $SvcStatus = Gwmi Win32_Service -ComputerName $Global:ServerName | ? {$_.DisplayName -eq $combobox1.Text} | select name,displayname,state,startmode + NA-Service-Status + + #$Output.Text = "Starting Service: $($Global:ServiceStatus.displayname) on $Global:ServerName" | Out-String + $Output.Text = "Global Server Name: $($Global:Servername) ---- Global Service Status: $($Global:ServiceStatus.displayname)" | Out-String + + + #$ServiceStatus = Get-Service -Name $ServiceName -ComputerName $Global:ServerName + #$ServiceSelected = $combobox1.text + #NA-GlobalService + + Switch($Global:ServiceStatus.startmode) { + #Switch($ServiceStatus.startmode) { + #Restart { $Output.Text = "Re-starting Service: $($Global:ServiceStatus.displayname) ..... please wait"; Restart-Service -DisplayName $Global:ServiceStatus.displayname } + #Manual { Start-Service -DisplayName $Global:ServiceStatus.displayname } + Disabled { $Output.Text = "Starting Service ..... please wait"; NA-Service-State -State Manual; $Global:ServiceStatus.StartService() <# Get-Service -Name $Global:ServiceStatus.name -ComputerName $Global:ServerName | Start-Service #>} + Default { $Global:ServiceStatus.StartService() } + #Disabled { $Output.Text = "Disabled" } + #Default { $Output.Text = "Manual"} + } + + #$CurrentService = Get-Service -DisplayName $ServiceSelected + #Get-Service -DisplayName $($combobox1.text) -ComputerName $Global:ServerName | Start-Service | Out-String + Start-Sleep -Seconds 4 + #$Output.Text = Get-Service -DisplayName $ServiceSelected | ft -AutoSize | Out-String + NA-Service-Status + + $Output.Text = $Global:ServiceStatus | select name,displayname,state,startmode | ft -AutoSize | Out-String + } +######################################################################################################################################### + function NA-ClearGlobalVariables + { + $Global:ServerName = "" + $Global:ServiceStatus = "" + $Global:Serv = "" + $Global:Proc = "" + $Global:ProcessStatus ="" + } +######################################################################################################################################### + Function NA-Populate-DropDowns { + Param($DropDownName) + + Switch($DropDownName) { + Service { $Global:Serv = Gwmi Win32_Service -ComputerName $Global:ServerName | sort displayname + $Global:Serv | % { $combobox1.Items.Add($_.displayname) } + }#endService + Process { $ComboboxProc.Items.Clear() + $Global:Proc = Invoke-Command -ComputerName $Global:ServerName { Get-Process } + + $i = 0 + $Q = @() + + foreach ($P in $Global:Proc) { + $Q += $Global:Proc[$i].ProcessName + " -- ID = " + "$($Global:Proc[$i].ID)" + #$Q += $P[$i].ProcessName + # $Q[$i] + $ComboboxProc.Items.Add($Q[$i]) + $i++ + }#endForeach + }#endProcess + Sort { $Items = "CPU","VM","ProcessName" + $ComboboxProcSort.items.Clear() + $Items | % { $ComboboxProcSort.Items.Add($_) } + } + FilterStartMode { $Items = "Auto","Manual","Disabled" + $ComboboxServiceStartMode.items.Clear() + $Items | % { $ComboboxServiceStartMode.Items.Add($_) }} + ServiceState { $ComboboxServiceStateItems = "Stopped","Running" + $ComboboxServiceState.items.Clear() + $ComboboxServiceStateItems | % { $ComboboxServiceState.Items.Add($_) }} + }#endSwitch + }#endFunction + +######################################################################################################################################### + function xNA-GlobalService { + + #$Global:ServiceStatus = "" + If ($combobox1.Text -ne "" -and $combobox1.Text -notlike "--*" -and ($Global:ServerName)) { + + $Global:ServiceStatus = Gwmi Win32_Service -ComputerName $Global:ServerName | ? {$_.DisplayName -eq $combobox1.Text} | select displayname,name,state,startmode + #$Global:ServiceStatus = Get-Service -ComputerName $Global:ServerName -DisplayName $combobox1.Text + } + Else { $Output.Text = "Please Connect to a Server or Select a Service from the Drop down ... !"} + + } +######################################################################################################################################### + function NA-Messages { + Param($MessageType) + + Switch($MessageType) { + ConnectServer { $Output.Text = "Server NOT Found. Please Check Server Name and Connect ...... !!" } + ServerNotFound { $Output.Text = "Cannot Connect to Server. Please Check Server Name and Connect ......!!"} + ServiceStatus { $Output.Text = "Please Select a Service or Connect to a Server ... !!" } + ProcessStatus { $Output.Text = "Please Select a Process or Connect to a Server ... !!" } + + + }#end Switch + + + } +######################################################################################################################################### + + + + # --End User Generated Script-- + #---------------------------------------------- + #region Generated Events + #---------------------------------------------- + + $Form_StateCorrection_Load= + { + #Correct the initial state of the form to prevent the .Net maximized form issue + $form1.WindowState = $InitialFormWindowState + } + + $Form_Cleanup_FormClosed= + { + #Remove all event handlers from the controls + try + { + $Progressbar.remove_Click($Progressbar_Click) + $Services.remove_Click($Services_Click) + $Output.remove_TextChanged($Output_TextChanged) + $combobox1.remove_SelectedIndexChanged($combobox1_SelectedIndexChanged) + $ComboboxServiceStartMode.remove_SelectedIndexChanged($ComboboxServiceStartMode_SelectedIndexChanged) + $ComboboxServiceState.remove_SelectedIndexChanged($ComboboxServiceState_SelectedIndexChanged) + $ButtonDisplayServices.remove_Click($ButtonDisplayServices_Click) + $ButtonServiceStatus.remove_Click($ButtonServiceStatus_Click) + $ButtonConnectServer.remove_Click($ButtonConnectServer_Click) + $ButtonServiceStart.remove_Click($ButtonServiceStart_Click) + $ButtonServiceStop.remove_Click($ButtonServiceStop_Click) + $ButtonServiceRestart.remove_Click($ButtonServiceRestart_Click) + $ButtonServiceAutomatic.remove_Click($ButtonServiceAutomatic_Click) + $ButtonServiceDisabled.remove_Click($ButtonService_Click) + $ButtonServiceManual.remove_Click($ButtonServiceManual_Click) + $labelServerOS.remove_Click($labelServerOS_Click) + $labelDisplayOS.remove_Click($labelDisplayOS_Click) + $labelServerIP.remove_Click($labelServer_Click) + $labelDisplayIP.remove_Click($labelDisplayIP_Click) + $labelServerDomain.remove_Click($labelServer_Click) + $labelDisplayDomain.remove_Click($labelDisplayDomain_Click) + $labelServerType.remove_Click($labelServer_Click) + $labelDisplayServerInfo.remove_Click($labelDisplayServerInfo_Click) + $labelFilterService.remove_Click($labelFilterService_Click) + + $labelProcProcesses.remove_Click($labelProcProcesses_Click) + $ButtonProcDisplay.remove_Click($ButtonProcDisplay_Click) + $ButtonProcStatus.remove_Click($ButtonProcStatus_Click) + $ButtonKillProcess.remove_Click($ButtonKillProcess_Click) + $ComboboxProc.remove.SelectedIndexChanged($ComboboxProc_SelectedIndexChanged) + $ComboboxProcSort.remove.SelectedIndexChanged($ComboboxProcSort_SelectedIndexChanged) + + $form1.remove_Load($form1_Load) + $form1.remove_Load($Form_StateCorrection_Load) + $form1.remove_FormClosed($Form_Cleanup_FormClosed) + NA-ClearGlobalVariables + } + catch { Out-Null <# Prevent PSScriptAnalyzer warning #> } + } + #endregion Generated Events + + #---------------------------------------------- + #region Generated Form Code + #---------------------------------------------- + $form1.SuspendLayout() + $panel1.SuspendLayout() + + # + # form1 + # + $form1.Controls.Add($Progressbar) + $form1.Controls.Add($Services) + $form1.Controls.Add($panel1) + + $form1.Controls.Add($Output) + $form1.Controls.Add($ServerName) + $form1.Controls.Add($combobox1) + $form1.Controls.Add($ComboboxServiceStartMode) + $form1.Controls.Add($ComboboxServiceState) + $form1.Controls.Add($ButtonDisplayServices) + $form1.Controls.Add($ButtonServiceStatus) + $form1.Controls.Add($ButtonConnectServer) + $form1.Controls.Add($ButtonServiceStart) + $form1.Controls.Add($ButtonServiceStop) + $form1.Controls.Add($ButtonServiceRestart) + $form1.Controls.Add($ButtonServiceAutomatic) + $form1.Controls.Add($ButtonServiceDisabled) + $form1.Controls.Add($ButtonServiceManual) + $form1.Controls.Add($labelServerOS) + $form1.Controls.Add($labelDisplayOS) + $form1.Controls.Add($labelServerIP) + $form1.Controls.Add($labelDisplayIP) + $form1.Controls.Add($labelServerDomain) + $form1.Controls.Add($labelDisplayDomain) + $form1.Controls.Add($labelServerType) + $form1.Controls.Add($labelDisplayServerInfo) + $form1.Controls.Add($labelFilterService) + + $form1.Controls.Add($labelProcProcesses) + $form1.Controls.Add($ButtonProcDisplay) + $form1.controls.Add($ButtonProcStatus) + $form1.Controls.Add($ButtonKillProcess) + $form1.Controls.Add($ComboboxProc) + $form1.Controls.Add($ComboboxProcSort) + + $form1.AutoScaleDimensions = '6, 13' + $form1.AutoScaleMode = 'Font' + $form1.ClientSize = '990, 660' + $form1.Name = 'form1' + $form1.Text = 'Form' + $form1.add_Load($form1_Load) + # + # panel1 + # + $panel1.Controls.Add($ServerName) + $panel1.Controls.Add($labelServerOS) + $panel1.Controls.Add($labelDisplayOS) + $panel1.Controls.Add($labelServerIP) + $panel1.Controls.Add($labelDisplayIP) + $panel1.Controls.Add($labelServerDomain) + $panel1.Controls.Add($labelDisplayDomain) + $panel1.Controls.Add($labelServerType) + $panel1.controls.Add($labelDisplayServerInfo) + $panel1.Controls.Add($ButtonConnectServer) + $panel1.BackColor = 'ActiveCaption' + $panel1.ForeColor = 'ControlText' + $panel1.Location = '12, 12' + $panel1.Name = 'panel1' + $panel1.Size = '965, 34' + $panel1.TabIndex = 7 + # + # + # Progressbar + # + $Progressbar.Location = '60, 111' + $Progressbar.Maximum = $Global:Serv.count + $Progressbar.Step = 1 + $Progressbar.Value = 0 + $Progressbar.Style="Continuous" + $Progressbar.Name = 'Progressbar' + $Progressbar.Size = '600, 23' + $Progressbar.TabIndex = 9 + $Progressbar.add_Click($Progressbar_Click) + $Progressbar.Visible = $False + # + # Services + # + $Services.AutoSize = $True + $Services.Location = '12, 60' + $Services.Name = 'Services' + $Services.Size = '41, 13' + $Services.TabIndex = 6 + $Services.Text = 'Service:' + $Services.add_Click($Services_Click) + # + # labelFilterService + # + $labelFilterService.AutoSize = $True + $labelFilterService.Location = '88, 90' + $labelFilterService.Name = 'Filter' + $labelFilterService.Size = '41, 13' + $labelFilterService.TabIndex = 6 + $labelFilterService.Text = 'Filter:' + $labelFilterService.add_Click($labelFilterService_Click) + # + # labelProcProcesses + # + $labelProcProcesses.AutoSize = $True + $labelProcProcesses.Location = '12, 120' + $labelProcProcesses.Name = 'Proceses' + $labelProcProcesses.Size = '41, 13' + $labelProcProcesses.Text = 'Processes:' + $labelProcProcesses.add_Click($labelProcProcesses_Click) + # + # labelServerOS + # + $labelServerOS.AutoSize = $True + $labelServerOS.Font = 'Microsoft Sans Serif, 7.50pt, style=Bold' + $labelServerOS.ForeColor = 'DarkGreen' + $labelServerOS.TextAlign = 'MiddleRight' + $labelServerOS.Location = '264, 3' + $labelServerOS.Name = 'OS' + $labelServerOS.Size = '41, 13' + $labelServerOS.TabIndex = 6 + $labelServerOS.Text = 'O/S:' + $labelServerOS.add_Click($labelServerOS_Click) + # + # labelDisplayOS + # + $labelDisplayOS.AutoSize = $True + $labelDisplayOS.Font = 'Microsoft Sans Serif, 7.50pt, style=Bold' + $labelDisplayOS.ForeColor = 'DarkGreen' + $labelDisplayOS.TextAlign = 'MiddleRight' + $labelDisplayOS.Location = '295, 3' + $labelDisplayOS.Name = 'DisplayOS' + $labelDisplayOS.Size = '41, 13' + $labelDisplayOS.TabIndex = 7 + $labelDisplayOS.Text = '-----' + $labelDisplayOS.add_Click($labelDisplayOS_Click) + # + # labelServerIP + # + $labelServerIP.AutoSize = $True + $labelServerIP.Font = 'Microsoft Sans Serif, 7.50pt, style=Bold' + $labelServerIP.TextAlign = 'MiddleRight' + $labelServerIP.Location = '272, 17' + $labelServerIP.Name = 'IP' + $labelServerIP.Size = '41, 13' + $labelServerIP.TabIndex = 6 + $labelServerIP.Text = 'IP:' + $labelServerIP.add_Click($labelServerIP_Click) + # + # labelDisplayIP + # + $labelDisplayIP.AutoSize = $True + $labelDisplayIP.Font = 'Microsoft Sans Serif, 7.50pt, style=Bold' + $labelDisplayIP.TextAlign = 'MiddleRight' + $labelDisplayIP.Location = '295, 17' + $labelDisplayIP.Name = 'DisplayIP' + $labelDisplayIP.Size = '41, 13' + $labelDisplayIP.TabIndex = 8 + $labelDisplayIP.Text = '-----' + $labelDisplayIP.add_Click($labelDisplayIP_Click) + # + # labelServerDomain + # + $labelServerDomain.AutoSize = $True + $labelServerDomain.Font = 'Microsoft Sans Serif, 7.50pt, style=Bold' + $labelServerDomain.Location = '530, 3' + $labelServerDomain.Name = 'Domain' + $labelServerDomain.Size = '41, 13' + $labelServerDomain.TabIndex = 10 + $labelServerDomain.Text = 'Domain:' + $labelServerDomain.add_Click($labelServerDomain_Click) + # + # labelDisplayDomain + $labelDisplayDomain.AutoSize = $True + $labelDisplayDomain.Font = 'Microsoft Sans Serif, 7.50pt, style=Bold' + $labelDisplayDomain.Location = '580, 3' + $labelDisplayDomain.Name = 'DisplayDomain' + $labelDisplayDomain.Size = '41, 13' + $labelDisplayDomain.TabIndex = 9 + $labelDisplayDomain.Text = '-----' + $labelDisplayDomain.add_Click($labelDisplayDomain_Click) + # + # labelServerType + # + $labelServerType.AutoSize = $True + $labelServerType.Font = 'Microsoft Sans Serif, 7.50pt, style=Bold' + $labelServerType.Location = '542, 17' + $labelServerType.Name = 'Type' + $labelServerType.Size = '41, 13' + $labelServerType.TabIndex = 6 + $labelServerType.Text = 'Type:' + $labelServerType.add_Click($labelServerType_Click) + # + # labelDisplayServerInfo + # + $labelDisplayServerInfo.AutoSize = $True + $labelDisplayServerInfo.Font = 'Microsoft Sans Serif, 7.50pt, style=Bold' + $labelDisplayServerInfo.Location = '580, 17' + $labelDisplayServerInfo.Name = 'ServerType' + $labelDisplayServerInfo.Size = '41, 13' + $labelDisplayServerInfo.TabIndex = 11 + $labelDisplayServerInfo.Text = '-----' + $labelDisplayServerInfo.add_Click($labelDisplayServerInfo_Click) + # + # Output + # + $Output.Location = '12, 280' + $Output.Multiline = $True + $Output.Name = 'Output' + $Output.ScrollBars = 'both' + $Output.Size = '790, 360' + $Output.Font = 'Consolas, 8.25pt' + $Output.WordWrap = $False + $Output.TabIndex = 5 + $Output.add_TextChanged($Output_TextChanged) + # + # ServerName + # + $ServerName.BackColor = '255, 255, 192' + $ServerName.Font = 'Microsoft Sans Serif, 12pt, style=Bold' + $ServerName.Location = '4, 4' + $ServerName.Text = "--ServerName--" + $ServerName.Name = 'ServerName' + $ServerName.BackColor = '255, 255, 192' + $ServerName.TextAlign = 'Center' + $ServerName.Size = '130, 20' + $ServerName.TabIndex = 3 + # + # combobox1 + # + $combobox1.FormattingEnabled = $True + $combobox1.Location = '286, 55' + $combobox1.Name = 'combobox1' + $combobox1.Size = '165, 21' + $combobox1.TabIndex = 2 + $combobox1.Text = '---Select Service---' + $combobox1.add_SelectedIndexChanged($combobox1_SelectedIndexChanged) + # + # ComboboxServiceStartMode + # + $ComboboxServiceStartMode.FormattingEnabled = $True + $ComboboxServiceStartMode.Location = '125, 86' + $ComboboxServiceStartMode.Name = 'ComboboxServiceStartMode' + $ComboboxServiceStartMode.Size = '90, 21' + $ComboboxServiceStartMode.TabIndex = 2 + $ComboboxServiceStartMode.Text = '--Start Mode--' + $ComboboxServiceStartMode.add_SelectedIndexChanged($ComboboxServiceStartMode_SelectedIndexChanged) + # + # ComboboxServiceState + # + $ComboboxServiceState.FormattingEnabled = $True + $ComboboxServiceState.Location = '225, 86' + $ComboboxServiceState.Name = 'ComboboxServiceState' + $ComboboxServiceState.Size = '90, 21' + $ComboboxServiceState.TabIndex = 2 + $ComboboxServiceState.Text = '--State--' + $ComboboxServiceState.add_SelectedIndexChanged($ComboboxServiceState_SelectedIndexChanged) + # + # ComboboxProc + # + $ComboboxProc.FormattingEnabled = $True + $ComboboxProc.Location = '286, 115' + $ComboboxProc.Name = 'ComboboxProc' + $ComboboxProc.Size = '165, 21' + $ComboboxProc.TabIndex = 2 + $ComboboxProc.Text = '---Select Process---' + $ComboboxProc.add_SelectedIndexChanged($ComboboxProc_SelectedIndexChanged) + # + # ComboboxProcSort + # + $ComboboxProcSort.FormattingEnabled = $True + $ComboboxProcSort.Location = '547, 115' + $ComboboxProcSort.Name = 'SortBy' + $ComboboxProcSort.Size = '90, 21' + $ComboboxProcSort.TabIndex = 2 + $ComboboxProcSort.Text = '---Sort By---' + $ComboboxProcSort.add_SelectedIndexChanged($ComboboxProcSort_SelectedIndexChanged) + # + # ButtonDisplayServices + # + $ButtonDisplayServices.Location = '88, 54' + $ButtonDisplayServices.Name = 'DisplayService' + $ButtonDisplayServices.Size = '100, 23' + $ButtonDisplayServices.TabIndex = 1 + $ButtonDisplayServices.Text = 'Display Services' + $ButtonDisplayServices.UseVisualStyleBackColor = $True + $ButtonDisplayServices.add_Click($ButtonDisplayServices_Click) + # + # ButtonProcDisplay + # + $ButtonProcDisplay.Location = '88, 114' + $ButtonProcDisplay.Name = 'DisplayProcess' + $ButtonProcDisplay.Size = '105, 23' + $ButtonProcDisplay.TabIndex = 1 + $ButtonProcDisplay.Text = 'Display Processes' + $ButtonProcDisplay.UseVisualStyleBackColor = $True + $ButtonProcDisplay.add_Click($ButtonProcDisplay_Click) + # + # Service + # + $ButtonServiceStatus.Location = '199, 54' + $ButtonServiceStatus.Name = 'ServiceStatus' + $ButtonServiceStatus.Size = '80, 23' + $ButtonServiceStatus.TabIndex = 1 + $ButtonServiceStatus.Text = 'Status' + $ButtonServiceStatus.UseVisualStyleBackColor = $True + $ButtonServiceStatus.add_Click($ButtonServiceStatus_Click) + # + # ButtonProcStatus + $ButtonProcStatus.Location = '199, 114' + $ButtonProcStatus.Name = 'ProcessStatus' + $ButtonProcStatus.Size = '80, 23' + $ButtonProcStatus.TabIndex = 1 + $ButtonProcStatus.Text = 'Status' + $ButtonProcStatus.UseVisualStyleBackColor = $True + $ButtonProcStatus.add_Click($ButtonProcStatus_Click) + # + # ButtonKillProcess + # + $ButtonKillProcess.Location = '460, 115' + $ButtonKillProcess.Name = 'KillProcess' + $ButtonKillProcess.Size = '80, 23' + $ButtonKillProcess.TabIndex = 1 + $ButtonKillProcess.Text = 'Kill Process' + $ButtonKillProcess.UseVisualStyleBackColor = $True + $ButtonKillProcess.add_Click($ButtonKillProcess_Click) + # + # ButtonConnectServer + # + $ButtonConnectServer.Location = '156, 6' + $ButtonConnectServer.Name = 'ConnectServer' + $ButtonConnectServer.Text = 'Connect' + $ButtonConnectServer.UseVisualStyleBackColor = $True + $ButtonConnectServer.add_Click($ButtonConnectServer_Click) + # + # + + $form1.ResumeLayout() + $panel1.ResumeLayout() + + # + # ButtonServiceStart + # + $ButtonServiceStart.Location = '458, 54' + $ButtonServiceStart.Name = 'StartService' + $ButtonServiceStart.Size = '65, 23' + $ButtonServiceStart.TabIndex=2 + $ButtonServiceStart.Text = 'Start' + $ButtonServiceStart.UseVisualStyleBackColor = $True + $ButtonServiceStart.add_Click($ButtonServiceStart_Click) + $ButtonServiceStart.ResumeLayout() + # + # $ButtonServiceStop + # + $ButtonServiceStop.Location = '530, 54' + $ButtonServiceStop.Name = 'StopService' + $ButtonServiceStop.Size = '65, 23' + $ButtonServiceStop.TabIndex = 3 + $ButtonServiceStop.Text = 'Stop' + $ButtonServiceStop.UseVisualStyleBackColor = $True + $ButtonServiceStop.add_Click($ButtonServiceStop_Click) + $ButtonServiceStop.ResumeLayout() + # + # ButtonServiceRestart + # + $ButtonServiceRestart.Location = '602, 54' + $ButtonServiceRestart.Name = 'RestartService' + $ButtonServiceRestart.Size = '65, 23' + $ButtonServiceRestart.TabIndex = 3 + $ButtonServiceRestart.Text = 'Restart' + $ButtonServiceRestart.UseVisualStyleBackColor = $True + $ButtonServiceRestart.add_Click($ButtonServiceRestart_Click) + $ButtonServiceRestart.ResumeLayout() + # + # ButtonServiceAutomatic + # + $ButtonServiceAutomatic.Location = '674, 54' + $ButtonServiceAutomatic.Name = 'AutomaticService' + $ButtonServiceAutomatic.Size = '65, 23' + $ButtonServiceAutomatic.TabIndex = 3 + $ButtonServiceAutomatic.Text = 'Automatic' + $ButtonServiceAutomatic.UseVisualStyleBackColor = $True + $ButtonServiceAutomatic.add_Click($ButtonServiceAutomatic_Click) + $ButtonServiceAutomatic.ResumeLayout() + # + # ButtonServiceDisabled + # + $ButtonServiceDisabled.Location = '818, 54' + $ButtonServiceDisabled.Name = 'DisabledService' + $ButtonServiceDisabled.Size = '65, 23' + $ButtonServiceDisabled.TabIndex = 3 + $ButtonServiceDisabled.Text = 'Disabled' + $ButtonServiceDisabled.UseVisualStyleBackColor = $True + $ButtonServiceDisabled.add_Click($ButtonServiceDisabled_Click) + $ButtonServiceDisabled.ResumeLayout() + # + # + # + $ButtonServiceManual.Location = '746, 54' + $ButtonServiceManual.Name = 'ManualService' + $ButtonServiceManual.Size = '65, 23' + $ButtonServiceManual.TabIndex = 3 + $ButtonServiceManual.Text = 'Manual' + $ButtonServiceManual.UseVisualStyleBackColor = $True + $ButtonServiceManual.add_Click($ButtonServiceManual_Click) + $ButtonServiceManual.ResumeLayout() + # + #endregion Generated Form Code + + #---------------------------------------------- + + #Save the initial state of the form + $InitialFormWindowState = $form1.WindowState + #Init the OnLoad event to correct the initial state of the form + $form1.add_Load($Form_StateCorrection_Load) + #Clean up the control events + $form1.add_FormClosed($Form_Cleanup_FormClosed) + #Show the Form + return $form1.ShowDialog() + +} #End Function + +#Call the form +Show-test-tools_psf | Out-Null diff --git a/dump/SCCM-Tool/Forms/_FORMS-DESIGNER.ps1 b/dump/SCCM-Tool/Forms/_FORMS-DESIGNER.ps1 new file mode 100644 index 0000000..88f4bf1 --- /dev/null +++ b/dump/SCCM-Tool/Forms/_FORMS-DESIGNER.ps1 @@ -0,0 +1,432 @@ +Add-Type -AssemblyName System.Windows.Forms +Add-Type -AssemblyName System.Drawing + +function mouseDown { + + $Global:mCurFirstX = ([System.Windows.Forms.Cursor]::Position.X ) + $Global:mCurFirstY = ([System.Windows.Forms.Cursor]::Position.Y ) + +} + +function mouseMove ($mControlName) { + + $mCurMoveX = ([System.Windows.Forms.Cursor]::Position.X ) + $mCurMoveY = ([System.Windows.Forms.Cursor]::Position.Y ) + + if ($Global:mCurFirstX -ne 0 -and $Global:mCurFirstY -ne 0){ + + $mDifX = $Global:mCurFirstX - $mCurMoveX + $mDifY = $Global:mCurFirstY - $mCurMoveY + + $this.Left = $this.Left - $mDifX + $this.Top = $this.Top - $mDifY + + $Global:mCurFirstX = $mCurMoveX + $Global:mCurFirstY = $mCurMoveY + + } + + +} + +function mouseUP ($mControlObj) { + + $mCurUpX = ([System.Windows.Forms.Cursor]::Position.X ) + $mCurUpY = ([System.Windows.Forms.Cursor]::Position.Y ) + + $Global:mCurFirstX = 0 + $Global:mCurFirstY = 0 + + + Foreach ($mElement In $Global:mFormObj.Elements){ + + if ($mElement.Name -eq $this.name){ + + foreach( $mProp in $mElement.Properties){ + + Switch($mProp.Name){ + + 'Top'{ $mProp.Value = $this.Top} + 'Left'{$mProp.Value = $this.Left} + + } + } + } + } + + renewGrids +} + +Function renewGrids { + + $mList = New-Object System.Collections.ArrayList + [array]$mElementsArr = $mFormObj.Elements | select Name,Type + $mList.AddRange($mElementsArr) + $mElemetnsGrid.DataSource = $mList + $mElemetnsGrid.Columns[1].ReadOnly = $true + + $mList2 = New-Object System.Collections.ArrayList + [array]$mPropertyArr = $mFormObj.Elements[$mElemetnsGrid.CurrentRow.Index].Properties + $mList2.AddRange($mPropertyArr) + $mPropertiesGrid.DataSource = $mList2 + $mPropertiesGrid.Columns[0].ReadOnly=$true + +} + +Function DeleteElement { + + $Global:mFormObj.Elements = $mFormObj.Elements | ?{$_.Name -notlike $mFormObj.Elements[$mElemetnsGrid.CurrentRow.Index].Name} + renewGrids + +} + +Function AddProperty ($mName,$mValue){ + + $mPropertyObj = New-Object PSCustomObject + $mPropertyObj | Add-Member -Name 'Name' -MemberType NoteProperty -Value $mName + $mPropertyObj | Add-Member -Name 'Value' -MemberType NoteProperty -Value $mValue + return $mPropertyObj + +} + +Function ElementsChanged{ + + $mList2 = New-Object System.Collections.ArrayList + [array]$mPropertyArr = $mFormObj.Elements[$mElemetnsGrid.CurrentRow.Index].Properties + $mList2.AddRange($mPropertyArr) + $mPropertiesGrid.DataSource = $mList2 + +} + +function ElementsEndEdit { + + $Global:mFormObj.Elements[$mElemetnsGrid.CurrentRow.Index].Name = $mElemetnsGrid.CurrentCell.FormattedValue + repaintForm + +} + + + +Function AddElement { + + $mPropertiesArr =@() + + $mSameType = ($mFormObj.Elements | ?{$_.Type -like $mControlType.SelectedItem}) + + if($mSameType.count -ne $NUll -and $mSameType -ne $null) { + + $mControlName=''+$mControlType.SelectedItem+($mSameType.count+1) + + }elseif($mSameType.Count -eq $null -and $mSameType -ne $null){ + + $mControlName=''+$mControlType.SelectedItem+'2' + + }else{ + + $mControlName=''+$mControlType.SelectedItem+'1' + + } + + $mPropertiesArr+= AddProperty 'Text' $mControlName + $mPropertiesArr+= AddProperty 'SizeX' 100 + $mPropertiesArr+= AddProperty 'SizeY' 23 + $mPropertiesArr+= AddProperty 'Top' 5 + $mPropertiesArr+= AddProperty 'Left' 5 + $mPropertiesArr+= AddProperty 'Anchor' 'Left,Top' + + $mElementsObj = New-Object PSCustomObject + $mElementsObj |Add-Member -Name 'Name' -MemberType NoteProperty -Value $mControlName + $mElementsObj |Add-Member -Name 'Type' -MemberType NoteProperty -Value ($mControlType.SelectedItem) + $mElementsObj |Add-Member -Name 'Properties' -MemberType NoteProperty -Value $mPropertiesArr + $Global:mFormObj.Elements += $mElementsObj + + renewGrids + + repaintForm + +} + +function AddControl ($mControl) { + + $mReturnControl = $null + + switch ($mControl.Type){ + + "TextBox" {$mReturnControl = New-Object System.Windows.Forms.TextBox} + "ListBox" {$mReturnControl = New-Object System.Windows.Forms.ListBox} + "ComboBoX" {$mReturnControl = New-Object System.Windows.Forms.ComboBox} + "Label" {$mReturnControl = New-Object System.Windows.Forms.Label} + "DataGrid" {$mReturnControl = New-Object System.Windows.Forms.DataGridView} + "Button" {$mReturnControl = New-Object System.Windows.Forms.Button} + 'CheckBox' {$mReturnControl = New-Object System.Windows.Forms.CheckBox} + 'DateTimePicker' {$mReturnControl = New-Object System.Windows.Forms.DateTimePicker} + 'ListView' {$mReturnControl = New-Object System.Windows.Forms.ListView} + 'PictureBox' {$mReturnControl = New-Object System.Windows.Forms.PictureBox} + 'RichTextBox' {$mReturnControl = New-Object System.Windows.Forms.RichTextBox} + 'TreeView' {$mReturnControl = New-Object System.Windows.Forms.TreeView} + 'WebBrowser' {$mReturnControl = New-Object System.Windows.Forms.WebBrowser} + "default" {write-host 'something goes wrong sorry :('} + + } + + $mReturnControl.Name = $mControl.Name + + $mSizeX=$null + $mSizeY=$null + + foreach ($mProperty in $mControl.Properties){ + + switch ($mProperty.Name){ + 'Text' {$mReturnControl.Text=$mProperty.Value} + 'SizeX' {$mSizeX=$mProperty.Value} + 'SizeY' {$mSizeY=$mProperty.Value} + 'Top' {$mReturnControl.Top=$mProperty.Value} + 'Left' {$mReturnControl.Left=$mProperty.Value} + 'Anchor'{$mReturnControl.Anchor=$mProperty.Value} + } + + + } + + $mReturnControl.Size = New-Object System.Drawing.Size($mSizeX,$mSizeY) + $mReturnControl.Add_MouseDown({MouseDown}) + $mReturnControl.Add_MouseMove({MouseMove ($mControl.Name)}) + $mReturnControl.Add_MouseUP({MouseUP}) + + Return $mReturnControl + +} + +function PropertiesEndEdit{ + + foreach ($mProperty in $Global:mFormObj.Elements[$mElemetnsGrid.CurrentRow.Index].Properties){ + + if ($mProperty.Name -eq $mPropertiesGrid.currentrow.Cells[0].FormattedValue){ + + $mProperty.Value = $mPropertiesGrid.currentrow.Cells[1].FormattedValue + + } + + } + + repaintForm + +} + + +Function repaintForm { + + $mFormGroupBox.Size = New-Object System.Drawing.Size(($mFormObj.SizeX),($mFormObj.SizeY)) + $mFormGroupBox.controls.clear() + + Foreach ($mElement in $mFormObj.Elements){ + + $mFormGroupBox.controls.add((AddControl $mElement)) + + } + +} + +Function EditFormSize ($x,$y){ + + $Global:mFormObj.SizeX = $X + $Global:mFormObj.SizeY = $Y + + repaintForm + +} + + +function ExportForm { + + $mFormObj + $mExportString = " + " + $mExportString+= ' + Add-Type -AssemblyName System.Windows.Forms + Add-Type -AssemblyName System.Drawing + $MyForm = New-Object System.Windows.Forms.Form + $MyForm.Text="MyForm" + $MyForm.Size = New-Object System.Drawing.Size('+$mFormObj.SizeX+','+$mFormObj.SizeY+') + ' + foreach ($mElement in $mFormObj.Elements){ + + $mExportString+=' + + $m'+$mElement.Name+' = New-Object System.Windows.Forms.'+$mElement.Type+'' + $mPrSizeX='' + $mPrSizeY='' + + foreach ($mProperty in $mElement.Properties){ + + If ($mProperty.Name -eq 'SizeX'){ + + $mPrSizeX = $mProperty.Value + + } + elseIf ($mProperty.Name -eq 'SizeY'){ + + $mPrSizeY = $mProperty.Value + + } + else{ + + $mExportString+=' + $m'+$mElement.Name+'.'+$mProperty.Name +'="'+$mProperty.Value+'"' + + } + + } + + $mExportString+=' + $m'+$mElement.Name+'.Size = New-Object System.Drawing.Size('+$mPrSizeX+','+$mPrSizeY+') + $MyForm.Controls.Add($m'+$mElement.Name+') + ' + + } + + $mExportString+= '$MyForm.ShowDialog()' + + $mFileName='' + $mFileName = get-filename 'C:\' + if ($mFileName -notlike ''){ + + $mExportString > $mFileName + + } +} + +Function Get-FileName($initialDirectory) { + + $SaveFileDialog = New-Object System.Windows.Forms.SaveFileDialog + $SaveFileDialog.initialDirectory = $initialDirectory + $SaveFileDialog.filter = “Powershell Script (*.ps1)|*.ps1|All files (*.*)|*.*” + $SaveFileDialog.ShowDialog() | Out-Null + $SaveFileDialog.filename + +} + + +$mForm = New-Object System.Windows.Forms.Form +$mForm.AutoSize = $true +$mForm.Text='FormsMaker' + +$mControlType = New-Object System.Windows.Forms.ComboBoX +$mControlType.Anchor = 'Left,Top' +$mControlType.Size = New-Object System.Drawing.Size(100,23) +$mControlType.Left = 5 +$mControlType.Top = 5 +$mControlType.Items.Add("TextBox") +$mControlType.Items.Add("ListBox") +$mControlType.Items.Add("ComboBoX") +$mControlType.Items.Add("Label") +$mControlType.Items.Add("DataGrid") +$mControlType.Items.Add("Button") +$mControlType.Items.Add("CheckBox") +$mControlType.Items.Add("DateTimePicker") +$mControlType.Items.Add("ListView") +$mControlType.Items.Add("PictureBox") +$mControlType.Items.Add("RichTextBox") +$mControlType.Items.Add("TreeView") +$mControlType.Items.Add("WebBrowser") +$mForm.Controls.Add($mControlType) + +$mAddButton = New-Object System.Windows.Forms.Button +$mAddButton.Anchor = 'Left,Top' +$mAddButton.Text = 'Add' +$mAddButton.Left = 110 +$mAddButton.Top = 5 +$mAddButton.Size = New-Object System.Drawing.Size(50,23) +$mAddButton.Add_Click({AddElement}) +$mForm.Controls.Add($mAddButton) + +$mFormLabel = New-Object System.Windows.Forms.Label +$mFormLabel.Text = 'Form Size:' +$mFormLabel.Top = 5 +$mFormLabel.Left = 165 +$mFormLabel.Anchor = 'Left,Top' +$mFormLabel.Size = New-Object System.Drawing.Size(80,23) +$mFormLabel.TextAlign='MiddleRight' +$mForm.Controls.Add($mFormLabel) + +$mFormXTextBox = New-Object System.Windows.Forms.TextBox +$mFormXTextBox.left = 250 +$mFormXTextBox.top = 5 +$mFormXTextBox.Size = New-Object System.Drawing.Size(30,23) +$mFormXTextBox.Anchor = 'Left,Top' +$mFormXTextBox.Text=300 +$mForm.Controls.Add($mFormXTextBox) + +$mFormXLabel = New-Object System.Windows.Forms.Label +$mFormXLabel.Text = 'X' +$mFormXLabel.Top = 5 +$mFormXLabel.Left = 280 +$mFormXLabel.Anchor = 'Left,Top' +$mFormXLabel.Size = New-Object System.Drawing.Size(20,23) +$mFormXLabel.TextAlign='MiddleCenter' +$mFormXTextBox.Add_TextChanged({EditFormSize $mFormXTextBox.Text $mFormYTextBox.Text }) +$mForm.Controls.Add($mFormXLabel) + +$mFormYTextBox = New-Object System.Windows.Forms.TextBox +$mFormYTextBox.left = 300 +$mFormYTextBox.top = 5 +$mFormYTextBox.Size = New-Object System.Drawing.Size(30,23) +$mFormYTextBox.Anchor = 'Left,Top' +$mFormYTextBox.Text= 300 +$mFormYTextBox.Add_TextChanged({EditFormSize $mFormXTextBox.Text $mFormYTextBox.Text}) +$mForm.Controls.Add($mFormYTextBox) + +$mFormGroupBox = New-Object System.Windows.Forms.GroupBox +$mFormGroupBox.left = 350 +$mFormGroupBox.top = 5 +$mFormGroupBox.Anchor = 'Left,Top' +$mFormGroupBox.Size = New-Object System.Drawing.Size($mFormXTextBox.Text,$mFormYTextBox.Text) +$mFormGroupBox.Text = 'New Form' +$mForm.Controls.Add($mFormGroupBox) + +$mElemetnsGrid = New-Object System.Windows.Forms.DataGridView +$mElemetnsGrid.size = New-Object System.Drawing.Size(155,600) +$mElemetnsGrid.left=5 +$mElemetnsGrid.top=33 +$mElemetnsGrid.Anchor='Top,Left' +$mElemetnsGrid.RowHeadersVisible =$false +$mElemetnsGrid.Add_CellContentClick({ElementsChanged}) +$mElemetnsGrid.Add_CellEndEdit({ElementsEndEdit}) +$mForm.Controls.Add($mElemetnsGrid) + +$mPropertiesGrid = New-Object System.Windows.Forms.DataGridView +$mPropertiesGrid.size = New-Object System.Drawing.Size(155,600) +$mPropertiesGrid.left=180 +$mPropertiesGrid.top=33 +$mPropertiesGrid.Anchor='Top,Left' +$mPropertiesGrid.ColumnHeadersVisible=$true +$mPropertiesGrid.RowHeadersVisible =$false +$mPropertiesGrid.Add_CellEndEdit({PropertiesEndEdit}) +$mForm.Controls.Add($mPropertiesGrid) + +$mDeleteButton = New-Object System.Windows.Forms.Button +$mDeleteButton.size = New-Object System.Drawing.Size(155,23) +$mDeleteButton.Text = 'Delete' +$mDeleteButton.Left = 5 +$mDeleteButton.Top = 638 +$mDeleteButton.Anchor = 'Top,Left' +$mDeleteButton.Add_Click({DeleteElement}) +$mForm.Controls.Add($mDeleteButton) + +$mExportButton = New-Object System.Windows.Forms.Button +$mExportButton.size = New-Object System.Drawing.Size(155,23) +$mExportButton.text = 'Export' +$mExportButton.Left = 180 +$mExportButton.top = 638 +$mExportButton.Anchor='Top,Left' +$mExportButton.Add_Click({ExportForm}) +$mForm.Controls.Add($mExportButton) + +$Global:mFormObj = new-object PSCustomObject +$Global:mFormObj | Add-Member -Name 'SizeX' -MemberType NoteProperty -Value 300 +$Global:mFormObj | Add-Member -Name 'SizeY' -MemberType NoteProperty -Value 300 +$Global:mFormObj | Add-Member -Name 'Elements' -MemberType NoteProperty -Value @() +$Global:mCurFirstX =0 +$Global:mCurFirstY =0 + +$mForm.ShowDialog() \ No newline at end of file diff --git a/dump/SCCM-Tool/Forms/_Form-Template.Export-BLANK.ps1 b/dump/SCCM-Tool/Forms/_Form-Template.Export-BLANK.ps1 new file mode 100644 index 0000000..4926604 --- /dev/null +++ b/dump/SCCM-Tool/Forms/_Form-Template.Export-BLANK.ps1 @@ -0,0 +1,208 @@ +#------------------------------------------------------------------------ +# Source File Information (DO NOT MODIFY) +# Source ID: 676f8db7-35c7-452d-b353-a4b40f26243a +# Source File: Form-Template.psf +#------------------------------------------------------------------------ +#region File Recovery Data (DO NOT MODIFY) +<#RecoveryData: +RAUAAB+LCAAAAAAABAC9VNtKwzAYvhd8h5Dr2oPd3AZtYXTuxtNwQ72TrP07o2lSknSzPr3p2g1x +QkHGKJSk+Q7/KQ0eIRFrkNWEaILMQlHBQ3xpezg6P0MoeJB0RTlhU8rgnuQQTYXMLxaQF4xosAuV +Bc4BpmEu3yHRSFcFhHheKQ25/Ux5KjbKrkWat4X+OrLQUxtKz3brx0JxyXQpIeRQakmYhWblktHk +BqqF+AAeLgcD0k/6V97I74E7HGHETSghzoyeh1HyRlkqDQ7HgmspmGoSNIHOpChA6qoljEst5glh +MKE58DoIA72ykOcHzg7aRb0TKWBTKq47OTGjwPWcfhnCwDU+/nDYSaqrjKNtap3YBXxqvG3bIfR6 +bbxb3K0gaav5Wq8DZ3vaNNNputlsxkpBbooPaqfTfqmiXCVCMro8QgMDZ6/626UZmVN4HH0sux3r +m3gaI0k2lK/+4+X6WT8bZJ6X9l3ik26vl5ydJKdYSDi+0X7bjHzg/PxrRt9OzyrdRAUAAA==#> +#endregion + +<# + .NOTES + -------------------------------------------------------------------------------- + Code generated by: SAPIEN Technologies, Inc., PowerShell Studio 2017 v5.4.141 + Generated on: 8/29/2017 11:53 AM + Generated by: Haidey2 + -------------------------------------------------------------------------------- + .DESCRIPTION + GUI script generated by PowerShell Studio 2017 +#> + + +#---------------------------------------------- +#region Application Functions +#---------------------------------------------- + +#endregion Application Functions + +#---------------------------------------------- +# Generated Form Function +#---------------------------------------------- +function Show-Form-Template_psf { + + #---------------------------------------------- + #region Import the Assemblies + #---------------------------------------------- + [void][reflection.assembly]::Load('System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') + [void][reflection.assembly]::Load('System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') + [void][reflection.assembly]::Load('System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') + #endregion Import Assemblies + + #---------------------------------------------- + #region Generated Form Objects + #---------------------------------------------- + [System.Windows.Forms.Application]::EnableVisualStyles() + $form1 = New-Object 'System.Windows.Forms.Form' + $InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState' + + $PanelEventLogs_Events = New-Object 'System.Windows.Forms.Panel' + $PanelEventLogs_Filter = New-Object 'System.Windows.Forms.Panel' + + + $Text_ELogs_ServerName = New-Object 'System.Windows.Forms.TextBox' + $Text_ELogs_EventID = New-Object 'System.Windows.Forms.TextBox' + $Text_Elogs_DaysBack = New-Object 'System.Windows.Forms.TextBox' + + $Button_ELogs_Connect = New-Object 'System.Windows.Forms.Button' + + #endregion Generated Form Objects + + #---------------------------------------------- + # User Generated Script + #---------------------------------------------- + + $form1_Load={ + #TODO: Initialize Form Controls here + + } + + # --End User Generated Script-- + #---------------------------------------------- + #region Generated Events + #---------------------------------------------- + + $Form_StateCorrection_Load= + { + #Correct the initial state of the form to prevent the .Net maximized form issue + $form1.WindowState = $InitialFormWindowState + } + + $Form_Cleanup_FormClosed= + { + #Remove all event handlers from the controls + try + { + $form1.remove_Load($form1_Load) + $form1.remove_Load($Form_StateCorrection_Load) + $form1.remove_FormClosed($Form_Cleanup_FormClosed) + + $PanelEventLogs_Events.remove_Paint($PanelEventLogs_Events_Paint) + $PanelEventLogs_Filter.remove_Paint($PanelEventLogs_Filter_Paint) + + $Text_Elogs_DaysBack.remove_TextChanged($Text_Elogs_DaysBack_TextChanged) + $Text_ELogs_ServerName.remove_TextChanged($Text_ELogs_ServerName_TextChanged) + $Text_ELogs_EventID.remove_TextChanged($Text_ELogs_EventID_TextChanged) + + + + } + catch { Out-Null <# Prevent PSScriptAnalyzer warning #> } + } + + + $PanelEventLogs_Events_Paint=[System.Windows.Forms.PaintEventHandler]{ <#Event Argument: $_ = [System.Windows.Forms.PaintEventArgs]#> } + $PanelEventLogs_Filter_Paint=[System.Windows.Forms.PaintEventHandler]{ } + + $Text_ELogs_ServerName_TextChanged={} + $Text_Elogs_DaysBack_TextChanged={} + + #endregion Generated Events + + #---------------------------------------------- + #region Generated Form Code + #---------------------------------------------- + # + # form1 + # + $form1.Controls.Add($PanelEventLogs_Events) + $form1.Controls.Add($PanelEventLogs_Filter) + + + + + $form1.AutoScaleDimensions = '6, 13' + $form1.AutoScaleMode = 'Font' + $form1.ClientSize = '1200, 780' + $form1.Name = 'form1' + $form1.Text = 'Form' + $form1.add_Load($form1_Load) + #endregion Generated Form Code + + #---------------------------------------------- + + $PanelEventLogs_Events.Controls.Add($Text_ELogs_ServerName) + $PanelEventLogs_Events.Controls.Add($Button_ELogs_Connect) + $PanelEventLogs_Events.Controls.Add($Button_ELogs_View) + $PanelEventLogs_Events.Controls.Add($Combobox_EventLogs_LogsList) + $PanelEventLogs_Events.Controls.Add($VCenterUserPassword) + $PanelEventLogs_Events.Controls.Add($CheckBoxUseWindowsLogin) + $PanelEventLogs_Events.Controls.Add($labelVCenterUserName) + $PanelEventLogs_Events.Controls.Add($labelVCenterPassword) + $PanelEventLogs_Events.BackColor = '153,153,153' + $PanelEventLogs_Events.Location = '6, 6' + $PanelEventLogs_Events.Name = 'panelEventLogs_Events' + $PanelEventLogs_Events.Size = '598, 56' + $PanelEventLogs_Events.TabIndex = 0 + $PanelEventLogs_Events.add_Paint($PanelEventLogs_Events_Paint) + + $PanelEventLogs_Filter.Controls.Add($Combobox_ELogsFilter_Level) + $PanelEventLogs_Filter.Controls.Add($Text_ELogs_EventID) + $PanelEventLogs_Filter.Controls.Add($Text_Elogs_DaysBack) + $PanelEventLogs_Filter.Controls.Add($label_ELogs_Level) + $PanelEventLogs_Filter.Controls.Add($label_ELogs_EventID) + $PanelEventLogs_Filter.Controls.Add($label_ELogs_DaysBack) + $PanelEventLogs_Filter.BackColor = '255,255,212' + $PanelEventLogs_Filter.Location = '6, 62' + $PanelEventLogs_Filter.Name = 'PanelEventLogs_Filter' + $PanelEventLogs_Filter.Size = '598, 56' + $PanelEventLogs_Filter.BorderStyle = 'FixedSingle' + $PanelEventLogs_Filter.TabIndex = 0 + $PanelEventLogs_Filter.add_Paint($PanelEventLogs_Filter_Paint) + + # + # $Text_ELogs_ServerName + # + $Text_ELogs_ServerName.Location = '8, 26' + $Text_ELogs_ServerName.Name = '$Text_ELogs_ServerName' + $Text_ELogs_ServerName.Size = '100, 20' + $Text_ELogs_ServerName.text = "l2012" + $Text_ELogs_ServerName.TabIndex = 6 + $Text_ELogs_ServerName.add_TextChanged($Text_ELogs_ServerName_TextChanged) + # + # + # Text_ELogs_EventID + # + $Text_ELogs_EventID.Location = '115, 26' + $Text_ELogs_EventID.Name = 'Text_ELogs_EventID' + $Text_ELogs_EventID.Size = '40, 20' + $Text_ELogs_EventID.TabIndex = 7 + $Text_ELogs_EventID.add_TextChanged($Text_ELogs_EventID_TextChanged) + # + # Text_Elogs_DaysBack + # + $Text_Elogs_DaysBack.Location = '175, 26' + $Text_Elogs_DaysBack.Name = 'Text_Elogs_DaysBack' + $Text_Elogs_DaysBack.Size = '40, 20' + $Text_Elogs_DaysBack.TabIndex = 7 + $Text_Elogs_DaysBack.add_TextChanged($Text_Elogs_DaysBack_TextChanged) + # + #Save the initial state of the form + $InitialFormWindowState = $form1.WindowState + #Init the OnLoad event to correct the initial state of the form + $form1.add_Load($Form_StateCorrection_Load) + #Clean up the control events + $form1.add_FormClosed($Form_Cleanup_FormClosed) + #Show the Form + return $form1.ShowDialog() + +} #End Function + +#Call the form +Show-Form-Template_psf | Out-Null diff --git a/dump/SCCM-Tool/NA-Tool-GUI-10x.ps1 b/dump/SCCM-Tool/NA-Tool-GUI-10x.ps1 new file mode 100644 index 0000000..ff3c895 --- /dev/null +++ b/dump/SCCM-Tool/NA-Tool-GUI-10x.ps1 @@ -0,0 +1,948 @@ +#------------------------------------------------------------------------ +# Source File Information (DO NOT MODIFY) +# Source ID: 676f8db7-35c7-452d-b353-a4b40f26243a +# Source File: Form-Template.psf +#------------------------------------------------------------------------ +#region File Recovery Data (DO NOT MODIFY) +<#RecoveryData: +RAUAAB+LCAAAAAAABAC9VNtKwzAYvhd8h5Dr2oPd3AZtYXTuxtNwQ72TrP07o2lSknSzPr3p2g1x +QkHGKJSk+Q7/KQ0eIRFrkNWEaILMQlHBQ3xpezg6P0MoeJB0RTlhU8rgnuQQTYXMLxaQF4xosAuV +Bc4BpmEu3yHRSFcFhHheKQ25/Ux5KjbKrkWat4X+OrLQUxtKz3brx0JxyXQpIeRQakmYhWblktHk +BqqF+AAeLgcD0k/6V97I74E7HGHETSghzoyeh1HyRlkqDQ7HgmspmGoSNIHOpChA6qoljEst5glh +MKE58DoIA72ykOcHzg7aRb0TKWBTKq47OTGjwPWcfhnCwDU+/nDYSaqrjKNtap3YBXxqvG3bIfR6 +bbxb3K0gaav5Wq8DZ3vaNNNputlsxkpBbooPaqfTfqmiXCVCMro8QgMDZ6/626UZmVN4HH0sux3r +m3gaI0k2lK/+4+X6WT8bZJ6X9l3ik26vl5ydJKdYSDi+0X7bjHzg/PxrRt9OzyrdRAUAAA==#> +#endregion + +<# + .NOTES + -------------------------------------------------------------------------------- + Code generated by: SAPIEN Technologies, Inc., PowerShell Studio 2017 v5.4.141 + Generated on: 8/29/2017 11:53 AM + Generated by: Haidey2 + -------------------------------------------------------------------------------- + .DESCRIPTION + GUI script generated by PowerShell Studio 2017 +#> + + +#---------------------------------------------- +#region Application Functions +#---------------------------------------------- + +#endregion Application Functions + +#---------------------------------------------- +# Generated Form Function +#---------------------------------------------- +function Show-Form-Template_psf { + + #---------------------------------------------- + #region Import the Assemblies + #---------------------------------------------- + [void][reflection.assembly]::Load('System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') + [void][reflection.assembly]::Load('System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') + [void][reflection.assembly]::Load('System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') + #endregion Import Assemblies + + #---------------------------------------------- + #region Generated Form Objects + #---------------------------------------------- + [System.Windows.Forms.Application]::EnableVisualStyles() + $form1 = New-Object 'System.Windows.Forms.Form' + $InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState' + + + $Script:Output = New-Object System.Windows.Forms.TextBox + + $Script:Output_Left = New-Object System.Windows.Forms.TextBox + $Script:Output_Right = New-Object System.Windows.Forms.TextBox + + $Script:Collection_DropDownBox = New-Object System.Windows.Forms.ComboBox + $Script:Deployment_DropDownBox = New-Object System.Windows.Forms.ComboBox + $Script:Combobox_Tools = New-Object System.Windows.Forms.ComboBox + + $GroupBox = New-Object System.Windows.Forms.GroupBox + $GroupBox_Info = New-Object System.Windows.Forms.GroupBox + + $Script:RadioButton_Window = New-Object System.Windows.Forms.RadioButton + $Script:RadioButton_GridView = New-Object System.Windows.Forms.RadioButton + $Script:RadioButton_CSV = New-Object System.Windows.Forms.RadioButton + $Button_Go = New-Object System.Windows.Forms.Button + $Script:TextBox_CollectionName = New-Object “System.Windows.Forms.TextBox” + + #$PanelEventLogs_Events = New-Object 'System.Windows.Forms.Panel' + #$PanelEventLogs_Filter = New-Object 'System.Windows.Forms.Panel' + + + #$Text_ELogs_ServerName = New-Object 'System.Windows.Forms.TextBox' + #$Text_ELogs_EventID = New-Object 'System.Windows.Forms.TextBox' + #$Text_Elogs_DaysBack = New-Object 'System.Windows.Forms.TextBox' + + $label_CollectionName = New-Object 'System.Windows.Forms.Label' + $label_CollectionName_Value = New-Object 'System.Windows.Forms.Label' + $label_DeploymentName = New-Object 'System.Windows.Forms.Label' + $label_DeploymentName_Value = New-Object 'System.Windows.Forms.Label' + $label_DeploymentTime = New-Object 'System.Windows.Forms.Label' + $label_DeploymentTime_Value = New-Object 'System.Windows.Forms.Label' + $label_DeviceCount = New-Object 'System.Windows.Forms.Label' + $label_DeviceCount_Value = New-Object 'System.Windows.Forms.Label' + + $label_ServersResponding = New-Object 'System.Windows.Forms.Label' + $label_ServersResponding_Value = New-Object 'System.Windows.Forms.Label' + $label_ServersNOTResponding = New-Object 'System.Windows.Forms.Label' + $label_ServersNOTResponding_Value = New-Object 'System.Windows.Forms.Label' + $label_ServersPinging = New-Object 'System.Windows.Forms.Label' + $label_ServersPinging_Value = New-Object 'System.Windows.Forms.Label' + + + #$Button_ELogs_Connect = New-Object 'System.Windows.Forms.Button' + +# $Location = Split-Path $MyInvocation.MyCommand.Path -Parent + + $Script:ALL_Patch_Servers = @() + $Script:Responding = @() + $Script:NotResponding = @() + $Global:DeviceCollection_ServerNames1 = "" + + $Global:Collection_Name = "" + $Global:Select_Tool + $Global:Output_Type = "" + $Global:Deployments = "" + + #endregion Generated Form Objects + + #---------------------------------------------- + # User Generated Script + #---------------------------------------------- + + $form1_Load={ + #TODO: Initialize Form Controls here + + } + + $Script:Collection_DropDownBox_SelectedIndexChanged={ + + $Script:Output.Text = $Script:Collection_DropDownBox.Text + $T = Get-CMDeviceCollection -Name $Script:Collection_DropDownBox.text | select Name,MemberCount + + $label_DeviceCount_Value.Text = $T.MemberCount + + } + + $Script:Deployment_DropDownBox_SelectedIndexChanged={ + Reset-Forms -Form_Selection 1 + Deployed-to-Collections + $Script:Output.Text = $Script:Deployment_DropDownBox.Text + } + + $Script:Combobox_Tools_SelectedIndexChanged= { + $Script:Output.Text = $Script:Combobox_Tools.Text + + + } + + $Button_Go_Click = { + temp + #SCCM-Module + # $Global:Collection_Name = $Script:TextBox_CollectionName.Text #$Script:TextBox_CollectionName.Text + # $Global:Select_Tool = $Script:Combobox_Tools.Text + + + #$Output.Text = "$Global:Collection_Name --- $Global:Select_Tool " | Out-String + #$Output.Text = | Out-String + } + + +################################################################################################################## + Function ConnectTo-SCCM { + + If(!(Get-PSDrive).Name -ne "CCX") { + # + # Press 'F5' to run this script. Running this script will load the ConfigurationManager + # module for Windows PowerShell and will connect to the site. + # + # This script was auto-generated at '2/18/2021 10:12:39 AM'. + + # Uncomment the line below if running in an environment where script signing is + # required. + #Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process + + # Site configuration + $SiteCode = "CCX" # Site code + $ProviderMachineName = "PNCRASCCM001.ccx.carecentrix.com" # SMS Provider machine name + + # Customizations + $initParams = @{} + #$initParams.Add("Verbose", $true) # Uncomment this line to enable verbose logging + #$initParams.Add("ErrorAction", "Stop") # Uncomment this line to stop the script on any errors + + # Do not change anything below this line + + # Import the ConfigurationManager.psd1 module + if((Get-Module ConfigurationManager) -eq $null) { + Import-Module "$($ENV:SMS_ADMIN_UI_PATH)\..\ConfigurationManager.psd1" @initParams + } + + # Connect to the site's drive if it is not already present + if((Get-PSDrive -Name $SiteCode -PSProvider CMSite -ErrorAction SilentlyContinue) -eq $null) { + New-PSDrive -Name $SiteCode -PSProvider CMSite -Root $ProviderMachineName @initParams + } + + # Set the current location to be the site code. + Set-Location "$($SiteCode):\" @initParams + + #$Script:Output.Text = "inside connectoSCCM function" + }#endIf + }#endFunction +################################################################################################################## + Function SCCM-Module { + Write-Host "Inside SCCM function" -ForegroundColor Cyan + If(!(Get-PSDrive).Name -eq "sccm-drive") { + + Import-Module 'C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1' + New-PSDrive -Name SCCM-Drive -PSProvider "AdminUI.PS.Provider\CMSite" -Root "PNCRASCCM001.ccx.carecentrix.com" -Description "SCCM Site" + }#endIf + $Script:Output.Text | Get-PSDrive | ft -AutoSize | Out-String + CD sccm-drive: + }#endFunction +################################################################################################################## + Function Update-Dropdown1 { + # $Collections += $Script:Collection_DropDownBox.text + $Collections = @("Collection-Servers","Ping-Collection","Check_Uptime","Test-Service","Remotely Update Policy","Software Update Status","Test-Sccm") + $Collections | % { $Script:Combobox_Tools.Items.Add($_) } + } +################################################################################################################## + Function Reset-Forms { + Param($Form_Selection) + + Switch ($Form_Selection) { + 1 { $Collection_DropDownBox.Items.Clear(); $Collection_DropDownBox.Text = "--Deployed to Collections--" } + 2 {} + + } + + } +################################################################################################################## + Function temp { + $Script:Output.Clear() + $Script:Output_Left.Clear() + $Script:Output_Right.Clear() + #$Script:Script:Output.text = $Script:Collection_DropDownBox.text | Out-String + + #$Global:Collection_Name = $Script:TextBox_CollectionName.Text #$Script:TextBox_CollectionName.Text + $Global:Collection_Name = $Script:Collection_DropDownBox.Text + $Global:Select_Tool = $Script:Combobox_Tools.Text + + + If ($Script:RadioButton_Window.Checked -eq $true) { $Global:Output_Type = "Window" <#; $Script:Output.Text = "Window_Radio1 Checked: $($Script:RadioButton_Window.Checked)" | Out-String #> } + ElseIf ($Script:RadioButton_GridView.Checked -eq $true) { $Global:Output_Type = "Gridview" <#; $Script:Output.Text = "Gridview_Radio2 Checked: $($Script:RadioButton_GridView.Checked)" | Out-String #> } + ElseIf ($Script:RadioButton_CSV.Checked -eq $true) { $Global:Output_Type = "Export" <#; $Script:Output.Text = "CSV_Radio3 Checked: $($Script:RadioButton_CSV.Checked)" | Out-String #> } + + + If($Global:Collection_Name -and $Global:Select_Tool) { + # If($Script:Collection_DropDownBox.text = "Tool1"){gcc} + Run-Tool + #$Script:TextBox_CollectionName.clear() + $Script:Collection_DropDownBox.text = "----Select Collection----" + #Clear-Variables + }#endIf + Else { #$T = { Write-Host "You must enter Collection Name ............!!" -ForegroundColor Red } + $Script:Output.SelectionColor = 'red' + $Script:Output.Text = "You must select 'Tool' and enter Collection Name............!!" + } + + Run-Defaults + }#endFunction +################################################################################################################## + Function Run-Tool { + + Switch($Global:Select_Tool) { + Collection-Servers { Collection-Servers; Write-Host "Tool Selected: $Global:Select_Tool" } + Ping-Collection { Ping_Collection } + Check_Uptime { Check_Uptime } + Test-Service { Test-Service } + Test-SCCM { SCCM-Module } + #"Remotely Update Policy" { $Script:Output.Text = Invoke-Expression $Location\Tool-Remotely-Restart-SCCMSyncCycle.ps1 | ft -AutoSize | Out-String } + "Remotely Update Policy" { $Script:Output.Text = Invoke-Expression $Location\Tool-Remotely-Restart-SCCMSyncCycle.ps1 | ft -AutoSize | Out-String } + "Software Update Status" { $Script:Output.Text = & "$Location\Tool-Get-SCCMSoftwareUpdateStatus.ps1" -Dep_ID 16778048 | ft -AutoSize | Out-String} + }#endSwitch + #Clear-Variables + }#endFunction +################################################################################################################## + Function Run-Defaults { + #$Script:TextBox_CollectionName.Text = "Nabil - Test Collection" + $Script:RadioButton_Window.Checked = $true + + <# + If(!$Location) { + $Location = Split-Path $MyInvocation.MyCommand.Path -Parent + } + #> + } +################################################################################################################## + Function xClear-Variables { + $Global:Collection_Name = "" + $Global:Select_Tool = "" + $Global:Output_Type = "" + + $Script:ALL_Patch_Servers = @() + } +################################################################################################################## + Function Display-Results { + #Param($Global:Output_Type,$Final_Result) + Write-Host "DisplayType: $($Global:Output_Type)" + Switch ($Global:Output_Type){ + + Window { $Script:Output.Text = $Script:ALL_Patch_Servers | Out-String} + Gridview { $Script:ALL_Patch_Servers | Out-GridView } + Export { $Script:ALL_Patch_Servers | Export-Csv -Path $Location\Results.csv -NoTypeInformation; ii $Location\Results.csv } + + }#endSwitch + + } +############################################################################################################################################################# + Function Collection-Servers { + #Param($Coll_Name) + + Write-Host "Collection:$Global:Collection_Name" + $Script:ALL_Patch_Servers = @() + + ConnectTo-SCCM + NA-Set-Stage -Select_Stage OutputStage2 + #SCCM-Module + #CD sccm-drive: + $Script:DeviceCollection_MemberCount = Get-CMDeviceCollection -Name $Global:Collection_Name | select Name,MemberCount + $Script:DeviceCollection_ServerNames = Collection-Members #Get-CMCollectionMember -CollectionName $Global:Collection_Name | select Name,IsClient #| Export-Csv "E:\SCCM-Files\SCCM-Scripts\Files\$Global:Collection_Name.csv" -NoTypeInformation + #$ServerName = $DeviceCollection_ServerNames.Name + #Set-Location c: + + #$Script:Temp = Get-CMCollectionMember -CollectionName $Global:Collection_Name #| select Name,IsClient + + $Script:DeviceCollection_ServerNames | % { + $Obj = New-Object -TypeName PSObject + $Obj | Add-Member -MemberType NoteProperty -Name Server -Value $_.Name + $Obj | Add-Member -MemberType NoteProperty -Name ClientInstalled -Value $_.IsClient + $Obj | Add-Member -MemberType NoteProperty -Name CollectionName -Value $Global:Collection_Name + #$Obj | Add-Member -MemberType NoteProperty -Name CollectionMemberCount -Value {(Get-CMCollectionMember -Name $Global:Collection_Name).MemberCount} + + $Obj + $Script:ALL_Patch_Servers += $Obj + + }#end% + + # $Script:Output.Text = $Script:ALL_Patch_Servers | Out-String + Display-Results #-Final_Result $Script:ALL_Patch_Servers + Write-Host "$Script:ALL_Patch_Servers" + # $Script:ALL_Patch_Servers | Export-Csv $Location\Current-Collection-Servers.csv -NoTypeInformation + + }#endFunction +############################################################################################################################################################# + Function Collection-Members { + Get-CMCollectionMember -CollectionName $Global:Collection_Name | select Name,IsClient + + } + +############################################################################################################################################################# + Function NA-Set-Stage { + Param($Select_Stage) + Switch($Select_Stage) { + OutputStage1 { $Script:Output.Visible = $false + $Script:Output_Left.Visible = $True + $Script:Output_Right.Visible = $True + $label_ServersResponding.Visible = $True + $label_ServersResponding_Value.Visible = $True + $label_ServersNOTResponding.Visible = $True + $label_ServersNOTResponding_Value.Visible = $True + $label_ServersPinging.Visible = $True + $label_ServersPinging_Value.Visible = $True + + + #Write-Host "output-stage1" -ForegroundColor Yellow + } + OutputStage2 { $Script:Output.Visible = $True + $label_ServersResponding.Visible = $false + $label_ServersResponding_Value.Visible = $false + $label_ServersNOTResponding.Visible = $False + $label_ServersNOTResponding_Value.Visible = $false + $Script:Output_Left.Visible = $false + $Script:Output_Right.Visible = $false + $label_ServersPinging.Visible = $false + $label_ServersPinging_Value.Visible = $false + } + test { $Script:Output.Text = "inside na set stage function"} + }#endSwitch + $Script:Output.Text = "outside switch inside na set stage function - param: $Select_Stage" + + + + }#endFunction +############################################################################################################################################################# + + Function Ping_Collection { + + $Ping_Result = @() + $NotResponding = @() + $Responding = @() + + ConnectTo-SCCM + + NA-Set-Stage -Select_Stage OutputStage1 + #$Script:Output.Visible = $false + #$Script:Output_Left.Visible = $True + #$Script:Output_Right.Visible = $True + + + $Global:DeviceCollection_ServerNames1 = Collection-Members #Get-CMCollectionMember -CollectionName $Global:Collection_Name | select Name + #Set-Location c: + + Write-Host "Total Server Count: $($Global:DeviceCollection_ServerNames1.count)" -ForegroundColor Green + Write-Host "" + + ############ + # $Script:Output.Text = "CollectionName: $($Global:Collection_Name) ------ hello " + ############ + $Global:DeviceCollection_ServerNames1.Name | % { + $Server = $_ + $label_ServersPinging_Value.Text = $Server + $Obj = New-Object -TypeName PSObject + $Count = $Global:DeviceCollection_ServerNames1.count + #$Script:Output.Text = "Checking: $Server ----- Servers left: $($Count--) Please Wait !!!" | Out-String + + If (Test-Connection $Server -Count 1 -ErrorAction SilentlyContinue ) { + #Write-Host "Responding:---- $_ " -ForegroundColor Green + #$Script:Output.AppendText("Responding: $_") + + $Obj | Add-Member -MemberType NoteProperty -Name Server -Value $Server + $Obj | Add-Member -MemberType NoteProperty -Name Responding -Value "Yes" + $Ping_Result += $Obj + #$Responding += $Server + $Responding += $Obj + # $Script:Output.text += $Obj | Out-String + }#endIf + + Else { + $Obj | Add-Member -MemberType NoteProperty -Name Server -Value $Server + $Obj | Add-Member -MemberType NoteProperty -Name Responding -Value "No!" + $Ping_Result += $Obj + #$NotResponding += $Server + $NotResponding += $Obj + # $Script:Output.text += $Obj | Out-String + } + }#end% + #$Script:Output.Text = $Ping_Result | ft -AutoSize | Out-String + $Script:Output_Left.Text = $Responding | Out-String + $Script:Output_Right.Text = $NotResponding | Out-String + + $label_ServersPinging_Value.Text = "Done !" + $label_ServersResponding_Value.Text = $Responding.Count + $label_ServersNOTResponding_Value.Text = $NotResponding.Count + + write-host "-------------------------------------------------------" + Write-host "$($Responding.count) / $($DeviceCollection_ServerNames1.count) -- Responding" -foregroundcolor Green + Write-host "$($NotResponding.count) / $($DeviceCollection_ServerNames1.count) -- NOT Responding" -foregroundcolor Red + + #Write-Host "Servers NOT Responding: $NotResponding " -ForegroundColor Red + + }#endFunction +############################################################################################################################################################# + Function Check_Uptime { + ConnectTo-SCCM + $Global:DeviceCollection_ServerNames1 = Get-CMCollectionMember -CollectionName $Global:Collection_Name | select Name + $Script:Output.Text = $Global:DeviceCollection_ServerNames1.name | % { gwmi win32_operatingsystem -ComputerName $_ -ErrorAction SilentlyContinue | select @{n="Server";e={$_.PSComputername}},@{n="LastReboot";e={$_.Converttodatetime($_.LastBootUpTime)}}} | sort LastBootup -descending | Out-String + + } + +############################################################################################################################################################# + Function Deployment-List { + Param($Deployment_History) + # SCCM-Module + $Global:Deployments = Get-CMDeployment | ? { $_.deploymenttime -gt ((Get-Date).AddDays(-"$Deployment_History")) } + + #$T | select ApplicationName,CollectionName,DeploymentTime,AssignmentID,SoftwareName | % { $Deployment_DropDownBox.Items.Add($_) } + $i = 0 + $Q = "" #@() + + $Global:Deployments.ApplicationName | % { $Script:Deployment_DropDownBox.Items.Add($_)} + <# + foreach ($D in $Deployments) { + $Q = $D.ApplicationName + "-------------------------------------------------------" + $D.CollectionName + + $Deployment_DropDownBox.Items.Add($Q) + $i++ + } + #> + + #$T.ApplicationName | % { $Deployment_DropDownBox.Items.Add($_) } + + }#endFunction +############################################################################################################################################################# + Function Deployed-to-Collections { + $T = $Global:Deployments | ? { $_.ApplicationName -eq "$($Script:Deployment_DropDownBox.text)" } | Select -ExpandProperty CollectionName + $Script:Collection_DropDownBox.Items.Clear() + $T | % { $Script:Collection_DropDownBox.Items.Add("$_")} + } + +############################################################################################################################################################# + Function Test-Service { + + $Script:Output.Text = "test-service function" + #$T = Get-Service + #$Script:Output.Text = $T | ft -AutoSize | Out-String + } +################################################################################################################## + +################################################################################################################## + # --End User Generated Script-- + #---------------------------------------------- + #region Generated Events + #---------------------------------------------- + + $Form_StateCorrection_Load= + { + #Correct the initial state of the form to prevent the .Net maximized form issue + $form1.WindowState = $InitialFormWindowState + } + + $Form_Cleanup_FormClosed= + { + #Remove all event handlers from the controls + try + { + $form1.remove_Load($form1_Load) + $form1.remove_Load($Form_StateCorrection_Load) + $form1.remove_FormClosed($Form_Cleanup_FormClosed) + + #$PanelEventLogs_Events.remove_Paint($PanelEventLogs_Events_Paint) + #$PanelEventLogs_Filter.remove_Paint($PanelEventLogs_Filter_Paint) + + $Text_Elogs_DaysBack.remove_TextChanged($Text_Elogs_DaysBack_TextChanged) + $Text_ELogs_ServerName.remove_TextChanged($Text_ELogs_ServerName_TextChanged) + $Text_ELogs_EventID.remove_TextChanged($Text_ELogs_EventID_TextChanged) + + $Script:Output.remove_TextChanged($Output_TextChanged) + $Script:Output_Left.remove_TextChanged($Script:Output_Left_TextChanged) + $Script:Output_Right.remove_TextChanged($Script:Output_Right_TextChanged) + + $Script:Collection_DropDownBox.remove_SelectedIndexChanged($Script:Collection_DropDownBox_SelectedIndexChanged) + $Script:Deployment_DropDownBox.remove_SelectedIndexChanged($Script:Deployment_DropDownBox_SelectedIndexChanged) + $Script:Combobox_Tools.remove_SelectedIndexChanged($Script:Combobox_Tools_SelectedIndexChanged) + $Script:RadioButton_Window.remove_SelectedIndexChanged($Script:RadioButton_Window_SelectedIndexChanged) + $Script:RadioButton_GridView.remove_SelectedIndexChanged($Script:RadioButton_GridView_SelectedIndexChanged) + $Script:RadioButton_CSV.remove_SelectedIndexChanged($Script:RadioButton_CSV_SelectedIndexChanged) + $Button_Go.remove_Click($Button_Go_Click) + + } + catch { Out-Null <# Prevent PSScriptAnalyzer warning #> } + } + + + #$PanelEventLogs_Events_Paint=[System.Windows.Forms.PaintEventHandler]{ <#Event Argument: $_ = [System.Windows.Forms.PaintEventArgs]#> } + #$PanelEventLogs_Filter_Paint=[System.Windows.Forms.PaintEventHandler]{ } + + $Text_ELogs_ServerName_TextChanged={} + $Text_Elogs_DaysBack_TextChanged={} + + #endregion Generated Events + + #---------------------------------------------- + #region Generated Form Code + #---------------------------------------------- + # + # form1 + # + #$form1.Controls.Add($PanelEventLogs_Events) + #$form1.Controls.Add($PanelEventLogs_Filter) + + $form1.Controls.Add($Script:Output) + $form1.Controls.Add($Script:Output_Left) + $form1.Controls.Add($Script:Output_Right) + $form1.Controls.Add($Script:Collection_DropDownBox) + $form1.Controls.Add($Script:Deployment_DropDownBox) + $form1.Controls.Add($Script:Combobox_Tools) + $form1.Controls.Add($GroupBox) + $form1.Controls.Add($GroupBox_Info) + $form1.controls.Add($Script:RadioButton_Window) + $form1.controls.Add($Script:RadioButton_GridView) + $form1.Controls.Add($Script:RadioButton_CSV) + $form1.Controls.Add($Button_Go) + $form1.Controls.Add($Script:TextBox_CollectionName) + $form1.Controls.Add($label_CollectionName) + $form1.Controls.Add($label_CollectionName_Value) + $form1.Controls.Add($label_DeploymentName) + $form1.controls.Add($label_DeploymentName_Value) + $form1.Controls.Add($label_DeploymentTime) + $form1.Controls.Add($label_DeploymentTime_Value) + $form1.Controls.Add($label_DeviceCount) + $form1.Controls.Add($label_DeviceCount_Value) + $form1.Controls.Add($label_ServersResponding) + $form1.Controls.Add($label_ServersResponding_Value) + $form1.Controls.Add($label_ServersNOTResponding) + $form1.Controls.Add($label_ServersNOTResponding_Value) + $form1.Controls.Add($label_ServersPinging) + $form1.Controls.Add($label_ServersPinging_Value) + + + + $form1.AutoScaleDimensions = '6, 13' + $form1.AutoScaleMode = 'Font' + $form1.ClientSize = '1000, 800' + $form1.Name = 'form1' + $form1.Text = 'Form' + $form1.add_Load($form1_Load) + #endregion Generated Form Code + + #---------------------------------------------- +<# + $PanelEventLogs_Events.Controls.Add($Text_ELogs_ServerName) + $PanelEventLogs_Events.Controls.Add($Button_ELogs_Connect) + $PanelEventLogs_Events.Controls.Add($Button_ELogs_View) + $PanelEventLogs_Events.Controls.Add($Combobox_EventLogs_LogsList) + $PanelEventLogs_Events.Controls.Add($VCenterUserPassword) + $PanelEventLogs_Events.Controls.Add($CheckBoxUseWindowsLogin) + $PanelEventLogs_Events.Controls.Add($labelVCenterUserName) + $PanelEventLogs_Events.Controls.Add($labelVCenterPassword) + $PanelEventLogs_Events.Controls.Add($Script:Collection_DropDownBox) + $PanelEventLogs_Events.BackColor = '153,153,153' + $PanelEventLogs_Events.Location = '6, 6' + $PanelEventLogs_Events.Name = 'panelEventLogs_Events' + $PanelEventLogs_Events.Size = '598, 56' + $PanelEventLogs_Events.TabIndex = 0 + $PanelEventLogs_Events.add_Paint($PanelEventLogs_Events_Paint) + + $PanelEventLogs_Filter.Controls.Add($Combobox_ELogsFilter_Level) + $PanelEventLogs_Filter.Controls.Add($Text_ELogs_EventID) + $PanelEventLogs_Filter.Controls.Add($Text_Elogs_DaysBack) + $PanelEventLogs_Filter.Controls.Add($label_ELogs_Level) + $PanelEventLogs_Filter.Controls.Add($label_ELogs_EventID) + $PanelEventLogs_Filter.Controls.Add($label_ELogs_DaysBack) + $PanelEventLogs_Filter.BackColor = '255,255,212' + $PanelEventLogs_Filter.Location = '6, 62' + $PanelEventLogs_Filter.Name = 'PanelEventLogs_Filter' + $PanelEventLogs_Filter.Size = '598, 56' + $PanelEventLogs_Filter.BorderStyle = 'FixedSingle' + $PanelEventLogs_Filter.TabIndex = 0 + $PanelEventLogs_Filter.add_Paint($PanelEventLogs_Filter_Paint) +#> + # + # $Text_ELogs_ServerName + <# + $Text_ELogs_ServerName.Location = '8, 26' + $Text_ELogs_ServerName.Name = '$Text_ELogs_ServerName' + $Text_ELogs_ServerName.Size = '100, 20' + $Text_ELogs_ServerName.text = "l2012" + $Text_ELogs_ServerName.TabIndex = 6 + $Text_ELogs_ServerName.add_TextChanged($Text_ELogs_ServerName_TextChanged) + # + # + # Text_ELogs_EventID + # + $Text_ELogs_EventID.Location = '115, 26' + $Text_ELogs_EventID.Name = 'Text_ELogs_EventID' + $Text_ELogs_EventID.Size = '40, 20' + $Text_ELogs_EventID.TabIndex = 7 + $Text_ELogs_EventID.add_TextChanged($Text_ELogs_EventID_TextChanged) + # + # Text_Elogs_DaysBack + # + $Text_Elogs_DaysBack.Location = '175, 26' + $Text_Elogs_DaysBack.Name = 'Text_Elogs_DaysBack' + $Text_Elogs_DaysBack.Size = '40, 20' + $Text_Elogs_DaysBack.TabIndex = 7 + $Text_Elogs_DaysBack.add_TextChanged($Text_Elogs_DaysBack_TextChanged) + #> + # Output + # + $Script:Output.Location = '10, 250' + $Script:Output.Multiline = $True + $Script:Output.Name = 'Output' + $Script:Output.ScrollBars = 'both' + $Script:Output.Size = '965, 500' + $Script:Output.Font = 'Consolas, 8.25pt' + $Script:Output.WordWrap = $False + $Script:Output.TabIndex = 5 + $Script:Output.add_TextChanged($Output_TextChanged) + $Script:Output.Visible = $True + # + $Script:Output_Left.Location = '20, 250' + $Script:Output_Left.Multiline = $True + $Script:Output_Left.Name = 'Output_Left' + $Script:Output_Left.ScrollBars = 'both' + $Script:Output_Left.Size = '470, 500' + $Script:Output_Left.Font = 'Consolas, 8.25pt' + $Script:Output_Left.WordWrap = $False + #$Script:Output_Left.TabIndex = 5 + + $Script:Output_Left.add_TextChanged($Output_Left_TextChanged) + # + $Script:Output_Right.Location = '510, 250' + $Script:Output_Right.Multiline = $True + $Script:Output_Right.Name = 'Output_Right' + $Script:Output_Right.ScrollBars = 'both' + $Script:Output_Right.Size = '470, 500' + $Script:Output_Right.Font = 'Consolas, 8.25pt' + $Script:Output_Right.WordWrap = $False + #$Script:Output_Right.TabIndex = 5 + $Script:Output_Right.add_TextChanged($Output_Right_TextChanged) + # + # ComboboxServiceStartMode + # + $Script:Collection_DropDownBox.FormattingEnabled = $True + $Script:Collection_DropDownBox.Location = '20, 80' + $Script:Collection_DropDownBox.Name = 'Script:Collection_DropDownBox' + $Script:Collection_DropDownBox.Size = '180, 20' + $Script:Collection_DropDownBox.TabIndex = 2 + $Script:Collection_DropDownBox.Text = '--Deployed to Collections--' + $Script:Collection_DropDownBox.add_SelectedIndexChanged($Script:Collection_DropDownBox_SelectedIndexChanged) + # + $Script:Deployment_DropDownBox.Location = '20,30' + #$Script:Deployment_DropDownBox.Size = New-Object System.Drawing.Size(580,50) + $Script:Deployment_DropDownBox.Size = '580,50' + #$Script:Deployment_DropDownBox.DropDownHeight = 200 + $Script:Deployment_DropDownBox.text = "----Select Deployment----" + #$Script:Deployment_DropDownBox.Visible = $false + $Script:Deployment_DropDownBox.add_SelectedIndexChanged($Script:Deployment_DropDownBox_SelectedIndexChanged) + # + #$Script:Combobox_Tools.Size = New-Object System.Drawing.Size(180,20) + #$Script:Combobox_Tools.DropDownHeight = 200 + $Script:Combobox_Tools.text = "----Select Tool----!" + $Script:Combobox_Tools.Location = '20,170' + $Script:Combobox_Tools.Size = '180,10' + $Script:Combobox_Tools.add_SelectedIndexChanged($Script:Combobox_Tools_SelectedIndexChanged) + # + $groupBox.Location = '270,70' + $groupBox.size = ('150,90') #New-Object System.Drawing.Size(150,90) + $groupBox.text = "Select Output:" + $GroupBox.Controls.Add($Script:RadioButton_Window) + $GroupBox.Controls.Add($Script:RadioButton_GridView) + $GroupBox.Controls.Add($Script:RadioButton_CSV) + # + $GroupBox_Info.Location = '670,25' + $GroupBox_Info.Size = '300,160' + $GroupBox_Info.Text = "Deployment Info" + ############ + $GroupBox_Info.Controls.Add($label_CollectionName) + $GroupBox_Info.Controls.Add($label_CollectionName_Value) + $GroupBox_Info.Controls.Add($label_DeploymentName) + $GroupBox_Info.Controls.Add($label_DeploymentName_Value) + $GroupBox_Info.Controls.Add($label_DeploymentTime) + $GroupBox_Info.Controls.Add($label_DeploymentTime_Value) + $GroupBox_Info.Controls.Add($label_DeviceCount) + $GroupBox_Info.Controls.Add($label_DeviceCount_Value) + ############ + $label_CollectionName.AutoSize = $True + $label_CollectionName.Font = 'Microsoft Sans Serif, 9.0pt' #, style=Bold' + #$label_CollectionName.ForeColor = 'DarkGreen' + #$label_CollectionName.TextAlign = 'MiddleRight' + $label_CollectionName.Location = '20,25' + $label_CollectionName.Name = 'Collection_Name' + $label_CollectionName.Size = '41, 13' + #$label_CollectionName.TabIndex = 6 + $label_CollectionName.Text = 'Collection Name:' + #$label_CollectionName.add_Click($label_CollectionName_Click) + + ############ Value ############### + $label_CollectionName_Value.AutoSize = $True + $label_CollectionName_Value.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_CollectionName_Value.ForeColor = 'DarkGreen' + #$label_CollectionName_Value.TextAlign = 'MiddleRight' + $label_CollectionName_Value.Location = '140,25' + $label_CollectionName_Value.Name = 'Collection_Name_Value' + $label_CollectionName_Value.Size = '41, 13' + #$label_CollectionName_Value.TabIndex = 6 + $label_CollectionName_Value.Text = '_' + #$label_CollectionName_Value.add_Click($label_CollectionName_Value_Click) + + ############ + $label_DeploymentName.AutoSize = $True + $label_DeploymentName.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_DeploymentName.ForeColor = 'DarkGreen' + #$label_DeploymentName.TextAlign = 'MiddleRight' + $label_DeploymentName.Location = '20,45' + $label_DeploymentName.Name = 'Deployment_Name' + $label_DeploymentName.Size = '41, 13' + #$label_DeploymentName.TabIndex = 6 + $label_DeploymentName.Text = 'Deployment Name:' + #$label_DeploymentName.add_Click($label_DeploymentName_Click) + + ############ Value ############ + $label_DeploymentName_Value.AutoSize = $True + $label_DeploymentName_Value.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_DeploymentName_Value.ForeColor = 'DarkGreen' + #$label_DeploymentName_Value.TextAlign = 'MiddleRight' + $label_DeploymentName_Value.Location = '140,45' + $label_DeploymentName_Value.Name = 'Deployment_Name_Value' + $label_DeploymentName_Value.Size = '41, 13' + #$label_DeploymentName_Value.TabIndex = 6 + $label_DeploymentName_Value.Text = '_' + #$label_DeploymentName_Value.add_Click($label_DeploymentName_Value_Click) + + ############# + $label_DeploymentTime.AutoSize = $True + $label_DeploymentTime.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_DeploymentTime.ForeColor = 'DarkGreen' + #$label_DeploymentTime.TextAlign = 'MiddleRight' + $label_DeploymentTime.Location = '20,65' + $label_DeploymentTime.Name = 'Deployment_Time' + $label_DeploymentTime.Size = '41, 13' + #$label_DeploymentTime.TabIndex = 6 + $label_DeploymentTime.Text = 'Deployment Time:' + #$label_DeploymentTime.add_Click($label_CollectionName_Click) + + ############ Value ############ + $label_DeploymentTime_Value.AutoSize = $True + $label_DeploymentTime_Value.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_DeploymentTime_Value.ForeColor = 'DarkGreen' + #$label_DeploymentTime_Value.TextAlign = 'MiddleRight' + $label_DeploymentTime_Value.Location = '140,65' + $label_DeploymentTime_Value.Name = 'Deployment_Time_Value' + $label_DeploymentTime_Value.Size = '41, 13' + #$label_DeploymentTime_Value.TabIndex = 6 + $label_DeploymentTime_Value.Text = '_' + #$label_DeploymentTime_Value.add_Click($label_DeploymentTime_Value_Click) + + ########### + $label_DeviceCount.AutoSize = $True + $label_DeviceCount.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_DeviceCount.ForeColor = 'DarkGreen' + #$label_DeviceCount.TextAlign = 'MiddleRight' + $label_DeviceCount.Location = '20,85' + $label_DeviceCount.Name = 'Device_Count' + $label_DeviceCount.Size = '41, 13' + #$label_DeviceCount.TabIndex = 6 + $label_DeviceCount.Text = 'Device Count' + #$label_DeviceCount.add_Click($label_DeviceCount_Click) + + ############ Value ############ + $label_DeviceCount_Value.AutoSize = $True + $label_DeviceCount_Value.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_DeviceCount_Value.ForeColor = 'DarkGreen' + #$label_DeviceCount_Value.TextAlign = 'MiddleRight' + $label_DeviceCount_Value.Location = '140,85' + $label_DeviceCount_Value.Name = 'Device_Count_Value' + $label_DeviceCount_Value.Size = '41, 13' + #$label_DeviceCount_Value.TabIndex = 6 + $label_DeviceCount_Value.Text = '_' + #$label_DeviceCount_Value.add_Click($label_DeviceCount_Value_Click) +############ + $label_ServersResponding.AutoSize = $True + $label_ServersResponding.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_ServersResponding.ForeColor = 'DarkGreen' + #$label_ServersResponding.TextAlign = 'MiddleRight' + $label_ServersResponding.Location = '15,225' + $label_ServersResponding.Name = 'Servers Responding' + $label_ServersResponding.Size = '41, 13' + #$label_ServersResponding.TabIndex = 6 + $label_ServersResponding.Text = 'Servers Responding: ' + $label_ServersResponding.Visible = $False + #$label_ServersResponding.add_Click($label_ServersResponding_Click) +############ + $label_ServersResponding_Value.AutoSize = $True + $label_ServersResponding_Value.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_ServersResponding_Value.ForeColor = 'DarkGreen' + #$label_ServersResponding.TextAlign = 'MiddleRight' + $label_ServersResponding_Value.Location = '155,225' + $label_ServersResponding_Value.Name = 'Servers Responding Vlue' + $label_ServersResponding_Value.Size = '41, 13' + #$label_ServersResponding_Value.TabIndex = 6 + $label_ServersResponding_Value.Text = '-' + $label_ServersResponding_Value.Visible = $False + #$label_ServersResponding_Value.add_Click($label_ServersResponding_Value_Click) +############ +$label_ServersNOTResponding.AutoSize = $True + $label_ServersNOTResponding.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_ServersNOTResponding.ForeColor = 'Red' + #$label_ServersNOTResponding.TextAlign = 'MiddleRight' + $label_ServersNOTResponding.Location = '510,225' + $label_ServersNOTResponding.Name = 'Servers Not Responding' + $label_ServersNOTResponding.Size = '41, 13' + #$label_ServersNOTResponding.TabIndex = 6 + $label_ServersNOTResponding.Text = 'Servers NOT Responding: ' + $label_ServersNOTResponding.Visible = $False + #$label_ServersNOTResponding.add_Click($label_ServersNOTResponding_Click) +############ +$label_ServersNOTResponding_Value.AutoSize = $True + $label_ServersNOTResponding_Value.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_ServersNOTResponding_Value.ForeColor = 'Red' + #$label_ServersNOTResponding_Value.TextAlign = 'MiddleRight' + $label_ServersNOTResponding_Value.Location = '670,225' + $label_ServersNOTResponding_Value.Name = 'Servers Not Responding Value' + $label_ServersNOTResponding_Value.Size = '41, 13' + #$label_ServersNOTResponding_Value.TabIndex = 6 + $label_ServersNOTResponding_Value.Text = '- ' + $label_ServersNOTResponding_Value.Visible = $False + #$label_ServersNOTResponding_Value.add_Click($label_ServersNOTResponding_Value_Click) +############ +$label_ServersPinging.AutoSize = $True + $label_ServersPinging.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_ServersPinging.ForeColor = 'Green' + #$label_ServersPinging.TextAlign = 'MiddleRight' + $label_ServersPinging.Location = '15,210' + $label_ServersPinging.Name = 'Servers Pinging' + $label_ServersPinging.Size = '41, 13' + #$label_ServersPinging.TabIndex = 6 + $label_ServersPinging.Text = 'Checking Servers: ' + $label_ServersPinging.Visible = $False + #$label_ServersPinging.add_Click($label_ServersPinging_Click) +############ +$label_ServersPinging_Value.AutoSize = $True + $label_ServersPinging_Value.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_ServersPinging_Value.ForeColor = 'Green' + #$label_ServersPinging_Value.TextAlign = 'MiddleRight' + $label_ServersPinging_Value.Location = '165,210' + $label_ServersPinging_Value.Name = 'Servers Pinging Value' + $label_ServersPinging_Value.Size = '41, 13' + $label_ServersPinging_Value.Text = '- ' + $label_ServersPinging_Value.Visible = $False + #$label_ServersPinging_Value.add_Click($label_ServersPinging_Value_Click) +############ + $Script:RadioButton_Window.Location = new-object System.Drawing.Point(15,15) + $Script:RadioButton_Window.size = New-Object System.Drawing.Size(130,20) + $Script:RadioButton_Window.Checked = $true + $Script:RadioButton_Window.Text = "Window" + #$Script:RadioButton_Window. + # + $Script:RadioButton_GridView.Location = new-object System.Drawing.Point(15,35) + $Script:RadioButton_GridView.size = New-Object System.Drawing.Size(80,20) + $Script:RadioButton_GridView.Checked = $False + $Script:RadioButton_GridView.Text = "GridView" + # + $Script:RadioButton_CSV.Location = new-object System.Drawing.Point(15,55) + $Script:RadioButton_CSV.size = New-Object System.Drawing.Size(80,20) + $Script:RadioButton_CSV.Checked = $False + $Script:RadioButton_CSV.Text = "CSV" + # + $Button_Go.Location = New-Object System.Drawing.Size(450,75) + $Button_Go.Size = New-Object System.Drawing.Size(110,80) + $Button_Go.Text = "Go" + #$Button_Go.Add_Click({temp}) + $Button_Go.Add_Click($Button_Go_Click) + # + $Script:TextBox_CollectionName.Left = 20; + $Script:TextBox_CollectionName.Top = 130; + $Script:TextBox_CollectionName.width = 200; + $Script:TextBox_CollectionName.Text = "Nabil - Test Collection" + # + ############################################################################ + Update-Dropdown1 + ConnectTo-SCCM + Deployment-List -Deployment_History 10 + $Script:Output.Text = "helloooooooo" + #cd c: + + + ############################################################################ + +#Save the initial state of the form + $InitialFormWindowState = $form1.WindowState + #Init the OnLoad event to correct the initial state of the form + $form1.add_Load($Form_StateCorrection_Load) + #Clean up the control events + $form1.add_FormClosed($Form_Cleanup_FormClosed) + #Show the Form + return $form1.ShowDialog() + +} #End Function + +#Call the form +Show-Form-Template_psf | Out-Null diff --git a/dump/SCCM-Tool/NA-Tool-GUI-11x.ps1 b/dump/SCCM-Tool/NA-Tool-GUI-11x.ps1 new file mode 100644 index 0000000..dbaffea --- /dev/null +++ b/dump/SCCM-Tool/NA-Tool-GUI-11x.ps1 @@ -0,0 +1,960 @@ +#------------------------------------------------------------------------ +# Source File Information (DO NOT MODIFY) +# Source ID: 676f8db7-35c7-452d-b353-a4b40f26243a +# Source File: Form-Template.psf +#------------------------------------------------------------------------ +#region File Recovery Data (DO NOT MODIFY) +<#RecoveryData: +RAUAAB+LCAAAAAAABAC9VNtKwzAYvhd8h5Dr2oPd3AZtYXTuxtNwQ72TrP07o2lSknSzPr3p2g1x +QkHGKJSk+Q7/KQ0eIRFrkNWEaILMQlHBQ3xpezg6P0MoeJB0RTlhU8rgnuQQTYXMLxaQF4xosAuV +Bc4BpmEu3yHRSFcFhHheKQ25/Ux5KjbKrkWat4X+OrLQUxtKz3brx0JxyXQpIeRQakmYhWblktHk +BqqF+AAeLgcD0k/6V97I74E7HGHETSghzoyeh1HyRlkqDQ7HgmspmGoSNIHOpChA6qoljEst5glh +MKE58DoIA72ykOcHzg7aRb0TKWBTKq47OTGjwPWcfhnCwDU+/nDYSaqrjKNtap3YBXxqvG3bIfR6 +bbxb3K0gaav5Wq8DZ3vaNNNputlsxkpBbooPaqfTfqmiXCVCMro8QgMDZ6/626UZmVN4HH0sux3r +m3gaI0k2lK/+4+X6WT8bZJ6X9l3ik26vl5ydJKdYSDi+0X7bjHzg/PxrRt9OzyrdRAUAAA==#> +#endregion + +<# + .NOTES + -------------------------------------------------------------------------------- + Code generated by: SAPIEN Technologies, Inc., PowerShell Studio 2017 v5.4.141 + Generated on: 8/29/2017 11:53 AM + Generated by: Haidey2 + -------------------------------------------------------------------------------- + .DESCRIPTION + GUI script generated by PowerShell Studio 2017 +#> + + +#---------------------------------------------- +#region Application Functions +#---------------------------------------------- + +#endregion Application Functions + +#---------------------------------------------- +# Generated Form Function +#---------------------------------------------- +function Show-Form-Template_psf { + + #---------------------------------------------- + #region Import the Assemblies + #---------------------------------------------- + [void][reflection.assembly]::Load('System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') + [void][reflection.assembly]::Load('System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') + [void][reflection.assembly]::Load('System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') + #endregion Import Assemblies + + #---------------------------------------------- + #region Generated Form Objects + #---------------------------------------------- + [System.Windows.Forms.Application]::EnableVisualStyles() + $form1 = New-Object 'System.Windows.Forms.Form' + $InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState' + + + $Script:Output = New-Object System.Windows.Forms.TextBox + + $Script:Output_Left = New-Object System.Windows.Forms.TextBox + $Script:Output_Right = New-Object System.Windows.Forms.TextBox + + $Script:Collection_DropDownBox = New-Object System.Windows.Forms.ComboBox + $Script:Deployment_DropDownBox = New-Object System.Windows.Forms.ComboBox + $Script:Combobox_Tools = New-Object System.Windows.Forms.ComboBox + + $GroupBox = New-Object System.Windows.Forms.GroupBox + $GroupBox_Info = New-Object System.Windows.Forms.GroupBox + + $Script:RadioButton_Window = New-Object System.Windows.Forms.RadioButton + $Script:RadioButton_GridView = New-Object System.Windows.Forms.RadioButton + $Script:RadioButton_CSV = New-Object System.Windows.Forms.RadioButton + $Button_Go = New-Object System.Windows.Forms.Button + $Script:TextBox_CollectionName = New-Object “System.Windows.Forms.TextBox” + + #$PanelEventLogs_Events = New-Object 'System.Windows.Forms.Panel' + #$PanelEventLogs_Filter = New-Object 'System.Windows.Forms.Panel' + + + #$Text_ELogs_ServerName = New-Object 'System.Windows.Forms.TextBox' + #$Text_ELogs_EventID = New-Object 'System.Windows.Forms.TextBox' + #$Text_Elogs_DaysBack = New-Object 'System.Windows.Forms.TextBox' + + $label_CollectionName = New-Object 'System.Windows.Forms.Label' + $label_CollectionName_Value = New-Object 'System.Windows.Forms.Label' + $label_DeploymentName = New-Object 'System.Windows.Forms.Label' + $label_DeploymentName_Value = New-Object 'System.Windows.Forms.Label' + $label_DeploymentTime = New-Object 'System.Windows.Forms.Label' + $label_DeploymentTime_Value = New-Object 'System.Windows.Forms.Label' + $label_DeviceCount = New-Object 'System.Windows.Forms.Label' + $label_DeviceCount_Value = New-Object 'System.Windows.Forms.Label' + + $label_ServersResponding = New-Object 'System.Windows.Forms.Label' + $label_ServersResponding_Value = New-Object 'System.Windows.Forms.Label' + $label_ServersNOTResponding = New-Object 'System.Windows.Forms.Label' + $label_ServersNOTResponding_Value = New-Object 'System.Windows.Forms.Label' + $label_ServersPinging = New-Object 'System.Windows.Forms.Label' + $label_ServersPinging_Value = New-Object 'System.Windows.Forms.Label' + + + #$Button_ELogs_Connect = New-Object 'System.Windows.Forms.Button' + +# $Location = Split-Path $MyInvocation.MyCommand.Path -Parent + + $Script:ALL_Patch_Servers = @() + $Script:Responding = @() + $Script:NotResponding = @() + $Global:DeviceCollection_ServerNames1 = "" + + $Global:Collection_Name = "" + $Global:Select_Tool + $Global:Output_Type = "" + $Global:Deployments = "" + + #endregion Generated Form Objects + + #---------------------------------------------- + # User Generated Script + #---------------------------------------------- + + $form1_Load={ + #TODO: Initialize Form Controls here + + } + + $Script:Collection_DropDownBox_SelectedIndexChanged={ + + $Script:Output.Text = $Script:Collection_DropDownBox.Text + $T = Get-CMDeviceCollection -Name $Script:Collection_DropDownBox.text | select Name,MemberCount + + $Info = $Global:Deployments | ? { $_.applicationname -eq "$($Script:Deployment_DropDownBox.text)" -and $_.collectionname -eq "$($Script:Collection_DropDownBox.text)" } | select applicationname,collectionname,deploymenttime + + $label_DeploymentName_Value.Text = $Info.ApplicationName + $label_DeploymentTime_Value.Text = $Info.DeploymentTime + $label_CollectionName_Value.Text = $Script:Collection_DropDownBox.Text #$T.CollectionName + + $label_DeviceCount_Value.Text = $T.MemberCount + + } + + $Script:Deployment_DropDownBox_SelectedIndexChanged={ + Reset-Forms -Form_Selection 1 + Deployed-to-Collections + $Script:Output.Text = $Script:Deployment_DropDownBox.Text + } + + $Script:Combobox_Tools_SelectedIndexChanged= { + $Script:Output.Text = $Script:Combobox_Tools.Text + + + } + + $Button_Go_Click = { + temp + #SCCM-Module + # $Global:Collection_Name = $Script:TextBox_CollectionName.Text #$Script:TextBox_CollectionName.Text + # $Global:Select_Tool = $Script:Combobox_Tools.Text + + + #$Output.Text = "$Global:Collection_Name --- $Global:Select_Tool " | Out-String + #$Output.Text = | Out-String + } + + +################################################################################################################## + Function ConnectTo-SCCM { + + If(!(Get-PSDrive).Name -ne "CCX") { + # + # Press 'F5' to run this script. Running this script will load the ConfigurationManager + # module for Windows PowerShell and will connect to the site. + # + # This script was auto-generated at '2/18/2021 10:12:39 AM'. + + # Uncomment the line below if running in an environment where script signing is + # required. + #Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process + + # Site configuration + $SiteCode = "CCX" # Site code + $ProviderMachineName = "PNCRASCCM001.ccx.carecentrix.com" # SMS Provider machine name + + # Customizations + $initParams = @{} + #$initParams.Add("Verbose", $true) # Uncomment this line to enable verbose logging + #$initParams.Add("ErrorAction", "Stop") # Uncomment this line to stop the script on any errors + + # Do not change anything below this line + + # Import the ConfigurationManager.psd1 module + if((Get-Module ConfigurationManager) -eq $null) { + Import-Module "$($ENV:SMS_ADMIN_UI_PATH)\..\ConfigurationManager.psd1" @initParams + } + + # Connect to the site's drive if it is not already present + if((Get-PSDrive -Name $SiteCode -PSProvider CMSite -ErrorAction SilentlyContinue) -eq $null) { + New-PSDrive -Name $SiteCode -PSProvider CMSite -Root $ProviderMachineName @initParams + } + + # Set the current location to be the site code. + Set-Location "$($SiteCode):\" @initParams + + #$Script:Output.Text = "inside connectoSCCM function" + }#endIf + }#endFunction +################################################################################################################## + Function SCCM-Module { + Write-Host "Inside SCCM function" -ForegroundColor Cyan + If(!(Get-PSDrive).Name -eq "sccm-drive") { + + Import-Module 'C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1' + New-PSDrive -Name SCCM-Drive -PSProvider "AdminUI.PS.Provider\CMSite" -Root "PNCRASCCM001.ccx.carecentrix.com" -Description "SCCM Site" + }#endIf + $Script:Output.Text | Get-PSDrive | ft -AutoSize | Out-String + CD sccm-drive: + }#endFunction +################################################################################################################## + Function Update-Dropdown1 { + # $Collections += $Script:Collection_DropDownBox.text + $Collections = @("Collection-Servers","Ping-Collection","Check_Uptime","Test-Service","Remotely Update Policy","Software Update Status","Test-Sccm") + $Collections | % { $Script:Combobox_Tools.Items.Add($_) } + } +################################################################################################################## + Function Reset-Forms { + Param($Form_Selection) + + Switch ($Form_Selection) { + 1 { $Collection_DropDownBox.Items.Clear(); $Collection_DropDownBox.Text = "--Deployed to Collections--" } + 2 {} + + } + + } +################################################################################################################## + Function temp { + $Script:Output.Clear() + $Script:Output_Left.Clear() + $Script:Output_Right.Clear() + #$Script:Script:Output.text = $Script:Collection_DropDownBox.text | Out-String + + #$Global:Collection_Name = $Script:TextBox_CollectionName.Text #$Script:TextBox_CollectionName.Text + $Global:Collection_Name = $Script:Collection_DropDownBox.Text + $Global:Select_Tool = $Script:Combobox_Tools.Text + + #$Script:Collection_DropDownBox.BackColor + If ($Script:RadioButton_Window.Checked -eq $true) { $Global:Output_Type = "Window" <#; $Script:Output.Text = "Window_Radio1 Checked: $($Script:RadioButton_Window.Checked)" | Out-String #> } + ElseIf ($Script:RadioButton_GridView.Checked -eq $true) { $Global:Output_Type = "Gridview" <#; $Script:Output.Text = "Gridview_Radio2 Checked: $($Script:RadioButton_GridView.Checked)" | Out-String #> } + ElseIf ($Script:RadioButton_CSV.Checked -eq $true) { $Global:Output_Type = "Export" <#; $Script:Output.Text = "CSV_Radio3 Checked: $($Script:RadioButton_CSV.Checked)" | Out-String #> } + + + If($Global:Collection_Name -and $Global:Select_Tool) { + + $Script:Output.Text = "CollectionName: $Global:Collection_Name ----- SelectTool: $Global:Select_Tool" + # If($Script:Collection_DropDownBox.text = "Tool1"){gcc} + Run-Tool + #$Script:TextBox_CollectionName.clear() + $Script:Collection_DropDownBox.text = "----Select Collection----" + #Clear-Variables + }#endIf + Else { #$T = { Write-Host "You must enter Collection Name ............!!" -ForegroundColor Red } + $Script:Output.SelectionColor = 'red' + $Script:Output.Text = "You must select 'Tool' and enter Collection Name............!!" + } + + Run-Defaults + }#endFunction +################################################################################################################## + Function Run-Tool { + + Switch($Global:Select_Tool) { + Collection-Servers { Collection-Servers; Write-Host "Tool Selected: $Global:Select_Tool" } + Ping-Collection { Ping_Collection } + Check_Uptime { Check_Uptime } + Test-Service { Test-Service } + Test-SCCM { SCCM-Module } + #"Remotely Update Policy" { $Script:Output.Text = Invoke-Expression $Location\Tool-Remotely-Restart-SCCMSyncCycle.ps1 | ft -AutoSize | Out-String } + "Remotely Update Policy" { $Script:Output.Text = Invoke-Expression $Location\Tool-Remotely-Restart-SCCMSyncCycle.ps1 | ft -AutoSize | Out-String } + "Software Update Status" { $Script:Output.Text = & "$Location\Tool-Get-SCCMSoftwareUpdateStatus.ps1" -Dep_ID 16778048 | ft -AutoSize | Out-String} + }#endSwitch + #Clear-Variables + }#endFunction +################################################################################################################## + Function Run-Defaults { + #$Script:TextBox_CollectionName.Text = "Nabil - Test Collection" + $Script:RadioButton_Window.Checked = $true + + <# + If(!$Location) { + $Location = Split-Path $MyInvocation.MyCommand.Path -Parent + } + #> + } +################################################################################################################## + Function xClear-Variables { + $Global:Collection_Name = "" + $Global:Select_Tool = "" + $Global:Output_Type = "" + + $Script:ALL_Patch_Servers = @() + } +################################################################################################################## + Function Display-Results { + #Param($Global:Output_Type,$Final_Result) + Write-Host "DisplayType: $($Global:Output_Type)" + Switch ($Global:Output_Type){ + + Window { $Script:Output.Text = $Script:ALL_Patch_Servers | Out-String} + Gridview { $Script:ALL_Patch_Servers | Out-GridView } + Export { $Script:ALL_Patch_Servers | Export-Csv -Path $Location\Results.csv -NoTypeInformation; ii $Location\Results.csv } + + }#endSwitch + + } +############################################################################################################################################################# + Function Collection-Servers { + #Param($Coll_Name) + + Write-Host "Collection:$Global:Collection_Name" + $Script:ALL_Patch_Servers = @() + + ConnectTo-SCCM + NA-Set-Stage -Select_Stage OutputStage2 + #SCCM-Module + #CD sccm-drive: + $Script:DeviceCollection_MemberCount = Get-CMDeviceCollection -Name $Global:Collection_Name | select Name,MemberCount + $Script:DeviceCollection_ServerNames = Collection-Members #Get-CMCollectionMember -CollectionName $Global:Collection_Name | select Name,IsClient #| Export-Csv "E:\SCCM-Files\SCCM-Scripts\Files\$Global:Collection_Name.csv" -NoTypeInformation + #$ServerName = $DeviceCollection_ServerNames.Name + #Set-Location c: + + #$Script:Temp = Get-CMCollectionMember -CollectionName $Global:Collection_Name #| select Name,IsClient + + $Script:DeviceCollection_ServerNames | % { + $Obj = New-Object -TypeName PSObject + $Obj | Add-Member -MemberType NoteProperty -Name Server -Value $_.Name + $Obj | Add-Member -MemberType NoteProperty -Name ClientInstalled -Value $_.IsClient + $Obj | Add-Member -MemberType NoteProperty -Name CollectionName -Value $Global:Collection_Name + #$Obj | Add-Member -MemberType NoteProperty -Name CollectionMemberCount -Value {(Get-CMCollectionMember -Name $Global:Collection_Name).MemberCount} + + $Obj + $Script:ALL_Patch_Servers += $Obj + + }#end% + + # $Script:Output.Text = $Script:ALL_Patch_Servers | Out-String + Display-Results #-Final_Result $Script:ALL_Patch_Servers + Write-Host "$Script:ALL_Patch_Servers" + # $Script:ALL_Patch_Servers | Export-Csv $Location\Current-Collection-Servers.csv -NoTypeInformation + + }#endFunction +############################################################################################################################################################# + Function Collection-Members { + Get-CMCollectionMember -CollectionName $Global:Collection_Name | select Name,IsClient + + } + +############################################################################################################################################################# + Function NA-Set-Stage { + Param($Select_Stage) + Switch($Select_Stage) { + OutputStage1 { $Script:Output.Visible = $false + $Script:Output_Left.Visible = $True + $Script:Output_Right.Visible = $True + $label_ServersResponding.Visible = $True + $label_ServersResponding_Value.Visible = $True + $label_ServersNOTResponding.Visible = $True + $label_ServersNOTResponding_Value.Visible = $True + $label_ServersPinging.Visible = $True + $label_ServersPinging_Value.Visible = $True + + + #Write-Host "output-stage1" -ForegroundColor Yellow + } + OutputStage2 { $Script:Output.Visible = $True + $label_ServersResponding.Visible = $false + $label_ServersResponding_Value.Visible = $false + $label_ServersNOTResponding.Visible = $False + $label_ServersNOTResponding_Value.Visible = $false + $Script:Output_Left.Visible = $false + $Script:Output_Right.Visible = $false + $label_ServersPinging.Visible = $false + $label_ServersPinging_Value.Visible = $false + } + test { $Script:Output.Text = "inside na set stage function"} + }#endSwitch + $Script:Output.Text = "outside switch inside na set stage function - param: $Select_Stage" + + + + }#endFunction +############################################################################################################################################################# + + Function Ping_Collection { + + $Ping_Result = @() + $NotResponding = @() + $Responding = @() + + ConnectTo-SCCM + + NA-Set-Stage -Select_Stage OutputStage1 + #$Script:Output.Visible = $false + #$Script:Output_Left.Visible = $True + #$Script:Output_Right.Visible = $True + + + $Global:DeviceCollection_ServerNames1 = Collection-Members -CollectionName $Global:Collection_Name | select Name #Get-CMCollectionMember + #Set-Location c: + + Write-Host "Total Server Count: $($Global:DeviceCollection_ServerNames1.count)" -ForegroundColor Green + Write-Host "" + + ############ + # $Script:Output.Text = "CollectionName: $($Global:Collection_Name) ------ hello " + ############ + $Global:DeviceCollection_ServerNames1.Name | % { + $Server = $_ + $label_ServersPinging_Value.Text = $Server + $Obj = New-Object -TypeName PSObject + $Count = $Global:DeviceCollection_ServerNames1.count + #$Script:Output.Text = "Checking: $Server ----- Servers left: $($Count--) Please Wait !!!" | Out-String + + If (Test-Connection $Server -Count 1 -ErrorAction SilentlyContinue ) { + #Write-Host "Responding:---- $_ " -ForegroundColor Green + #$Script:Output.AppendText("Responding: $_") + + $Obj | Add-Member -MemberType NoteProperty -Name Server -Value $Server + $Obj | Add-Member -MemberType NoteProperty -Name Responding -Value "Yes" + $Ping_Result += $Obj + #$Responding += $Server + $Responding += $Obj + # $Script:Output.text += $Obj | Out-String + }#endIf + + Else { + $Obj | Add-Member -MemberType NoteProperty -Name Server -Value $Server + $Obj | Add-Member -MemberType NoteProperty -Name Responding -Value "No!" + $Ping_Result += $Obj + #$NotResponding += $Server + $NotResponding += $Obj + # $Script:Output.text += $Obj | Out-String + } + + $label_ServersResponding_Value.Text = $Responding.Count + $label_ServersNOTResponding_Value.Text = $NotResponding.Count + + }#end% + #$Script:Output.Text = $Ping_Result | ft -AutoSize | Out-String + $Script:Output_Left.Text = $Responding | Out-String + $Script:Output_Right.Text = $NotResponding | Out-String + + $label_ServersPinging_Value.Text = "Done !" + + + write-host "-------------------------------------------------------" + Write-host "$($Responding.count) / $($DeviceCollection_ServerNames1.count) -- Responding" -foregroundcolor Green + Write-host "$($NotResponding.count) / $($DeviceCollection_ServerNames1.count) -- NOT Responding" -foregroundcolor Red + + #Write-Host "Servers NOT Responding: $NotResponding " -ForegroundColor Red + + }#endFunction +############################################################################################################################################################# + Function Check_Uptime { + ConnectTo-SCCM + $Global:DeviceCollection_ServerNames1 = Get-CMCollectionMember -CollectionName $Global:Collection_Name | select Name + $Script:Output.Text = $Global:DeviceCollection_ServerNames1.name | % { gwmi win32_operatingsystem -ComputerName $_ -ErrorAction SilentlyContinue | select @{n="Server";e={$_.PSComputername}},@{n="LastReboot";e={$_.Converttodatetime($_.LastBootUpTime)}}} | sort LastBootup -descending | Out-String + + } + +############################################################################################################################################################# + Function Deployment-List { + Param($Deployment_History) + # SCCM-Module + $Global:Deployments = Get-CMDeployment | ? { $_.deploymenttime -gt ((Get-Date).AddDays(-"$Deployment_History")) } + + #$T | select ApplicationName,CollectionName,DeploymentTime,AssignmentID,SoftwareName | % { $Deployment_DropDownBox.Items.Add($_) } + $i = 0 + $Q = "" #@() + + $Global:Deployments.ApplicationName | % { $Script:Deployment_DropDownBox.Items.Add($_)} + <# + foreach ($D in $Deployments) { + $Q = $D.ApplicationName + "-------------------------------------------------------" + $D.CollectionName + + $Deployment_DropDownBox.Items.Add($Q) + $i++ + } + #> + + #$T.ApplicationName | % { $Deployment_DropDownBox.Items.Add($_) } + + }#endFunction +############################################################################################################################################################# + Function Deployed-to-Collections { + $T = $Global:Deployments | ? { $_.ApplicationName -eq "$($Script:Deployment_DropDownBox.text)" } #| Select -ExpandProperty CollectionName + $Script:Collection_DropDownBox.Items.Clear() + $T.CollectionName | % { $Script:Collection_DropDownBox.Items.Add("$_")} + + + } + +############################################################################################################################################################# + Function Test-Service { + + $Script:Output.Text = "test-service function" + #$T = Get-Service + #$Script:Output.Text = $T | ft -AutoSize | Out-String + } +################################################################################################################## + +################################################################################################################## + # --End User Generated Script-- + #---------------------------------------------- + #region Generated Events + #---------------------------------------------- + + $Form_StateCorrection_Load= + { + #Correct the initial state of the form to prevent the .Net maximized form issue + $form1.WindowState = $InitialFormWindowState + } + + $Form_Cleanup_FormClosed= + { + #Remove all event handlers from the controls + try + { + $form1.remove_Load($form1_Load) + $form1.remove_Load($Form_StateCorrection_Load) + $form1.remove_FormClosed($Form_Cleanup_FormClosed) + + #$PanelEventLogs_Events.remove_Paint($PanelEventLogs_Events_Paint) + #$PanelEventLogs_Filter.remove_Paint($PanelEventLogs_Filter_Paint) + + $Text_Elogs_DaysBack.remove_TextChanged($Text_Elogs_DaysBack_TextChanged) + $Text_ELogs_ServerName.remove_TextChanged($Text_ELogs_ServerName_TextChanged) + $Text_ELogs_EventID.remove_TextChanged($Text_ELogs_EventID_TextChanged) + + $Script:Output.remove_TextChanged($Output_TextChanged) + $Script:Output_Left.remove_TextChanged($Script:Output_Left_TextChanged) + $Script:Output_Right.remove_TextChanged($Script:Output_Right_TextChanged) + + $Script:Collection_DropDownBox.remove_SelectedIndexChanged($Script:Collection_DropDownBox_SelectedIndexChanged) + $Script:Deployment_DropDownBox.remove_SelectedIndexChanged($Script:Deployment_DropDownBox_SelectedIndexChanged) + $Script:Combobox_Tools.remove_SelectedIndexChanged($Script:Combobox_Tools_SelectedIndexChanged) + $Script:RadioButton_Window.remove_SelectedIndexChanged($Script:RadioButton_Window_SelectedIndexChanged) + $Script:RadioButton_GridView.remove_SelectedIndexChanged($Script:RadioButton_GridView_SelectedIndexChanged) + $Script:RadioButton_CSV.remove_SelectedIndexChanged($Script:RadioButton_CSV_SelectedIndexChanged) + $Button_Go.remove_Click($Button_Go_Click) + + } + catch { Out-Null <# Prevent PSScriptAnalyzer warning #> } + } + + + #$PanelEventLogs_Events_Paint=[System.Windows.Forms.PaintEventHandler]{ <#Event Argument: $_ = [System.Windows.Forms.PaintEventArgs]#> } + #$PanelEventLogs_Filter_Paint=[System.Windows.Forms.PaintEventHandler]{ } + + $Text_ELogs_ServerName_TextChanged={} + $Text_Elogs_DaysBack_TextChanged={} + + #endregion Generated Events + + #---------------------------------------------- + #region Generated Form Code + #---------------------------------------------- + # + # form1 + # + #$form1.Controls.Add($PanelEventLogs_Events) + #$form1.Controls.Add($PanelEventLogs_Filter) + + $form1.Controls.Add($Script:Output) + $form1.Controls.Add($Script:Output_Left) + $form1.Controls.Add($Script:Output_Right) + $form1.Controls.Add($Script:Collection_DropDownBox) + $form1.Controls.Add($Script:Deployment_DropDownBox) + $form1.Controls.Add($Script:Combobox_Tools) + $form1.Controls.Add($GroupBox) + $form1.Controls.Add($GroupBox_Info) + $form1.controls.Add($Script:RadioButton_Window) + $form1.controls.Add($Script:RadioButton_GridView) + $form1.Controls.Add($Script:RadioButton_CSV) + $form1.Controls.Add($Button_Go) + $form1.Controls.Add($Script:TextBox_CollectionName) + $form1.Controls.Add($label_CollectionName) + $form1.Controls.Add($label_CollectionName_Value) + $form1.Controls.Add($label_DeploymentName) + $form1.controls.Add($label_DeploymentName_Value) + $form1.Controls.Add($label_DeploymentTime) + $form1.Controls.Add($label_DeploymentTime_Value) + $form1.Controls.Add($label_DeviceCount) + $form1.Controls.Add($label_DeviceCount_Value) + $form1.Controls.Add($label_ServersResponding) + $form1.Controls.Add($label_ServersResponding_Value) + $form1.Controls.Add($label_ServersNOTResponding) + $form1.Controls.Add($label_ServersNOTResponding_Value) + $form1.Controls.Add($label_ServersPinging) + $form1.Controls.Add($label_ServersPinging_Value) + + + + $form1.AutoScaleDimensions = '6, 13' + $form1.AutoScaleMode = 'Font' + $form1.ClientSize = '1000, 800' + $form1.Name = 'form1' + $form1.Text = 'Form' + $form1.add_Load($form1_Load) + #endregion Generated Form Code + + #---------------------------------------------- +<# + $PanelEventLogs_Events.Controls.Add($Text_ELogs_ServerName) + $PanelEventLogs_Events.Controls.Add($Button_ELogs_Connect) + $PanelEventLogs_Events.Controls.Add($Button_ELogs_View) + $PanelEventLogs_Events.Controls.Add($Combobox_EventLogs_LogsList) + $PanelEventLogs_Events.Controls.Add($VCenterUserPassword) + $PanelEventLogs_Events.Controls.Add($CheckBoxUseWindowsLogin) + $PanelEventLogs_Events.Controls.Add($labelVCenterUserName) + $PanelEventLogs_Events.Controls.Add($labelVCenterPassword) + $PanelEventLogs_Events.Controls.Add($Script:Collection_DropDownBox) + $PanelEventLogs_Events.BackColor = '153,153,153' + $PanelEventLogs_Events.Location = '6, 6' + $PanelEventLogs_Events.Name = 'panelEventLogs_Events' + $PanelEventLogs_Events.Size = '598, 56' + $PanelEventLogs_Events.TabIndex = 0 + $PanelEventLogs_Events.add_Paint($PanelEventLogs_Events_Paint) + + $PanelEventLogs_Filter.Controls.Add($Combobox_ELogsFilter_Level) + $PanelEventLogs_Filter.Controls.Add($Text_ELogs_EventID) + $PanelEventLogs_Filter.Controls.Add($Text_Elogs_DaysBack) + $PanelEventLogs_Filter.Controls.Add($label_ELogs_Level) + $PanelEventLogs_Filter.Controls.Add($label_ELogs_EventID) + $PanelEventLogs_Filter.Controls.Add($label_ELogs_DaysBack) + $PanelEventLogs_Filter.BackColor = '255,255,212' + $PanelEventLogs_Filter.Location = '6, 62' + $PanelEventLogs_Filter.Name = 'PanelEventLogs_Filter' + $PanelEventLogs_Filter.Size = '598, 56' + $PanelEventLogs_Filter.BorderStyle = 'FixedSingle' + $PanelEventLogs_Filter.TabIndex = 0 + $PanelEventLogs_Filter.add_Paint($PanelEventLogs_Filter_Paint) +#> + # + # $Text_ELogs_ServerName + <# + $Text_ELogs_ServerName.Location = '8, 26' + $Text_ELogs_ServerName.Name = '$Text_ELogs_ServerName' + $Text_ELogs_ServerName.Size = '100, 20' + $Text_ELogs_ServerName.text = "l2012" + $Text_ELogs_ServerName.TabIndex = 6 + $Text_ELogs_ServerName.add_TextChanged($Text_ELogs_ServerName_TextChanged) + # + # + # Text_ELogs_EventID + # + $Text_ELogs_EventID.Location = '115, 26' + $Text_ELogs_EventID.Name = 'Text_ELogs_EventID' + $Text_ELogs_EventID.Size = '40, 20' + $Text_ELogs_EventID.TabIndex = 7 + $Text_ELogs_EventID.add_TextChanged($Text_ELogs_EventID_TextChanged) + # + # Text_Elogs_DaysBack + # + $Text_Elogs_DaysBack.Location = '175, 26' + $Text_Elogs_DaysBack.Name = 'Text_Elogs_DaysBack' + $Text_Elogs_DaysBack.Size = '40, 20' + $Text_Elogs_DaysBack.TabIndex = 7 + $Text_Elogs_DaysBack.add_TextChanged($Text_Elogs_DaysBack_TextChanged) + #> + # Output + # + $Script:Output.Location = '10, 250' + $Script:Output.Multiline = $True + $Script:Output.Name = 'Output' + $Script:Output.ScrollBars = 'both' + $Script:Output.Size = '965, 500' + $Script:Output.Font = 'Consolas, 8.25pt' + $Script:Output.WordWrap = $False + $Script:Output.TabIndex = 5 + $Script:Output.add_TextChanged($Output_TextChanged) + $Script:Output.Visible = $True + # + $Script:Output_Left.Location = '20, 250' + $Script:Output_Left.Multiline = $True + $Script:Output_Left.Name = 'Output_Left' + $Script:Output_Left.ScrollBars = 'both' + $Script:Output_Left.Size = '470, 500' + $Script:Output_Left.Font = 'Consolas, 8.25pt' + $Script:Output_Left.WordWrap = $False + #$Script:Output_Left.TabIndex = 5 + + $Script:Output_Left.add_TextChanged($Output_Left_TextChanged) + # + $Script:Output_Right.Location = '510, 250' + $Script:Output_Right.Multiline = $True + $Script:Output_Right.Name = 'Output_Right' + $Script:Output_Right.ScrollBars = 'both' + $Script:Output_Right.Size = '470, 500' + $Script:Output_Right.Font = 'Consolas, 8.25pt' + $Script:Output_Right.WordWrap = $False + #$Script:Output_Right.TabIndex = 5 + $Script:Output_Right.add_TextChanged($Output_Right_TextChanged) + # + # ComboboxServiceStartMode + # + $Script:Collection_DropDownBox.FormattingEnabled = $True + $Script:Collection_DropDownBox.Location = '20, 80' + $Script:Collection_DropDownBox.Name = 'Script:Collection_DropDownBox' + $Script:Collection_DropDownBox.Size = '180, 20' + $Script:Collection_DropDownBox.TabIndex = 2 + $Script:Collection_DropDownBox.Text = '--Deployed to Collections--' + $Script:Collection_DropDownBox.add_SelectedIndexChanged($Script:Collection_DropDownBox_SelectedIndexChanged) + # + $Script:Deployment_DropDownBox.Location = '20,30' + #$Script:Deployment_DropDownBox.Size = New-Object System.Drawing.Size(580,50) + $Script:Deployment_DropDownBox.Size = '500,50' + #$Script:Deployment_DropDownBox.DropDownHeight = 200 + $Script:Deployment_DropDownBox.text = "----Select Deployment----" + #$Script:Deployment_DropDownBox.Visible = $false + $Script:Deployment_DropDownBox.add_SelectedIndexChanged($Script:Deployment_DropDownBox_SelectedIndexChanged) + # + #$Script:Combobox_Tools.Size = New-Object System.Drawing.Size(180,20) + #$Script:Combobox_Tools.DropDownHeight = 200 + $Script:Combobox_Tools.text = "----Select Tool----!" + $Script:Combobox_Tools.Location = '20,170' + $Script:Combobox_Tools.Size = '180,10' + $Script:Combobox_Tools.add_SelectedIndexChanged($Script:Combobox_Tools_SelectedIndexChanged) + # + $groupBox.Location = '270,70' + $groupBox.size = ('150,90') #New-Object System.Drawing.Size(150,90) + $groupBox.text = "Select Output:" + $GroupBox.Controls.Add($Script:RadioButton_Window) + $GroupBox.Controls.Add($Script:RadioButton_GridView) + $GroupBox.Controls.Add($Script:RadioButton_CSV) + # + $GroupBox_Info.Location = '570,25' + $GroupBox_Info.Size = '410,160' + $GroupBox_Info.Text = "Deployment Info" + $GroupBox_Info.Controls.Add($label_CollectionName) + $GroupBox_Info.Controls.Add($label_CollectionName_Value) + $GroupBox_Info.Controls.Add($label_DeploymentName) + $GroupBox_Info.Controls.Add($label_DeploymentName_Value) + $GroupBox_Info.Controls.Add($label_DeploymentTime) + $GroupBox_Info.Controls.Add($label_DeploymentTime_Value) + $GroupBox_Info.Controls.Add($label_DeviceCount) + $GroupBox_Info.Controls.Add($label_DeviceCount_Value) + ############ + $label_CollectionName.AutoSize = $True + $label_CollectionName.Font = 'Microsoft Sans Serif, 9.0pt' #, style=Bold' + #$label_CollectionName.ForeColor = 'DarkGreen' + #$label_CollectionName.TextAlign = 'MiddleRight' + $label_CollectionName.Location = '20,25' + $label_CollectionName.Name = 'Collection_Name' + $label_CollectionName.Size = '41, 13' + #$label_CollectionName.TabIndex = 6 + $label_CollectionName.Text = 'Collection Name:' + #$label_CollectionName.add_Click($label_CollectionName_Click) + + ############ Value ############### + $label_CollectionName_Value.AutoSize = $True + $label_CollectionName_Value.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_CollectionName_Value.ForeColor = 'DarkGreen' + #$label_CollectionName_Value.TextAlign = 'MiddleRight' + $label_CollectionName_Value.Location = '140,25' + $label_CollectionName_Value.Name = 'Collection_Name_Value' + $label_CollectionName_Value.Size = '41, 13' + #$label_CollectionName_Value.TabIndex = 6 + $label_CollectionName_Value.Text = '_' + #$label_CollectionName_Value.add_Click($label_CollectionName_Value_Click) + + ############ + $label_DeploymentName.AutoSize = $True + $label_DeploymentName.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_DeploymentName.ForeColor = 'DarkGreen' + #$label_DeploymentName.TextAlign = 'MiddleRight' + $label_DeploymentName.Location = '20,45' + $label_DeploymentName.Name = 'Deployment_Name' + $label_DeploymentName.Size = '41, 13' + #$label_DeploymentName.TabIndex = 6 + $label_DeploymentName.Text = 'Deployment Name:' + #$label_DeploymentName.add_Click($label_DeploymentName_Click) + + ############ Value ############ + $label_DeploymentName_Value.AutoSize = $True + $label_DeploymentName_Value.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_DeploymentName_Value.ForeColor = 'DarkGreen' + #$label_DeploymentName_Value.TextAlign = 'MiddleRight' + $label_DeploymentName_Value.Location = '140,45' + $label_DeploymentName_Value.Name = 'Deployment_Name_Value' + $label_DeploymentName_Value.Size = '41, 13' + #$label_DeploymentName_Value.TabIndex = 6 + $label_DeploymentName_Value.Text = '_' + #$label_DeploymentName_Value.add_Click($label_DeploymentName_Value_Click) + + ############# + $label_DeploymentTime.AutoSize = $True + $label_DeploymentTime.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_DeploymentTime.ForeColor = 'DarkGreen' + #$label_DeploymentTime.TextAlign = 'MiddleRight' + $label_DeploymentTime.Location = '20,65' + $label_DeploymentTime.Name = 'Deployment_Time' + $label_DeploymentTime.Size = '41, 13' + #$label_DeploymentTime.TabIndex = 6 + $label_DeploymentTime.Text = 'Deployment Time:' + #$label_DeploymentTime.add_Click($label_CollectionName_Click) + + ############ Value ############ + $label_DeploymentTime_Value.AutoSize = $True + $label_DeploymentTime_Value.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_DeploymentTime_Value.ForeColor = 'DarkGreen' + #$label_DeploymentTime_Value.TextAlign = 'MiddleRight' + $label_DeploymentTime_Value.Location = '140,65' + $label_DeploymentTime_Value.Name = 'Deployment_Time_Value' + $label_DeploymentTime_Value.Size = '41, 13' + #$label_DeploymentTime_Value.TabIndex = 6 + $label_DeploymentTime_Value.Text = '_' + #$label_DeploymentTime_Value.add_Click($label_DeploymentTime_Value_Click) + + ########### + $label_DeviceCount.AutoSize = $True + $label_DeviceCount.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_DeviceCount.ForeColor = 'DarkGreen' + #$label_DeviceCount.TextAlign = 'MiddleRight' + $label_DeviceCount.Location = '20,85' + $label_DeviceCount.Name = 'Device_Count' + $label_DeviceCount.Size = '41, 13' + #$label_DeviceCount.TabIndex = 6 + $label_DeviceCount.Text = 'Device Count' + #$label_DeviceCount.add_Click($label_DeviceCount_Click) + + ############ Value ############ + $label_DeviceCount_Value.AutoSize = $True + $label_DeviceCount_Value.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_DeviceCount_Value.ForeColor = 'DarkGreen' + #$label_DeviceCount_Value.TextAlign = 'MiddleRight' + $label_DeviceCount_Value.Location = '140,85' + $label_DeviceCount_Value.Name = 'Device_Count_Value' + $label_DeviceCount_Value.Size = '41, 13' + #$label_DeviceCount_Value.TabIndex = 6 + $label_DeviceCount_Value.Text = '_' + #$label_DeviceCount_Value.add_Click($label_DeviceCount_Value_Click) +############ + $label_ServersResponding.AutoSize = $True + $label_ServersResponding.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_ServersResponding.ForeColor = 'DarkGreen' + #$label_ServersResponding.TextAlign = 'MiddleRight' + $label_ServersResponding.Location = '15,225' + $label_ServersResponding.Name = 'Servers Responding' + $label_ServersResponding.Size = '41, 13' + #$label_ServersResponding.TabIndex = 6 + $label_ServersResponding.Text = 'Servers Responding: ' + $label_ServersResponding.Visible = $False + #$label_ServersResponding.add_Click($label_ServersResponding_Click) +############ + $label_ServersResponding_Value.AutoSize = $True + $label_ServersResponding_Value.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_ServersResponding_Value.ForeColor = 'DarkGreen' + #$label_ServersResponding.TextAlign = 'MiddleRight' + $label_ServersResponding_Value.Location = '155,225' + $label_ServersResponding_Value.Name = 'Servers Responding Vlue' + $label_ServersResponding_Value.Size = '41, 13' + #$label_ServersResponding_Value.TabIndex = 6 + $label_ServersResponding_Value.Text = '-' + $label_ServersResponding_Value.Visible = $False + #$label_ServersResponding_Value.add_Click($label_ServersResponding_Value_Click) +############ +$label_ServersNOTResponding.AutoSize = $True + $label_ServersNOTResponding.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_ServersNOTResponding.ForeColor = 'Red' + #$label_ServersNOTResponding.TextAlign = 'MiddleRight' + $label_ServersNOTResponding.Location = '510,225' + $label_ServersNOTResponding.Name = 'Servers Not Responding' + $label_ServersNOTResponding.Size = '41, 13' + #$label_ServersNOTResponding.TabIndex = 6 + $label_ServersNOTResponding.Text = 'Servers NOT Responding: ' + $label_ServersNOTResponding.Visible = $False + #$label_ServersNOTResponding.add_Click($label_ServersNOTResponding_Click) +############ +$label_ServersNOTResponding_Value.AutoSize = $True + $label_ServersNOTResponding_Value.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_ServersNOTResponding_Value.ForeColor = 'Red' + #$label_ServersNOTResponding_Value.TextAlign = 'MiddleRight' + $label_ServersNOTResponding_Value.Location = '670,225' + $label_ServersNOTResponding_Value.Name = 'Servers Not Responding Value' + $label_ServersNOTResponding_Value.Size = '41, 13' + #$label_ServersNOTResponding_Value.TabIndex = 6 + $label_ServersNOTResponding_Value.Text = '- ' + $label_ServersNOTResponding_Value.Visible = $False + #$label_ServersNOTResponding_Value.add_Click($label_ServersNOTResponding_Value_Click) +############ +$label_ServersPinging.AutoSize = $True + $label_ServersPinging.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_ServersPinging.ForeColor = 'Green' + #$label_ServersPinging.TextAlign = 'MiddleRight' + $label_ServersPinging.Location = '15,210' + $label_ServersPinging.Name = 'Servers Pinging' + $label_ServersPinging.Size = '41, 13' + #$label_ServersPinging.TabIndex = 6 + $label_ServersPinging.Text = 'Checking Servers: ' + $label_ServersPinging.Visible = $False + #$label_ServersPinging.add_Click($label_ServersPinging_Click) +############ +$label_ServersPinging_Value.AutoSize = $True + $label_ServersPinging_Value.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_ServersPinging_Value.ForeColor = 'Green' + #$label_ServersPinging_Value.TextAlign = 'MiddleRight' + $label_ServersPinging_Value.Location = '165,210' + $label_ServersPinging_Value.Name = 'Servers Pinging Value' + $label_ServersPinging_Value.Size = '41, 13' + $label_ServersPinging_Value.Text = '- ' + $label_ServersPinging_Value.Visible = $False + #$label_ServersPinging_Value.add_Click($label_ServersPinging_Value_Click) +############ + $Script:RadioButton_Window.Location = new-object System.Drawing.Point(15,15) + $Script:RadioButton_Window.size = New-Object System.Drawing.Size(130,20) + $Script:RadioButton_Window.Checked = $true + $Script:RadioButton_Window.Text = "Window" + #$Script:RadioButton_Window. + # + $Script:RadioButton_GridView.Location = new-object System.Drawing.Point(15,35) + $Script:RadioButton_GridView.size = New-Object System.Drawing.Size(80,20) + $Script:RadioButton_GridView.Checked = $False + $Script:RadioButton_GridView.Text = "GridView" + # + $Script:RadioButton_CSV.Location = new-object System.Drawing.Point(15,55) + $Script:RadioButton_CSV.size = New-Object System.Drawing.Size(80,20) + $Script:RadioButton_CSV.Checked = $False + $Script:RadioButton_CSV.Text = "CSV" + # + $Button_Go.Location = New-Object System.Drawing.Size(450,75) + $Button_Go.Size = New-Object System.Drawing.Size(110,80) + $Button_Go.Text = "Go" + #$Button_Go.Add_Click({temp}) + $Button_Go.Add_Click($Button_Go_Click) + # + $Script:TextBox_CollectionName.Left = 20; + $Script:TextBox_CollectionName.Top = 130; + $Script:TextBox_CollectionName.width = 200; + $Script:TextBox_CollectionName.Text = "Nabil - Test Collection" + # + ############################################################################ + Update-Dropdown1 + ConnectTo-SCCM + Deployment-List -Deployment_History 10 + $Script:Output.Text = "helloooooooo" + #cd c: + + + ############################################################################ + +#Save the initial state of the form + $InitialFormWindowState = $form1.WindowState + #Init the OnLoad event to correct the initial state of the form + $form1.add_Load($Form_StateCorrection_Load) + #Clean up the control events + $form1.add_FormClosed($Form_Cleanup_FormClosed) + #Show the Form + return $form1.ShowDialog() + +} #End Function + +#Call the form +Show-Form-Template_psf | Out-Null diff --git a/dump/SCCM-Tool/NA-Tool-GUI-12x.ps1 b/dump/SCCM-Tool/NA-Tool-GUI-12x.ps1 new file mode 100644 index 0000000..67b53de --- /dev/null +++ b/dump/SCCM-Tool/NA-Tool-GUI-12x.ps1 @@ -0,0 +1,960 @@ +#------------------------------------------------------------------------ +# Source File Information (DO NOT MODIFY) +# Source ID: 676f8db7-35c7-452d-b353-a4b40f26243a +# Source File: Form-Template.psf +#------------------------------------------------------------------------ +#region File Recovery Data (DO NOT MODIFY) +<#RecoveryData: +RAUAAB+LCAAAAAAABAC9VNtKwzAYvhd8h5Dr2oPd3AZtYXTuxtNwQ72TrP07o2lSknSzPr3p2g1x +QkHGKJSk+Q7/KQ0eIRFrkNWEaILMQlHBQ3xpezg6P0MoeJB0RTlhU8rgnuQQTYXMLxaQF4xosAuV +Bc4BpmEu3yHRSFcFhHheKQ25/Ux5KjbKrkWat4X+OrLQUxtKz3brx0JxyXQpIeRQakmYhWblktHk +BqqF+AAeLgcD0k/6V97I74E7HGHETSghzoyeh1HyRlkqDQ7HgmspmGoSNIHOpChA6qoljEst5glh +MKE58DoIA72ykOcHzg7aRb0TKWBTKq47OTGjwPWcfhnCwDU+/nDYSaqrjKNtap3YBXxqvG3bIfR6 +bbxb3K0gaav5Wq8DZ3vaNNNputlsxkpBbooPaqfTfqmiXCVCMro8QgMDZ6/626UZmVN4HH0sux3r +m3gaI0k2lK/+4+X6WT8bZJ6X9l3ik26vl5ydJKdYSDi+0X7bjHzg/PxrRt9OzyrdRAUAAA==#> +#endregion + +<# + .NOTES + -------------------------------------------------------------------------------- + Code generated by: SAPIEN Technologies, Inc., PowerShell Studio 2017 v5.4.141 + Generated on: 8/29/2017 11:53 AM + Generated by: Haidey2 + -------------------------------------------------------------------------------- + .DESCRIPTION + GUI script generated by PowerShell Studio 2017 +#> + + +#---------------------------------------------- +#region Application Functions +#---------------------------------------------- + +#endregion Application Functions + +#---------------------------------------------- +# Generated Form Function +#---------------------------------------------- +function Show-Form-Template_psf { + + #---------------------------------------------- + #region Import the Assemblies + #---------------------------------------------- + [void][reflection.assembly]::Load('System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') + [void][reflection.assembly]::Load('System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') + [void][reflection.assembly]::Load('System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') + #endregion Import Assemblies + + #---------------------------------------------- + #region Generated Form Objects + #---------------------------------------------- + [System.Windows.Forms.Application]::EnableVisualStyles() + $form1 = New-Object 'System.Windows.Forms.Form' + $InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState' + + + $Script:Output = New-Object System.Windows.Forms.TextBox + + $Script:Output_Left = New-Object System.Windows.Forms.TextBox + $Script:Output_Right = New-Object System.Windows.Forms.TextBox + + $Script:Collection_DropDownBox = New-Object System.Windows.Forms.ComboBox + $Script:Deployment_DropDownBox = New-Object System.Windows.Forms.ComboBox + $Script:Combobox_Tools = New-Object System.Windows.Forms.ComboBox + + $GroupBox = New-Object System.Windows.Forms.GroupBox + $GroupBox_Info = New-Object System.Windows.Forms.GroupBox + + $Script:RadioButton_Window = New-Object System.Windows.Forms.RadioButton + $Script:RadioButton_GridView = New-Object System.Windows.Forms.RadioButton + $Script:RadioButton_CSV = New-Object System.Windows.Forms.RadioButton + $Button_Go = New-Object System.Windows.Forms.Button + $Script:TextBox_CollectionName = New-Object “System.Windows.Forms.TextBox” + + #$PanelEventLogs_Events = New-Object 'System.Windows.Forms.Panel' + #$PanelEventLogs_Filter = New-Object 'System.Windows.Forms.Panel' + + + #$Text_ELogs_ServerName = New-Object 'System.Windows.Forms.TextBox' + #$Text_ELogs_EventID = New-Object 'System.Windows.Forms.TextBox' + #$Text_Elogs_DaysBack = New-Object 'System.Windows.Forms.TextBox' + + $label_CollectionName = New-Object 'System.Windows.Forms.Label' + $label_CollectionName_Value = New-Object 'System.Windows.Forms.Label' + $label_DeploymentName = New-Object 'System.Windows.Forms.Label' + $label_DeploymentName_Value = New-Object 'System.Windows.Forms.Label' + $label_DeploymentTime = New-Object 'System.Windows.Forms.Label' + $label_DeploymentTime_Value = New-Object 'System.Windows.Forms.Label' + $label_DeviceCount = New-Object 'System.Windows.Forms.Label' + $label_DeviceCount_Value = New-Object 'System.Windows.Forms.Label' + + $label_ServersResponding = New-Object 'System.Windows.Forms.Label' + $label_ServersResponding_Value = New-Object 'System.Windows.Forms.Label' + $label_ServersNOTResponding = New-Object 'System.Windows.Forms.Label' + $label_ServersNOTResponding_Value = New-Object 'System.Windows.Forms.Label' + $label_ServersPinging = New-Object 'System.Windows.Forms.Label' + $label_ServersPinging_Value = New-Object 'System.Windows.Forms.Label' + + + #$Button_ELogs_Connect = New-Object 'System.Windows.Forms.Button' + +# $Location = Split-Path $MyInvocation.MyCommand.Path -Parent + + $Script:ALL_Patch_Servers = @() + $Script:Responding = @() + $Script:NotResponding = @() + $Global:DeviceCollection_ServerNames1 = "" + + $Global:Collection_Name = "" + $Global:Select_Tool + $Global:Output_Type = "" + $Global:Deployments = "" + + #endregion Generated Form Objects + + #---------------------------------------------- + # User Generated Script + #---------------------------------------------- + + $form1_Load={ + #TODO: Initialize Form Controls here + + } + + $Script:Collection_DropDownBox_SelectedIndexChanged={ + + $Script:Output.Text = $Script:Collection_DropDownBox.Text + $T = Get-CMDeviceCollection -Name $Script:Collection_DropDownBox.text | select Name,MemberCount + + $Info = $Global:Deployments | ? { $_.applicationname -eq "$($Script:Deployment_DropDownBox.text)" -and $_.collectionname -eq "$($Script:Collection_DropDownBox.text)" } | select applicationname,collectionname,deploymenttime + + $label_DeploymentName_Value.Text = $Info.ApplicationName + $label_DeploymentTime_Value.Text = $Info.DeploymentTime + $label_CollectionName_Value.Text = $Script:Collection_DropDownBox.Text #$T.CollectionName + + $label_DeviceCount_Value.Text = $T.MemberCount + + } + + $Script:Deployment_DropDownBox_SelectedIndexChanged={ + Reset-Forms -Form_Selection 1 + Deployed-to-Collections + $Script:Output.Text = $Script:Deployment_DropDownBox.Text + } + + $Script:Combobox_Tools_SelectedIndexChanged= { + $Script:Output.Text = $Script:Combobox_Tools.Text + + + } + + $Button_Go_Click = { + temp + #SCCM-Module + # $Global:Collection_Name = $Script:TextBox_CollectionName.Text #$Script:TextBox_CollectionName.Text + # $Global:Select_Tool = $Script:Combobox_Tools.Text + + + #$Output.Text = "$Global:Collection_Name --- $Global:Select_Tool " | Out-String + #$Output.Text = | Out-String + } + + +################################################################################################################## + Function ConnectTo-SCCM { + + If(!(Get-PSDrive).Name -ne "CCX") { + # + # Press 'F5' to run this script. Running this script will load the ConfigurationManager + # module for Windows PowerShell and will connect to the site. + # + # This script was auto-generated at '2/18/2021 10:12:39 AM'. + + # Uncomment the line below if running in an environment where script signing is + # required. + #Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process + + # Site configuration + $SiteCode = "CCX" # Site code + $ProviderMachineName = "PNCRASCCM001.ccx.carecentrix.com" # SMS Provider machine name + + # Customizations + $initParams = @{} + #$initParams.Add("Verbose", $true) # Uncomment this line to enable verbose logging + #$initParams.Add("ErrorAction", "Stop") # Uncomment this line to stop the script on any errors + + # Do not change anything below this line + + # Import the ConfigurationManager.psd1 module + if((Get-Module ConfigurationManager) -eq $null) { + Import-Module "$($ENV:SMS_ADMIN_UI_PATH)\..\ConfigurationManager.psd1" @initParams + } + + # Connect to the site's drive if it is not already present + if((Get-PSDrive -Name $SiteCode -PSProvider CMSite -ErrorAction SilentlyContinue) -eq $null) { + New-PSDrive -Name $SiteCode -PSProvider CMSite -Root $ProviderMachineName @initParams + } + + # Set the current location to be the site code. + Set-Location "$($SiteCode):\" @initParams + + #$Script:Output.Text = "inside connectoSCCM function" + }#endIf + }#endFunction +################################################################################################################## + Function SCCM-Module { + Write-Host "Inside SCCM function" -ForegroundColor Cyan + If(!(Get-PSDrive).Name -eq "sccm-drive") { + + Import-Module 'C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1' + New-PSDrive -Name SCCM-Drive -PSProvider "AdminUI.PS.Provider\CMSite" -Root "PNCRASCCM001.ccx.carecentrix.com" -Description "SCCM Site" + }#endIf + $Script:Output.Text | Get-PSDrive | ft -AutoSize | Out-String + CD sccm-drive: + }#endFunction +################################################################################################################## + Function Update-Dropdown1 { + # $Collections += $Script:Collection_DropDownBox.text + $Collections = @("Collection-Servers","Ping-Collection","Check_Uptime","Test-Service","Remotely Update Policy","Software Update Status","Test-Sccm") + $Collections | % { $Script:Combobox_Tools.Items.Add($_) } + } +################################################################################################################## + Function Reset-Forms { + Param($Form_Selection) + + Switch ($Form_Selection) { + 1 { $Collection_DropDownBox.Items.Clear(); $Collection_DropDownBox.Text = "--Deployed to Collections--" } + 2 {} + + } + + } +################################################################################################################## + Function temp { + $Script:Output.Clear() + $Script:Output_Left.Clear() + $Script:Output_Right.Clear() + #$Script:Script:Output.text = $Script:Collection_DropDownBox.text | Out-String + + #$Global:Collection_Name = $Script:TextBox_CollectionName.Text #$Script:TextBox_CollectionName.Text + $Global:Collection_Name = $Script:Collection_DropDownBox.Text + $Global:Select_Tool = $Script:Combobox_Tools.Text + + #$Script:Collection_DropDownBox.BackColor + If ($Script:RadioButton_Window.Checked -eq $true) { $Global:Output_Type = "Window" <#; $Script:Output.Text = "Window_Radio1 Checked: $($Script:RadioButton_Window.Checked)" | Out-String #> } + ElseIf ($Script:RadioButton_GridView.Checked -eq $true) { $Global:Output_Type = "Gridview" <#; $Script:Output.Text = "Gridview_Radio2 Checked: $($Script:RadioButton_GridView.Checked)" | Out-String #> } + ElseIf ($Script:RadioButton_CSV.Checked -eq $true) { $Global:Output_Type = "Export" <#; $Script:Output.Text = "CSV_Radio3 Checked: $($Script:RadioButton_CSV.Checked)" | Out-String #> } + + + If($Global:Collection_Name -and $Global:Select_Tool) { + + $Script:Output.Text = "CollectionName: $Global:Collection_Name ----- SelectTool: $Global:Select_Tool" + # If($Script:Collection_DropDownBox.text = "Tool1"){gcc} + Run-Tool + #$Script:TextBox_CollectionName.clear() + $Script:Collection_DropDownBox.text = "----Select Collection----" + #Clear-Variables + }#endIf + Else { #$T = { Write-Host "You must enter Collection Name ............!!" -ForegroundColor Red } + $Script:Output.SelectionColor = 'red' + $Script:Output.Text = "You must select 'Tool' and enter Collection Name............!!" + } + + Run-Defaults + }#endFunction +################################################################################################################## + Function Run-Tool { + + Switch($Global:Select_Tool) { + Collection-Servers { Collection-Servers; Write-Host "Tool Selected: $Global:Select_Tool" } + Ping-Collection { Ping_Collection } + Check_Uptime { Check_Uptime } + Test-Service { Test-Service } + Test-SCCM { SCCM-Module } + #"Remotely Update Policy" { $Script:Output.Text = Invoke-Expression $Location\Tool-Remotely-Restart-SCCMSyncCycle.ps1 | ft -AutoSize | Out-String } + "Remotely Update Policy" { $Script:Output.Text = Invoke-Expression $Location\Tool-Remotely-Restart-SCCMSyncCycle.ps1 | ft -AutoSize | Out-String } + "Software Update Status" { $Script:Output.Text = & "$Location\Tool-Get-SCCMSoftwareUpdateStatus.ps1" -Dep_ID 16778048 | ft -AutoSize | Out-String} + }#endSwitch + #Clear-Variables + }#endFunction +################################################################################################################## + Function Run-Defaults { + #$Script:TextBox_CollectionName.Text = "Nabil - Test Collection" + $Script:RadioButton_Window.Checked = $true + + <# + If(!$Location) { + $Location = Split-Path $MyInvocation.MyCommand.Path -Parent + } + #> + } +################################################################################################################## + Function xClear-Variables { + $Global:Collection_Name = "" + $Global:Select_Tool = "" + $Global:Output_Type = "" + + $Script:ALL_Patch_Servers = @() + } +################################################################################################################## + Function Display-Results { + #Param($Global:Output_Type,$Final_Result) + Write-Host "DisplayType: $($Global:Output_Type)" + Switch ($Global:Output_Type){ + + Window { $Script:Output.Text = $Script:ALL_Patch_Servers | Out-String} + Gridview { $Script:ALL_Patch_Servers | Out-GridView } + Export { $Script:ALL_Patch_Servers | Export-Csv -Path $Location\Results.csv -NoTypeInformation; ii $Location\Results.csv } + + }#endSwitch + + } +############################################################################################################################################################# + Function Collection-Servers { + #Param($Coll_Name) + + Write-Host "Collection:$Global:Collection_Name" + $Script:ALL_Patch_Servers = @() + + ConnectTo-SCCM + NA-Set-Stage -Select_Stage OutputStage2 + #SCCM-Module + #CD sccm-drive: + $Script:DeviceCollection_MemberCount = Get-CMDeviceCollection -Name $Global:Collection_Name | select Name,MemberCount + $Script:DeviceCollection_ServerNames = Collection-Members #Get-CMCollectionMember -CollectionName $Global:Collection_Name | select Name,IsClient #| Export-Csv "E:\SCCM-Files\SCCM-Scripts\Files\$Global:Collection_Name.csv" -NoTypeInformation + #$ServerName = $DeviceCollection_ServerNames.Name + #Set-Location c: + + #$Script:Temp = Get-CMCollectionMember -CollectionName $Global:Collection_Name #| select Name,IsClient + + $Script:DeviceCollection_ServerNames | % { + $Obj = New-Object -TypeName PSObject + $Obj | Add-Member -MemberType NoteProperty -Name Server -Value $_.Name + $Obj | Add-Member -MemberType NoteProperty -Name ClientInstalled -Value $_.IsClient + $Obj | Add-Member -MemberType NoteProperty -Name CollectionName -Value $Global:Collection_Name + #$Obj | Add-Member -MemberType NoteProperty -Name CollectionMemberCount -Value {(Get-CMCollectionMember -Name $Global:Collection_Name).MemberCount} + + $Obj + $Script:ALL_Patch_Servers += $Obj + + }#end% + + # $Script:Output.Text = $Script:ALL_Patch_Servers | Out-String + Display-Results #-Final_Result $Script:ALL_Patch_Servers + Write-Host "$Script:ALL_Patch_Servers" + # $Script:ALL_Patch_Servers | Export-Csv $Location\Current-Collection-Servers.csv -NoTypeInformation + + }#endFunction +############################################################################################################################################################# + Function Collection-Members { + Get-CMCollectionMember -CollectionName $Global:Collection_Name | select Name,IsClient + + } + +############################################################################################################################################################# + Function NA-Set-Stage { + Param($Select_Stage) + Switch($Select_Stage) { + OutputStage1 { $Script:Output.Visible = $false + $Script:Output_Left.Visible = $True + $Script:Output_Right.Visible = $True + $label_ServersResponding.Visible = $True + $label_ServersResponding_Value.Visible = $True + $label_ServersNOTResponding.Visible = $True + $label_ServersNOTResponding_Value.Visible = $True + $label_ServersPinging.Visible = $True + $label_ServersPinging_Value.Visible = $True + + + #Write-Host "output-stage1" -ForegroundColor Yellow + } + OutputStage2 { $Script:Output.Visible = $True + $label_ServersResponding.Visible = $false + $label_ServersResponding_Value.Visible = $false + $label_ServersNOTResponding.Visible = $False + $label_ServersNOTResponding_Value.Visible = $false + $Script:Output_Left.Visible = $false + $Script:Output_Right.Visible = $false + $label_ServersPinging.Visible = $false + $label_ServersPinging_Value.Visible = $false + } + test { $Script:Output.Text = "inside na set stage function"} + }#endSwitch + $Script:Output.Text = "outside switch inside na set stage function - param: $Select_Stage" + + + + }#endFunction +############################################################################################################################################################# + + Function Ping_Collection { + + $Ping_Result = @() + $NotResponding = @() + $Responding = @() + + ConnectTo-SCCM + NA-Set-Stage -Select_Stage OutputStage1 + + $Global:DeviceCollection_ServerNames1 = Collection-Members -CollectionName $Global:Collection_Name | select Name #Get-CMCollectionMember + #Set-Location c: + + Write-Host "Total Server Count: $($Global:DeviceCollection_ServerNames1.count)" -ForegroundColor Green + Write-Host "" + + If($Script:Collection_DropDownBox.Text -like "-*") { + $Script:Collection_DropDownBox.BackColor = 'red' + } + + Else { + $Script:Collection_DropDownBox.BackColor = 'white' + ############ + # $Script:Output.Text = "CollectionName: $($Global:Collection_Name) ------ hello " + ############ + $Global:DeviceCollection_ServerNames1.Name | % { + $Server = $_ + $label_ServersPinging_Value.Text = $Server + $Obj = New-Object -TypeName PSObject + $Count = $Global:DeviceCollection_ServerNames1.count + #$Script:Output.Text = "Checking: $Server ----- Servers left: $($Count--) Please Wait !!!" | Out-String + + If (Test-Connection $Server -Count 1 -ErrorAction SilentlyContinue ) { + + $Obj | Add-Member -MemberType NoteProperty -Name Server -Value $Server + $Obj | Add-Member -MemberType NoteProperty -Name Responding -Value "Yes" + $Ping_Result += $Obj + #$Responding += $Server + $Responding += $Obj + # $Script:Output.text += $Obj | Out-String + }#endIf + + Else { + $Obj | Add-Member -MemberType NoteProperty -Name Server -Value $Server + $Obj | Add-Member -MemberType NoteProperty -Name Responding -Value "No!" + $Ping_Result += $Obj + #$NotResponding += $Server + $NotResponding += $Obj + # $Script:Output.text += $Obj | Out-String + } + + $label_ServersResponding_Value.Text = $Responding.Count + $label_ServersNOTResponding_Value.Text = $NotResponding.Count + + }#end% + #$Script:Output.Text = $Ping_Result | ft -AutoSize | Out-String + $Script:Output_Left.Text = $Responding | Out-String + $Script:Output_Right.Text = $NotResponding | Out-String + + $label_ServersPinging_Value.Text = "Done !" + + + write-host "-------------------------------------------------------" + Write-host "$($Responding.count) / $($DeviceCollection_ServerNames1.count) -- Responding" -foregroundcolor Green + Write-host "$($NotResponding.count) / $($DeviceCollection_ServerNames1.count) -- NOT Responding" -foregroundcolor Red + + + }#endElse + }#endFunction +############################################################################################################################################################# + Function Check_Uptime { + ConnectTo-SCCM + NA-Set-Stage -Select_Stage OutputStage2 + $Global:DeviceCollection_ServerNames1 = Get-CMCollectionMember -CollectionName $Global:Collection_Name | select Name + $Script:Output.Text = $Global:DeviceCollection_ServerNames1.name | % { gwmi win32_operatingsystem -ComputerName $_ -ErrorAction SilentlyContinue | select @{n="Server";e={$_.PSComputername}},@{n="LastReboot";e={$_.Converttodatetime($_.LastBootUpTime)}}} | sort LastBootup -descending | Out-String + + } + +############################################################################################################################################################# + Function Deployment-List { + Param($Deployment_History) + # SCCM-Module + $Global:Deployments = Get-CMDeployment | ? { $_.deploymenttime -gt ((Get-Date).AddDays(-"$Deployment_History")) } + + #$T | select ApplicationName,CollectionName,DeploymentTime,AssignmentID,SoftwareName | % { $Deployment_DropDownBox.Items.Add($_) } + $i = 0 + $Q = "" #@() + + $Global:Deployments.ApplicationName | % { $Script:Deployment_DropDownBox.Items.Add($_)} + <# + foreach ($D in $Deployments) { + $Q = $D.ApplicationName + "-------------------------------------------------------" + $D.CollectionName + + $Deployment_DropDownBox.Items.Add($Q) + $i++ + } + #> + + #$T.ApplicationName | % { $Deployment_DropDownBox.Items.Add($_) } + + }#endFunction +############################################################################################################################################################# + Function Deployed-to-Collections { + $T = $Global:Deployments | ? { $_.ApplicationName -eq "$($Script:Deployment_DropDownBox.text)" } #| Select -ExpandProperty CollectionName + $Script:Collection_DropDownBox.Items.Clear() + $T.CollectionName | % { $Script:Collection_DropDownBox.Items.Add("$_")} + + + } + +############################################################################################################################################################# + Function Test-Service { + + $Script:Output.Text = "test-service function" + #$T = Get-Service + #$Script:Output.Text = $T | ft -AutoSize | Out-String + } +################################################################################################################## + +################################################################################################################## + # --End User Generated Script-- + #---------------------------------------------- + #region Generated Events + #---------------------------------------------- + + $Form_StateCorrection_Load= + { + #Correct the initial state of the form to prevent the .Net maximized form issue + $form1.WindowState = $InitialFormWindowState + } + + $Form_Cleanup_FormClosed= + { + #Remove all event handlers from the controls + try + { + $form1.remove_Load($form1_Load) + $form1.remove_Load($Form_StateCorrection_Load) + $form1.remove_FormClosed($Form_Cleanup_FormClosed) + + #$PanelEventLogs_Events.remove_Paint($PanelEventLogs_Events_Paint) + #$PanelEventLogs_Filter.remove_Paint($PanelEventLogs_Filter_Paint) + + $Text_Elogs_DaysBack.remove_TextChanged($Text_Elogs_DaysBack_TextChanged) + $Text_ELogs_ServerName.remove_TextChanged($Text_ELogs_ServerName_TextChanged) + $Text_ELogs_EventID.remove_TextChanged($Text_ELogs_EventID_TextChanged) + + $Script:Output.remove_TextChanged($Output_TextChanged) + $Script:Output_Left.remove_TextChanged($Script:Output_Left_TextChanged) + $Script:Output_Right.remove_TextChanged($Script:Output_Right_TextChanged) + + $Script:Collection_DropDownBox.remove_SelectedIndexChanged($Script:Collection_DropDownBox_SelectedIndexChanged) + $Script:Deployment_DropDownBox.remove_SelectedIndexChanged($Script:Deployment_DropDownBox_SelectedIndexChanged) + $Script:Combobox_Tools.remove_SelectedIndexChanged($Script:Combobox_Tools_SelectedIndexChanged) + $Script:RadioButton_Window.remove_SelectedIndexChanged($Script:RadioButton_Window_SelectedIndexChanged) + $Script:RadioButton_GridView.remove_SelectedIndexChanged($Script:RadioButton_GridView_SelectedIndexChanged) + $Script:RadioButton_CSV.remove_SelectedIndexChanged($Script:RadioButton_CSV_SelectedIndexChanged) + $Button_Go.remove_Click($Button_Go_Click) + + } + catch { Out-Null <# Prevent PSScriptAnalyzer warning #> } + } + + + #$PanelEventLogs_Events_Paint=[System.Windows.Forms.PaintEventHandler]{ <#Event Argument: $_ = [System.Windows.Forms.PaintEventArgs]#> } + #$PanelEventLogs_Filter_Paint=[System.Windows.Forms.PaintEventHandler]{ } + + $Text_ELogs_ServerName_TextChanged={} + $Text_Elogs_DaysBack_TextChanged={} + + #endregion Generated Events + + #---------------------------------------------- + #region Generated Form Code + #---------------------------------------------- + # + # form1 + # + #$form1.Controls.Add($PanelEventLogs_Events) + #$form1.Controls.Add($PanelEventLogs_Filter) + + $form1.Controls.Add($Script:Output) + $form1.Controls.Add($Script:Output_Left) + $form1.Controls.Add($Script:Output_Right) + $form1.Controls.Add($Script:Collection_DropDownBox) + $form1.Controls.Add($Script:Deployment_DropDownBox) + $form1.Controls.Add($Script:Combobox_Tools) + $form1.Controls.Add($GroupBox) + $form1.Controls.Add($GroupBox_Info) + $form1.controls.Add($Script:RadioButton_Window) + $form1.controls.Add($Script:RadioButton_GridView) + $form1.Controls.Add($Script:RadioButton_CSV) + $form1.Controls.Add($Button_Go) + $form1.Controls.Add($Script:TextBox_CollectionName) + $form1.Controls.Add($label_CollectionName) + $form1.Controls.Add($label_CollectionName_Value) + $form1.Controls.Add($label_DeploymentName) + $form1.controls.Add($label_DeploymentName_Value) + $form1.Controls.Add($label_DeploymentTime) + $form1.Controls.Add($label_DeploymentTime_Value) + $form1.Controls.Add($label_DeviceCount) + $form1.Controls.Add($label_DeviceCount_Value) + $form1.Controls.Add($label_ServersResponding) + $form1.Controls.Add($label_ServersResponding_Value) + $form1.Controls.Add($label_ServersNOTResponding) + $form1.Controls.Add($label_ServersNOTResponding_Value) + $form1.Controls.Add($label_ServersPinging) + $form1.Controls.Add($label_ServersPinging_Value) + + + + $form1.AutoScaleDimensions = '6, 13' + $form1.AutoScaleMode = 'Font' + $form1.ClientSize = '1000, 800' + $form1.Name = 'form1' + $form1.Text = 'Form' + $form1.add_Load($form1_Load) + #endregion Generated Form Code + + #---------------------------------------------- +<# + $PanelEventLogs_Events.Controls.Add($Text_ELogs_ServerName) + $PanelEventLogs_Events.Controls.Add($Button_ELogs_Connect) + $PanelEventLogs_Events.Controls.Add($Button_ELogs_View) + $PanelEventLogs_Events.Controls.Add($Combobox_EventLogs_LogsList) + $PanelEventLogs_Events.Controls.Add($VCenterUserPassword) + $PanelEventLogs_Events.Controls.Add($CheckBoxUseWindowsLogin) + $PanelEventLogs_Events.Controls.Add($labelVCenterUserName) + $PanelEventLogs_Events.Controls.Add($labelVCenterPassword) + $PanelEventLogs_Events.Controls.Add($Script:Collection_DropDownBox) + $PanelEventLogs_Events.BackColor = '153,153,153' + $PanelEventLogs_Events.Location = '6, 6' + $PanelEventLogs_Events.Name = 'panelEventLogs_Events' + $PanelEventLogs_Events.Size = '598, 56' + $PanelEventLogs_Events.TabIndex = 0 + $PanelEventLogs_Events.add_Paint($PanelEventLogs_Events_Paint) + + $PanelEventLogs_Filter.Controls.Add($Combobox_ELogsFilter_Level) + $PanelEventLogs_Filter.Controls.Add($Text_ELogs_EventID) + $PanelEventLogs_Filter.Controls.Add($Text_Elogs_DaysBack) + $PanelEventLogs_Filter.Controls.Add($label_ELogs_Level) + $PanelEventLogs_Filter.Controls.Add($label_ELogs_EventID) + $PanelEventLogs_Filter.Controls.Add($label_ELogs_DaysBack) + $PanelEventLogs_Filter.BackColor = '255,255,212' + $PanelEventLogs_Filter.Location = '6, 62' + $PanelEventLogs_Filter.Name = 'PanelEventLogs_Filter' + $PanelEventLogs_Filter.Size = '598, 56' + $PanelEventLogs_Filter.BorderStyle = 'FixedSingle' + $PanelEventLogs_Filter.TabIndex = 0 + $PanelEventLogs_Filter.add_Paint($PanelEventLogs_Filter_Paint) +#> + # + # $Text_ELogs_ServerName + <# + $Text_ELogs_ServerName.Location = '8, 26' + $Text_ELogs_ServerName.Name = '$Text_ELogs_ServerName' + $Text_ELogs_ServerName.Size = '100, 20' + $Text_ELogs_ServerName.text = "l2012" + $Text_ELogs_ServerName.TabIndex = 6 + $Text_ELogs_ServerName.add_TextChanged($Text_ELogs_ServerName_TextChanged) + # + # + # Text_ELogs_EventID + # + $Text_ELogs_EventID.Location = '115, 26' + $Text_ELogs_EventID.Name = 'Text_ELogs_EventID' + $Text_ELogs_EventID.Size = '40, 20' + $Text_ELogs_EventID.TabIndex = 7 + $Text_ELogs_EventID.add_TextChanged($Text_ELogs_EventID_TextChanged) + # + # Text_Elogs_DaysBack + # + $Text_Elogs_DaysBack.Location = '175, 26' + $Text_Elogs_DaysBack.Name = 'Text_Elogs_DaysBack' + $Text_Elogs_DaysBack.Size = '40, 20' + $Text_Elogs_DaysBack.TabIndex = 7 + $Text_Elogs_DaysBack.add_TextChanged($Text_Elogs_DaysBack_TextChanged) + #> + # Output + # + $Script:Output.Location = '10, 250' + $Script:Output.Multiline = $True + $Script:Output.Name = 'Output' + $Script:Output.ScrollBars = 'both' + $Script:Output.Size = '965, 500' + $Script:Output.Font = 'Consolas, 8.25pt' + $Script:Output.WordWrap = $False + $Script:Output.TabIndex = 5 + $Script:Output.add_TextChanged($Output_TextChanged) + $Script:Output.Visible = $True + # + $Script:Output_Left.Location = '20, 250' + $Script:Output_Left.Multiline = $True + $Script:Output_Left.Name = 'Output_Left' + $Script:Output_Left.ScrollBars = 'both' + $Script:Output_Left.Size = '470, 500' + $Script:Output_Left.Font = 'Consolas, 8.25pt' + $Script:Output_Left.WordWrap = $False + #$Script:Output_Left.TabIndex = 5 + + $Script:Output_Left.add_TextChanged($Output_Left_TextChanged) + # + $Script:Output_Right.Location = '510, 250' + $Script:Output_Right.Multiline = $True + $Script:Output_Right.Name = 'Output_Right' + $Script:Output_Right.ScrollBars = 'both' + $Script:Output_Right.Size = '470, 500' + $Script:Output_Right.Font = 'Consolas, 8.25pt' + $Script:Output_Right.WordWrap = $False + #$Script:Output_Right.TabIndex = 5 + $Script:Output_Right.add_TextChanged($Output_Right_TextChanged) + # + # ComboboxServiceStartMode + # + $Script:Collection_DropDownBox.FormattingEnabled = $True + $Script:Collection_DropDownBox.Location = '20, 80' + $Script:Collection_DropDownBox.Name = 'Script:Collection_DropDownBox' + $Script:Collection_DropDownBox.Size = '180, 20' + $Script:Collection_DropDownBox.TabIndex = 2 + $Script:Collection_DropDownBox.Text = '--Deployed to Collections--' + $Script:Collection_DropDownBox.add_SelectedIndexChanged($Script:Collection_DropDownBox_SelectedIndexChanged) + # + $Script:Deployment_DropDownBox.Location = '20,30' + #$Script:Deployment_DropDownBox.Size = New-Object System.Drawing.Size(580,50) + $Script:Deployment_DropDownBox.Size = '500,50' + #$Script:Deployment_DropDownBox.DropDownHeight = 200 + $Script:Deployment_DropDownBox.text = "----Select Deployment----" + #$Script:Deployment_DropDownBox.Visible = $false + $Script:Deployment_DropDownBox.add_SelectedIndexChanged($Script:Deployment_DropDownBox_SelectedIndexChanged) + # + #$Script:Combobox_Tools.Size = New-Object System.Drawing.Size(180,20) + #$Script:Combobox_Tools.DropDownHeight = 200 + $Script:Combobox_Tools.text = "----Select Tool----!" + $Script:Combobox_Tools.Location = '20,170' + $Script:Combobox_Tools.Size = '180,10' + $Script:Combobox_Tools.add_SelectedIndexChanged($Script:Combobox_Tools_SelectedIndexChanged) + # + $groupBox.Location = '270,70' + $groupBox.size = ('150,90') #New-Object System.Drawing.Size(150,90) + $groupBox.text = "Select Output:" + $GroupBox.Controls.Add($Script:RadioButton_Window) + $GroupBox.Controls.Add($Script:RadioButton_GridView) + $GroupBox.Controls.Add($Script:RadioButton_CSV) + # + $GroupBox_Info.Location = '570,25' + $GroupBox_Info.Size = '410,160' + $GroupBox_Info.Text = "Deployment Info" + $GroupBox_Info.Controls.Add($label_CollectionName) + $GroupBox_Info.Controls.Add($label_CollectionName_Value) + $GroupBox_Info.Controls.Add($label_DeploymentName) + $GroupBox_Info.Controls.Add($label_DeploymentName_Value) + $GroupBox_Info.Controls.Add($label_DeploymentTime) + $GroupBox_Info.Controls.Add($label_DeploymentTime_Value) + $GroupBox_Info.Controls.Add($label_DeviceCount) + $GroupBox_Info.Controls.Add($label_DeviceCount_Value) + ############ + $label_CollectionName.AutoSize = $True + $label_CollectionName.Font = 'Microsoft Sans Serif, 9.0pt' #, style=Bold' + #$label_CollectionName.ForeColor = 'DarkGreen' + #$label_CollectionName.TextAlign = 'MiddleRight' + $label_CollectionName.Location = '20,25' + $label_CollectionName.Name = 'Collection_Name' + $label_CollectionName.Size = '41, 13' + #$label_CollectionName.TabIndex = 6 + $label_CollectionName.Text = 'Collection Name:' + #$label_CollectionName.add_Click($label_CollectionName_Click) + + ############ Value ############### + $label_CollectionName_Value.AutoSize = $True + $label_CollectionName_Value.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_CollectionName_Value.ForeColor = 'DarkGreen' + #$label_CollectionName_Value.TextAlign = 'MiddleRight' + $label_CollectionName_Value.Location = '140,25' + $label_CollectionName_Value.Name = 'Collection_Name_Value' + $label_CollectionName_Value.Size = '41, 13' + #$label_CollectionName_Value.TabIndex = 6 + $label_CollectionName_Value.Text = '_' + #$label_CollectionName_Value.add_Click($label_CollectionName_Value_Click) + + ############ + $label_DeploymentName.AutoSize = $True + $label_DeploymentName.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_DeploymentName.ForeColor = 'DarkGreen' + #$label_DeploymentName.TextAlign = 'MiddleRight' + $label_DeploymentName.Location = '20,45' + $label_DeploymentName.Name = 'Deployment_Name' + $label_DeploymentName.Size = '41, 13' + #$label_DeploymentName.TabIndex = 6 + $label_DeploymentName.Text = 'Deployment Name:' + #$label_DeploymentName.add_Click($label_DeploymentName_Click) + + ############ Value ############ + $label_DeploymentName_Value.AutoSize = $True + $label_DeploymentName_Value.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_DeploymentName_Value.ForeColor = 'DarkGreen' + #$label_DeploymentName_Value.TextAlign = 'MiddleRight' + $label_DeploymentName_Value.Location = '140,45' + $label_DeploymentName_Value.Name = 'Deployment_Name_Value' + $label_DeploymentName_Value.Size = '41, 13' + #$label_DeploymentName_Value.TabIndex = 6 + $label_DeploymentName_Value.Text = '_' + #$label_DeploymentName_Value.add_Click($label_DeploymentName_Value_Click) + + ############# + $label_DeploymentTime.AutoSize = $True + $label_DeploymentTime.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_DeploymentTime.ForeColor = 'DarkGreen' + #$label_DeploymentTime.TextAlign = 'MiddleRight' + $label_DeploymentTime.Location = '20,65' + $label_DeploymentTime.Name = 'Deployment_Time' + $label_DeploymentTime.Size = '41, 13' + #$label_DeploymentTime.TabIndex = 6 + $label_DeploymentTime.Text = 'Deployment Time:' + #$label_DeploymentTime.add_Click($label_CollectionName_Click) + + ############ Value ############ + $label_DeploymentTime_Value.AutoSize = $True + $label_DeploymentTime_Value.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_DeploymentTime_Value.ForeColor = 'DarkGreen' + #$label_DeploymentTime_Value.TextAlign = 'MiddleRight' + $label_DeploymentTime_Value.Location = '140,65' + $label_DeploymentTime_Value.Name = 'Deployment_Time_Value' + $label_DeploymentTime_Value.Size = '41, 13' + #$label_DeploymentTime_Value.TabIndex = 6 + $label_DeploymentTime_Value.Text = '_' + #$label_DeploymentTime_Value.add_Click($label_DeploymentTime_Value_Click) + + ########### + $label_DeviceCount.AutoSize = $True + $label_DeviceCount.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_DeviceCount.ForeColor = 'DarkGreen' + #$label_DeviceCount.TextAlign = 'MiddleRight' + $label_DeviceCount.Location = '20,85' + $label_DeviceCount.Name = 'Device_Count' + $label_DeviceCount.Size = '41, 13' + #$label_DeviceCount.TabIndex = 6 + $label_DeviceCount.Text = 'Device Count:' + #$label_DeviceCount.add_Click($label_DeviceCount_Click) + + ############ Value ############ + $label_DeviceCount_Value.AutoSize = $True + $label_DeviceCount_Value.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_DeviceCount_Value.ForeColor = 'DarkGreen' + #$label_DeviceCount_Value.TextAlign = 'MiddleRight' + $label_DeviceCount_Value.Location = '140,85' + $label_DeviceCount_Value.Name = 'Device_Count_Value' + $label_DeviceCount_Value.Size = '41, 13' + #$label_DeviceCount_Value.TabIndex = 6 + $label_DeviceCount_Value.Text = '_' + #$label_DeviceCount_Value.add_Click($label_DeviceCount_Value_Click) +############ + $label_ServersResponding.AutoSize = $True + $label_ServersResponding.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_ServersResponding.ForeColor = 'DarkGreen' + #$label_ServersResponding.TextAlign = 'MiddleRight' + $label_ServersResponding.Location = '15,225' + $label_ServersResponding.Name = 'Servers Responding' + $label_ServersResponding.Size = '41, 13' + #$label_ServersResponding.TabIndex = 6 + $label_ServersResponding.Text = 'Servers Responding: ' + $label_ServersResponding.Visible = $False + #$label_ServersResponding.add_Click($label_ServersResponding_Click) +############ + $label_ServersResponding_Value.AutoSize = $True + $label_ServersResponding_Value.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_ServersResponding_Value.ForeColor = 'DarkGreen' + #$label_ServersResponding.TextAlign = 'MiddleRight' + $label_ServersResponding_Value.Location = '155,225' + $label_ServersResponding_Value.Name = 'Servers Responding Vlue' + $label_ServersResponding_Value.Size = '41, 13' + #$label_ServersResponding_Value.TabIndex = 6 + $label_ServersResponding_Value.Text = '-' + $label_ServersResponding_Value.Visible = $False + #$label_ServersResponding_Value.add_Click($label_ServersResponding_Value_Click) +############ +$label_ServersNOTResponding.AutoSize = $True + $label_ServersNOTResponding.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_ServersNOTResponding.ForeColor = 'Red' + #$label_ServersNOTResponding.TextAlign = 'MiddleRight' + $label_ServersNOTResponding.Location = '510,225' + $label_ServersNOTResponding.Name = 'Servers Not Responding' + $label_ServersNOTResponding.Size = '41, 13' + #$label_ServersNOTResponding.TabIndex = 6 + $label_ServersNOTResponding.Text = 'Servers NOT Responding: ' + $label_ServersNOTResponding.Visible = $False + #$label_ServersNOTResponding.add_Click($label_ServersNOTResponding_Click) +############ +$label_ServersNOTResponding_Value.AutoSize = $True + $label_ServersNOTResponding_Value.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_ServersNOTResponding_Value.ForeColor = 'Red' + #$label_ServersNOTResponding_Value.TextAlign = 'MiddleRight' + $label_ServersNOTResponding_Value.Location = '670,225' + $label_ServersNOTResponding_Value.Name = 'Servers Not Responding Value' + $label_ServersNOTResponding_Value.Size = '41, 13' + #$label_ServersNOTResponding_Value.TabIndex = 6 + $label_ServersNOTResponding_Value.Text = '- ' + $label_ServersNOTResponding_Value.Visible = $False + #$label_ServersNOTResponding_Value.add_Click($label_ServersNOTResponding_Value_Click) +############ +$label_ServersPinging.AutoSize = $True + $label_ServersPinging.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_ServersPinging.ForeColor = 'Green' + #$label_ServersPinging.TextAlign = 'MiddleRight' + $label_ServersPinging.Location = '15,210' + $label_ServersPinging.Name = 'Servers Pinging' + $label_ServersPinging.Size = '41, 13' + #$label_ServersPinging.TabIndex = 6 + $label_ServersPinging.Text = 'Checking Servers: ' + $label_ServersPinging.Visible = $False + #$label_ServersPinging.add_Click($label_ServersPinging_Click) +############ +$label_ServersPinging_Value.AutoSize = $True + $label_ServersPinging_Value.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_ServersPinging_Value.ForeColor = 'Green' + #$label_ServersPinging_Value.TextAlign = 'MiddleRight' + $label_ServersPinging_Value.Location = '165,210' + $label_ServersPinging_Value.Name = 'Servers Pinging Value' + $label_ServersPinging_Value.Size = '41, 13' + $label_ServersPinging_Value.Text = '- ' + $label_ServersPinging_Value.Visible = $False + #$label_ServersPinging_Value.add_Click($label_ServersPinging_Value_Click) +############ + $Script:RadioButton_Window.Location = new-object System.Drawing.Point(15,15) + $Script:RadioButton_Window.size = New-Object System.Drawing.Size(130,20) + $Script:RadioButton_Window.Checked = $true + $Script:RadioButton_Window.Text = "Window" + #$Script:RadioButton_Window. + # + $Script:RadioButton_GridView.Location = new-object System.Drawing.Point(15,35) + $Script:RadioButton_GridView.size = New-Object System.Drawing.Size(80,20) + $Script:RadioButton_GridView.Checked = $False + $Script:RadioButton_GridView.Text = "GridView" + # + $Script:RadioButton_CSV.Location = new-object System.Drawing.Point(15,55) + $Script:RadioButton_CSV.size = New-Object System.Drawing.Size(80,20) + $Script:RadioButton_CSV.Checked = $False + $Script:RadioButton_CSV.Text = "CSV" + # + $Button_Go.Location = New-Object System.Drawing.Size(450,75) + $Button_Go.Size = New-Object System.Drawing.Size(110,80) + $Button_Go.Text = "Go" + #$Button_Go.Add_Click({temp}) + $Button_Go.Add_Click($Button_Go_Click) + # + $Script:TextBox_CollectionName.Left = 20; + $Script:TextBox_CollectionName.Top = 130; + $Script:TextBox_CollectionName.width = 200; + $Script:TextBox_CollectionName.Text = "Nabil - Test Collection" + # + ############################################################################ + Update-Dropdown1 + ConnectTo-SCCM + Deployment-List -Deployment_History 5 + $Script:Output.Text = "helloooooooo" + #cd c: + + + ############################################################################ + +#Save the initial state of the form + $InitialFormWindowState = $form1.WindowState + #Init the OnLoad event to correct the initial state of the form + $form1.add_Load($Form_StateCorrection_Load) + #Clean up the control events + $form1.add_FormClosed($Form_Cleanup_FormClosed) + #Show the Form + return $form1.ShowDialog() + +} #End Function + +#Call the form +Show-Form-Template_psf | Out-Null diff --git a/dump/SCCM-Tool/NA-Tool-GUI-2.ps1 b/dump/SCCM-Tool/NA-Tool-GUI-2.ps1 new file mode 100644 index 0000000..ef825ea --- /dev/null +++ b/dump/SCCM-Tool/NA-Tool-GUI-2.ps1 @@ -0,0 +1,318 @@ +$Location = Split-Path $MyInvocation.MyCommand.Path -Parent + +$Script:ALL_Patch_Servers = @() +$Script:Responding = @() +$Script:NotResponding = @() +$Global:Collection_Name = "" +$Global:Select_Tool +$Global:Output_Type = "" + +If(!(Get-PSDrive -Name SCCM-Drive -ErrorAction SilentlyContinue)) { + Import-Module 'C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1' + New-PSDrive -Name SCCM-Drive -PSProvider "AdminUI.PS.Provider\CMSite" -Root "PNCRASCCM001.ccx.carecentrix.com" -Description "SCCM Site" +} +######################################################################################################################################################### +Function Start-Form { + + #$Global:Collection_Name = "" + #$Global:Select_Tool = "" + #$Global:Output_Type = "" + + $Temp = "" + + [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") + [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") + + $Form = New-Object System.Windows.Forms.Form + $Form.Size = New-Object System.Drawing.Size(1000,800) + ############################################## + #$Form_Load={ $Script:outputBox.text = "Welcome" } + ############################################## Start functions + <# function pingInfo { + + if ($RadioButton1.Checked -eq $true) {$nrOfPings=1} + if ($RadioButton2.Checked -eq $true) {$nrOfPings=2} + if ($RadioButton3.Checked -eq $true) {$nrOfPings=3} + + $computer=$DropDownBox.SelectedItem.ToString() #populate the var with the value you selected + $pingResult=ping $wks -n $nrOfPings | fl | out-string; + $Script:outputBox.text=$pingResult + + } #end pingInfo + #> + ############################################## end functions + Function SCCM-Module { + + If(!(Get-PSDrive).Name -eq "sccm-drive") { + Import-Module 'C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1' + New-PSDrive -Name SCCM-Drive -PSProvider "AdminUI.PS.Provider\CMSite" -Root "PNCRASCCM001.ccx.carecentrix.com" -Description "SCCM Site" + }#endIf + CD sccm-drive: + }#endFunction + ############################################## + Function Update-Dropdown1 { + # $Collections += $textBox1.text + $Collections = @("Collection-Servers","Ping-Collection","Check_Uptime","Test-Service","Remotely Update Policy","Tool6","Tool7") + $Collections | % { $DropDownBox.Items.Add($_) } + } + ############################################## + Function temp { + $outputBox.Clear() + #$Script:outputBox.text = $textBox1.text | Out-String + $Global:Collection_Name = $textBox1.Text + #$Global:Select_Tool = $RadioButton1.Checked + + $Global:Select_Tool = $DropDownBox.text + #$Global:Output_Type = + If ($RadioButton1.Checked -eq $true) { $Global:Output_Type = "Window"; $outputBox.Text = "Radio1 Checked: $($RadioButton1.Checked)" | Out-String } + ElseIf ($RadioButton2.Checked -eq $true) { $Global:Output_Type = "Gridview"; $outputBox.Text = "Radio2 Checked: $RadioButton2.Checked" | Out-String } + ElseIf ($RadioButton3.Checked -eq $true) { $Global:Output_Type = "Export"; $outputBox.Text = "Radio3 Checked: $RadioButton2.Checked" | Out-String } + + If($Global:Collection_Name -and $Global:Select_Tool) { + # If($DropDownBox.text = "Tool1"){gcc} + Run-Tool + $textBox1.clear() + $DropDownBox.text = "----Select Tool----" + Clear-Variables + }#endIf + Else { #$T = { Write-Host "You must enter Collection Name ............!!" -ForegroundColor Red } + $Script:outputBox.SelectionColor = 'red' + $Script:outputBox.Text = "You must select 'Tool' and enter Collection Name............!!" + } + + Run-Defaults + }#endFunction + ############################################## + Function Run-Tool { + + Switch($Global:Select_Tool) { + Collection-Servers { Collection-Servers; Write-Host "Tool Selected: $Global:Select_Tool" } + Ping-Collection { Ping_Collection } + Check_Uptime { Check_Uptime } + Test-Service { Test-Service } + #"Remotely Update Policy" { $outputBox.Text = Invoke-Expression $Location\Tool-Remotely-Restart-SCCMSyncCycle.ps1 | ft -AutoSize | Out-String } + "Remotely Update Policy" { $outputBox.Text = Invoke-Expression $Location\Tool-Remotely-Restart-SCCMSyncCycle.ps1 | ft -AutoSize | Out-String } + "Software Update Status" { $outputBox.Text = Invoke-Expression $Location\Tool-Get-SCCMSoftwareUpdateStatus.ps1 | ft -AutoSize | Out-String} + }#endSwitch + #Clear-Variables + }#endFunction + ############################################## + Function Run-Defaults { + $Script:textBox1.Text = "Nabil - Test Collection" + $Script:RadioButton1.Checked = $true + } + ############################################## + Function gcc { + $Script:outputBox.text = Get-Service | Out-String + } + ############################################## + Function Clear-Variables { + $Global:Collection_Name = "" + $Global:Select_Tool = "" + $Global:Output_Type = "" + + $Script:ALL_Patch_Servers = @() + } +#region Controls + ############################################## Start group boxes + $groupBox = New-Object System.Windows.Forms.GroupBox + $groupBox.Location = New-Object System.Drawing.Size(270,20) + $groupBox.size = New-Object System.Drawing.Size(150,110) + $groupBox.text = "Select Output:" + $Form.Controls.Add($groupBox) + ############################################## end group boxes + + ############################################## Start radio buttons + $Script:RadioButton1 = New-Object System.Windows.Forms.RadioButton + $Script:RadioButton1.Location = new-object System.Drawing.Point(15,15) + $Script:RadioButton1.size = New-Object System.Drawing.Size(130,20) + $Script:RadioButton1.Checked = $true + $Script:RadioButton1.Text = "Window" + $groupBox.Controls.Add($RadioButton1) + + $Script:RadioButton2 = New-Object System.Windows.Forms.RadioButton + $Script:RadioButton2.Location = new-object System.Drawing.Point(15,35) + $Script:RadioButton2.size = New-Object System.Drawing.Size(80,20) + $Script:RadioButton2.Text = "Gridview" + $groupBox.Controls.Add($RadioButton2) + + $Script:RadioButton3 = New-Object System.Windows.Forms.RadioButton + $Script:RadioButton3.Location = new-object System.Drawing.Point(15,55) + $Script:RadioButton3.size = New-Object System.Drawing.Size(80,20) + $Script:RadioButton3.Text = "Export csv" + $groupBox.Controls.Add($RadioButton3) + + ############################################## end radio buttons + ########### Text Box ########### + ############Define text box1 for input + $Script:textBox1 = New-Object “System.Windows.Forms.TextBox”; + $Script:textBox1.Left = 20; + $Script:textBox1.Top = 30; + $Script:textBox1.width = 200; + $Script:textBox1.Text = "Nabil - Test Collection" + $Form.Controls.Add($textBox1) + ############################################## Start drop down boxes + + $Script:DropDownBox = New-Object System.Windows.Forms.ComboBox + $Script:DropDownBox.Location = New-Object System.Drawing.Size(20,80) + $Script:DropDownBox.Size = New-Object System.Drawing.Size(180,20) + $Script:DropDownBox.DropDownHeight = 200 + $Script:DropDownBox.text = "----Select Tool----" + $Form.Controls.Add($DropDownBox) + + ############################################## end drop down boxes + + <############################################## Start text fields + + $Script:outputBox = New-Object System.Windows.Forms.TextBox + $Script:outputBox.Location = New-Object System.Drawing.Size(10,150) + $Script:outputBox.Size = New-Object System.Drawing.Size(865,300) + $Script:outputBox.MultiLine = $True + + $Script:outputBox.ScrollBars = "Vertical" + $Form.Controls.Add($Script:outputBox) + ###########> + $SCRIPT:outputBox=New-Object System.Windows.Forms.RichTextBox + $outputBox.Location=New-Object System.Drawing.Size(10,150) + $outputBox.Size=New-Object System.Drawing.Size(965,600) + $outputBox.Multiline=$True + $outputBox.ReadOnly = $True + $outputBox.BackColor = [Drawing.Color]::White + $outputBox.ScrollBars = "both" + $outputBox.WordWrap = $false + $outputBox.Font = 'Consolas, 8.25pt' + $form.Controls.Add($Script:outputBox) + + + + + ############################################## end text fields + + ############################################## Start buttons + + $Button = New-Object System.Windows.Forms.Button + $Button.Location = New-Object System.Drawing.Size(450,30) + $Button.Size = New-Object System.Drawing.Size(110,80) + $Button.Text = "Go" + $Button.Add_Click({temp}) + $Form.Controls.Add($Button) +#endregion Controls + ############################################## end buttons + Update-Dropdown1 + + $Form.Add_Shown({$Form.Activate()}) + [void] $Form.ShowDialog() + +} +######################################################################################################################################################### + <# Function Input-Box { + [void][System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic') + $Global:Collection_Name = [Microsoft.VisualBasic.Interaction]::InputBox("Enter your name", "Name", "Enter Collection Name") + + } + #> +############################################################################################################################################################# + Function Display-Results { + #Param($Global:Output_Type,$Final_Result) + Write-Host "DisplayType: $($Global:Output_Type)" + Switch ($Global:Output_Type){ + + Window { $Script:outputBox.Text = $Script:ALL_Patch_Servers | Out-String} + Gridview { $Script:ALL_Patch_Servers | Out-GridView } + Export { $Script:ALL_Patch_Servers | Export-Csv -Path $Location\Results.csv -NoTypeInformation; ii $Location\Results.csv } + + }#endSwitch + + } +############################################################################################################################################################# + Function Collection-Servers { + #Param($Coll_Name) + + Write-Host "Collection:$Global:Collection_Name" + + SCCM-Module + #CD sccm-drive: + $Script:DeviceCollection_MemberCount = Get-CMDeviceCollection -Name $Global:Collection_Name | select Name,MemberCount + $Script:DeviceCollection_ServerNames = Get-CMCollectionMember -CollectionName $Global:Collection_Name | select Name,IsClient #| Export-Csv "E:\SCCM-Files\SCCM-Scripts\Files\$Global:Collection_Name.csv" -NoTypeInformation + #$ServerName = $DeviceCollection_ServerNames.Name + Set-Location c: + + #$Script:Temp = Get-CMCollectionMember -CollectionName $Global:Collection_Name #| select Name,IsClient + + $Script:DeviceCollection_ServerNames | % { + $Obj = New-Object -TypeName PSObject + $Obj | Add-Member -MemberType NoteProperty -Name Server -Value $_.Name + $Obj | Add-Member -MemberType NoteProperty -Name ClientInstalled -Value $_.IsClient + $Obj | Add-Member -MemberType NoteProperty -Name CollectionName -Value $Global:Collection_Name + #$Obj | Add-Member -MemberType NoteProperty -Name CollectionMemberCount -Value {(Get-CMCollectionMember -Name $Global:Collection_Name).MemberCount} + + $Obj + $Script:ALL_Patch_Servers += $Obj + + }#end% + + # $Script:outputBox.Text = $Script:ALL_Patch_Servers | Out-String + Display-Results #-Final_Result $Script:ALL_Patch_Servers + Write-Host "$Script:ALL_Patch_Servers" + $Script:ALL_Patch_Servers | Export-Csv $Location\Current-Collection-Servers.csv -NoTypeInformation + + }#endFunction +############################################################################################################################################################# + Function Ping_Collection { + + $Ping_Result = @() + Write-Host "Total Server Count: $($Script:ALL_Patch_Servers.count)" -ForegroundColor Green + Write-Host "" + + SCCM-Module + #CD sccm-drive: + $Script:DeviceCollection_ServerNames1 = Get-CMCollectionMember -CollectionName $Global:Collection_Name | select Name + Set-Location c: + $Script:DeviceCollection_ServerNames1.Name | % { + + $Obj = New-Object -TypeName PSObject + If (Test-Connection $_ -Count 1 -ErrorAction SilentlyContinue ) { + #Write-Host "Responding:---- $_ " -ForegroundColor Green + #$Script:outputBox.AppendText("Responding: $_") + + $Obj | Add-Member -MemberType NoteProperty -Name Server -Value $_ + $Obj | Add-Member -MemberType NoteProperty -Name Responding -Value "No!" + $Ping_Result += $Obj + + }#endIf + + Else { + #$Script:outputBox.AppendText("NOT Responding: $_") + $NotResponding += $_ + $Obj | Add-Member -MemberType NoteProperty -Name Server -Value $_ + $Obj | Add-Member -MemberType NoteProperty -Name Responding -Value "No!" + $Ping_Result += $Obj + } + }#end% + $Script:outputBox.Text = $Ping_Result | ft -AutoSize | Out-String + + write-host "-------------------------------------------------------" + Write-host "$($Responding.count) / $($DeviceCollection_ServerNames1.count) -- Responding" -foregroundcolor Green + Write-host "$($NotResponding.count) / $($DeviceCollection_ServerNames1.count) -- NOT Responding" -foregroundcolor Red + + Write-Host "Servers NOT Responding: $NotResponding " -ForegroundColor Red + + }#endFunction +############################################################################################################################################################# + Function Check_Uptime { + SCCM-Module + $Script:DeviceCollection_ServerNames1 = Get-CMCollectionMember -CollectionName $Global:Collection_Name | select Name + $Script:outputBox.Text = $Script:DeviceCollection_ServerNames1.name | % { gwmi win32_operatingsystem -ComputerName $_ -ErrorAction SilentlyContinue | select @{n="Server";e={$_.PSComputername}},@{n="LastBootup";e={$_.Converttodatetime($_.LastBootUpTime)}}} | sort LastBootup -descending | Out-String + + } + +############################################################################################################################################################# + Function Test-Service { + $T = Get-Service + $outputBox.Text = $T | ft -AutoSize | Out-String + } +############################################################################################################################################################# + +############################################################################################################################################################# +Start-Form + diff --git a/dump/SCCM-Tool/NA-Tool-GUI-3.ps1 b/dump/SCCM-Tool/NA-Tool-GUI-3.ps1 new file mode 100644 index 0000000..4413f23 --- /dev/null +++ b/dump/SCCM-Tool/NA-Tool-GUI-3.ps1 @@ -0,0 +1,377 @@ +$Location = Split-Path $MyInvocation.MyCommand.Path -Parent + +$Script:ALL_Patch_Servers = @() +$Script:Responding = @() +$Script:NotResponding = @() +$Global:Collection_Name = "" +$Global:Select_Tool +$Global:Output_Type = "" + +If(!(Get-PSDrive -Name SCCM-Drive -ErrorAction SilentlyContinue)) { + Import-Module 'C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1' + New-PSDrive -Name SCCM-Drive -PSProvider "AdminUI.PS.Provider\CMSite" -Root "PNCRASCCM001.ccx.carecentrix.com" -Description "SCCM Site" +} +######################################################################################################################################################### +Function Start-Form { + + #$Global:Collection_Name = "" + #$Global:Select_Tool = "" + #$Global:Output_Type = "" + + $Temp = "" + + [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") + [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") + + $Form = New-Object System.Windows.Forms.Form + $Form.Size = New-Object System.Drawing.Size(1000,800) + ############################################## + #$Form_Load={ $Script:outputBox.text = "Welcome" } + ############################################## Start functions + <# function pingInfo { + + if ($RadioButton1.Checked -eq $true) {$nrOfPings=1} + if ($RadioButton2.Checked -eq $true) {$nrOfPings=2} + if ($RadioButton3.Checked -eq $true) {$nrOfPings=3} + + $computer=$DropDownBox.SelectedItem.ToString() #populate the var with the value you selected + $pingResult=ping $wks -n $nrOfPings | fl | out-string; + $Script:outputBox.text=$pingResult + + } #end pingInfo + #> + + + + + ############################################## end functions + Function SCCM-Module { + + If(!(Get-PSDrive).Name -eq "sccm-drive") { + Import-Module 'C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1' + New-PSDrive -Name SCCM-Drive -PSProvider "AdminUI.PS.Provider\CMSite" -Root "PNCRASCCM001.ccx.carecentrix.com" -Description "SCCM Site" + }#endIf + CD sccm-drive: + }#endFunction + ############################################## + Function Update-Dropdown1 { + # $Collections += $textBox1.text + $Collections = @("Collection-Servers","Ping-Collection","Check_Uptime","Test-Service","Remotely Update Policy","Software Update Status","Tool7") + $Collections | % { $DropDownBox.Items.Add($_) } + } + ############################################## + Function temp { + $outputBox.Clear() + #$Script:outputBox.text = $textBox1.text | Out-String + $Global:Collection_Name = $textBox1.Text + #$Global:Select_Tool = $RadioButton1.Checked + + $Global:Select_Tool = $DropDownBox.text + #$Global:Output_Type = + If ($RadioButton1.Checked -eq $true) { $Global:Output_Type = "Window"; $outputBox.Text = "Radio1 Checked: $($RadioButton1.Checked)" | Out-String } + ElseIf ($RadioButton2.Checked -eq $true) { $Global:Output_Type = "Gridview"; $outputBox.Text = "Radio2 Checked: $RadioButton2.Checked" | Out-String } + ElseIf ($RadioButton3.Checked -eq $true) { $Global:Output_Type = "Export"; $outputBox.Text = "Radio3 Checked: $RadioButton2.Checked" | Out-String } + + If($Global:Collection_Name -and $Global:Select_Tool) { + # If($DropDownBox.text = "Tool1"){gcc} + Run-Tool + $textBox1.clear() + $DropDownBox.text = "----Select Tool----" + Clear-Variables + }#endIf + Else { #$T = { Write-Host "You must enter Collection Name ............!!" -ForegroundColor Red } + $Script:outputBox.SelectionColor = 'red' + $Script:outputBox.Text = "You must select 'Tool' and enter Collection Name............!!" + } + + Run-Defaults + }#endFunction + ############################################## + Function Run-Tool { + + Switch($Global:Select_Tool) { + Collection-Servers { Collection-Servers; Write-Host "Tool Selected: $Global:Select_Tool" } + Ping-Collection { Ping_Collection } + Check_Uptime { Check_Uptime } + Test-Service { Test-Service } + #"Remotely Update Policy" { $outputBox.Text = Invoke-Expression $Location\Tool-Remotely-Restart-SCCMSyncCycle.ps1 | ft -AutoSize | Out-String } + "Remotely Update Policy" { $outputBox.Text = Invoke-Expression $Location\Tool-Remotely-Restart-SCCMSyncCycle.ps1 | ft -AutoSize | Out-String } + "Software Update Status" { $outputBox.Text = & "$Location\Tool-Get-SCCMSoftwareUpdateStatus.ps1" -Dep_ID 16778048 | ft -AutoSize | Out-String} + }#endSwitch + #Clear-Variables + }#endFunction + ############################################## + Function Run-Defaults { + $Script:textBox1.Text = "Nabil - Test Collection" + $Script:RadioButton1.Checked = $true + } + ############################################## + Function gcc { + $Script:outputBox.text = Get-Service | Out-String + } + ############################################## + Function Clear-Variables { + $Global:Collection_Name = "" + $Global:Select_Tool = "" + $Global:Output_Type = "" + + $Script:ALL_Patch_Servers = @() + } +#region Controls + ############################################## Start group boxes + $groupBox = New-Object System.Windows.Forms.GroupBox + $groupBox.Location = New-Object System.Drawing.Size(270,20) + $groupBox.size = New-Object System.Drawing.Size(150,90) + $groupBox.text = "Select Output:" + $Form.Controls.Add($groupBox) + ############################################## end group boxes + + ############################################## Start radio buttons + $Script:RadioButton1 = New-Object System.Windows.Forms.RadioButton + $Script:RadioButton1.Location = new-object System.Drawing.Point(15,15) + $Script:RadioButton1.size = New-Object System.Drawing.Size(130,20) + $Script:RadioButton1.Checked = $true + $Script:RadioButton1.Text = "Window" + $groupBox.Controls.Add($RadioButton1) + + $Script:RadioButton2 = New-Object System.Windows.Forms.RadioButton + $Script:RadioButton2.Location = new-object System.Drawing.Point(15,35) + $Script:RadioButton2.size = New-Object System.Drawing.Size(80,20) + $Script:RadioButton2.Text = "Gridview" + $groupBox.Controls.Add($RadioButton2) + + $Script:RadioButton3 = New-Object System.Windows.Forms.RadioButton + $Script:RadioButton3.Location = new-object System.Drawing.Point(15,55) + $Script:RadioButton3.size = New-Object System.Drawing.Size(80,20) + $Script:RadioButton3.Text = "Export csv" + $groupBox.Controls.Add($RadioButton3) + + ############################################## end radio buttons + ########### Text Box ########### + ############Define text box1 for input + $Script:textBox1 = New-Object “System.Windows.Forms.TextBox”; + $Script:textBox1.Left = 20; + $Script:textBox1.Top = 30; + $Script:textBox1.width = 200; + $Script:textBox1.Text = "Nabil - Test Collection" + $Form.Controls.Add($textBox1) + ############################################## Start drop down boxes + $Script:DropDownBox = New-Object System.Windows.Forms.ComboBox + $Script:DropDownBox.Location = New-Object System.Drawing.Size(20,80) + $Script:DropDownBox.Size = New-Object System.Drawing.Size(180,20) + $Script:DropDownBox.DropDownHeight = 200 + $Script:DropDownBox.text = "----Select Tool----" + $Form.Controls.Add($DropDownBox) + ############################################## end drop down boxes + $Script:Deployment_DropDownBox = New-Object System.Windows.Forms.ComboBox + $Script:Deployment_DropDownBox.Location = New-Object System.Drawing.Size(20,150) + $Script:Deployment_DropDownBox.Size = New-Object System.Drawing.Size(580,50) + $Script:Deployment_DropDownBox.DropDownHeight = 200 + $Script:Deployment_DropDownBox.text = "----Select Deployment----" + #$Script:Deployment_DropDownBox.Visible = $false + $Form.Controls.Add($Deployment_DropDownBox) + ############################################## + $Script:DeploymentCollection_DropDownBox = New-Object System.Windows.Forms.ComboBox + $Script:DeploymentCollection_DropDownBox.Location = New-Object System.Drawing.Size(20,180) + $Script:DeploymentCollection_DropDownBox.Size = New-Object System.Drawing.Size(280,50) + $Script:DeploymentCollection_DropDownBox.DropDownHeight = 200 + $Script:DeploymentCollection_DropDownBox.text = "----Deployment Collections----" + #$Script:DeploymentCollection_DropDownBox.Visible = $false + $Form.Controls.Add($DeploymentCollection_DropDownBox) + + + <############################################## Start text fields + + $Script:outputBox = New-Object System.Windows.Forms.TextBox + $Script:outputBox.Location = New-Object System.Drawing.Size(10,150) + $Script:outputBox.Size = New-Object System.Drawing.Size(865,300) + $Script:outputBox.MultiLine = $True + + $Script:outputBox.ScrollBars = "Vertical" + $Form.Controls.Add($Script:outputBox) + ###########> + $SCRIPT:outputBox=New-Object System.Windows.Forms.RichTextBox + $OutputBox.Location=New-Object System.Drawing.Size(10,250) + $OutputBox.Size=New-Object System.Drawing.Size(965,500) + $OutputBox.Multiline=$True + $OutputBox.ReadOnly = $True + $OutputBox.BackColor = [Drawing.Color]::White + $OutputBox.ScrollBars = "both" + $OutputBox.WordWrap = $false + $OutputBox.Font = 'Consolas, 8.25pt' + $form.Controls.Add($SCRIPT:OutputBox) + + + + + ############################################## end text fields + + ############################################## Start buttons + + $Button = New-Object System.Windows.Forms.Button + $Button.Location = New-Object System.Drawing.Size(450,30) + $Button.Size = New-Object System.Drawing.Size(110,80) + $Button.Text = "Go" + $Button.Add_Click({temp}) + $Form.Controls.Add($Button) +#endregion Controls + ############################################## end buttons + Update-Dropdown1 + Deployment-List -Deployment_History 2 +$OutputBox.Text = "hello" +############################################## + $Script:Deployment_DropDownBox_SelectedIndexChanged={ + #$Script:DeploymentCollection_DropDownBox.Text + $OutputBox.Text = "hello111111" #$Script:Deployment_DropDownBox.Text + } + + + + $Form.Add_Shown({$Form.Activate()}) + + + + + + + + [void] $Form.ShowDialog() + +} + + + + +######################################################################################################################################################### + <# Function Input-Box { + [void][System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic') + $Global:Collection_Name = [Microsoft.VisualBasic.Interaction]::InputBox("Enter your name", "Name", "Enter Collection Name") + + } + #> +############################################################################################################################################################# + Function Display-Results { + #Param($Global:Output_Type,$Final_Result) + Write-Host "DisplayType: $($Global:Output_Type)" + Switch ($Global:Output_Type){ + + Window { $Script:outputBox.Text = $Script:ALL_Patch_Servers | Out-String} + Gridview { $Script:ALL_Patch_Servers | Out-GridView } + Export { $Script:ALL_Patch_Servers | Export-Csv -Path $Location\Results.csv -NoTypeInformation; ii $Location\Results.csv } + + }#endSwitch + + } +############################################################################################################################################################# + Function Collection-Servers { + #Param($Coll_Name) + + Write-Host "Collection:$Global:Collection_Name" + + SCCM-Module + #CD sccm-drive: + $Script:DeviceCollection_MemberCount = Get-CMDeviceCollection -Name $Global:Collection_Name | select Name,MemberCount + $Script:DeviceCollection_ServerNames = Get-CMCollectionMember -CollectionName $Global:Collection_Name | select Name,IsClient #| Export-Csv "E:\SCCM-Files\SCCM-Scripts\Files\$Global:Collection_Name.csv" -NoTypeInformation + #$ServerName = $DeviceCollection_ServerNames.Name + Set-Location c: + + #$Script:Temp = Get-CMCollectionMember -CollectionName $Global:Collection_Name #| select Name,IsClient + + $Script:DeviceCollection_ServerNames | % { + $Obj = New-Object -TypeName PSObject + $Obj | Add-Member -MemberType NoteProperty -Name Server -Value $_.Name + $Obj | Add-Member -MemberType NoteProperty -Name ClientInstalled -Value $_.IsClient + $Obj | Add-Member -MemberType NoteProperty -Name CollectionName -Value $Global:Collection_Name + #$Obj | Add-Member -MemberType NoteProperty -Name CollectionMemberCount -Value {(Get-CMCollectionMember -Name $Global:Collection_Name).MemberCount} + + $Obj + $Script:ALL_Patch_Servers += $Obj + + }#end% + + # $Script:outputBox.Text = $Script:ALL_Patch_Servers | Out-String + Display-Results #-Final_Result $Script:ALL_Patch_Servers + Write-Host "$Script:ALL_Patch_Servers" + $Script:ALL_Patch_Servers | Export-Csv $Location\Current-Collection-Servers.csv -NoTypeInformation + + }#endFunction +############################################################################################################################################################# + Function Ping_Collection { + + $Ping_Result = @() + Write-Host "Total Server Count: $($Script:ALL_Patch_Servers.count)" -ForegroundColor Green + Write-Host "" + + SCCM-Module + #CD sccm-drive: + $Script:DeviceCollection_ServerNames1 = Get-CMCollectionMember -CollectionName $Global:Collection_Name | select Name + Set-Location c: + $Script:DeviceCollection_ServerNames1.Name | % { + + $Obj = New-Object -TypeName PSObject + If (Test-Connection $_ -Count 1 -ErrorAction SilentlyContinue ) { + #Write-Host "Responding:---- $_ " -ForegroundColor Green + #$Script:outputBox.AppendText("Responding: $_") + + $Obj | Add-Member -MemberType NoteProperty -Name Server -Value $_ + $Obj | Add-Member -MemberType NoteProperty -Name Responding -Value "No!" + $Ping_Result += $Obj + + }#endIf + + Else { + #$Script:outputBox.AppendText("NOT Responding: $_") + $NotResponding += $_ + $Obj | Add-Member -MemberType NoteProperty -Name Server -Value $_ + $Obj | Add-Member -MemberType NoteProperty -Name Responding -Value "No!" + $Ping_Result += $Obj + } + }#end% + $Script:outputBox.Text = $Ping_Result | ft -AutoSize | Out-String + + write-host "-------------------------------------------------------" + Write-host "$($Responding.count) / $($DeviceCollection_ServerNames1.count) -- Responding" -foregroundcolor Green + Write-host "$($NotResponding.count) / $($DeviceCollection_ServerNames1.count) -- NOT Responding" -foregroundcolor Red + + Write-Host "Servers NOT Responding: $NotResponding " -ForegroundColor Red + + }#endFunction +############################################################################################################################################################# + Function Check_Uptime { + SCCM-Module + $Script:DeviceCollection_ServerNames1 = Get-CMCollectionMember -CollectionName $Global:Collection_Name | select Name + $Script:outputBox.Text = $Script:DeviceCollection_ServerNames1.name | % { gwmi win32_operatingsystem -ComputerName $_ -ErrorAction SilentlyContinue | select @{n="Server";e={$_.PSComputername}},@{n="LastBootup";e={$_.Converttodatetime($_.LastBootUpTime)}}} | sort LastBootup -descending | Out-String + + } + +############################################################################################################################################################# + Function Deployment-List { + Param($Deployment_History) + SCCM-Module + $Deployments = Get-CMDeployment | ? { $_.deploymenttime -gt ((Get-Date).AddDays(-"$Deployment_History")) } + + #$T | select ApplicationName,CollectionName,DeploymentTime,AssignmentID,SoftwareName | % { $Deployment_DropDownBox.Items.Add($_) } + $i = 0 + $Q = "" #@() + + foreach ($D in $Deployments) { + $Q = $D.ApplicationName + "-------------------------------------------------------" + $D.CollectionName + + $Deployment_DropDownBox.Items.Add($Q) + $i++ + } + + + #$T.ApplicationName | % { $Deployment_DropDownBox.Items.Add($_) } + + }#endFunction +############################################################################################################################################################# + Function Test-Service { + $T = Get-Service + $outputBox.Text = $T | ft -AutoSize | Out-String + } +############################################################################################################################################################# + +############################################################################################################################################################# +Start-Form + diff --git a/dump/SCCM-Tool/NA-Tool-GUI-3x.ps1 b/dump/SCCM-Tool/NA-Tool-GUI-3x.ps1 new file mode 100644 index 0000000..8855f6b --- /dev/null +++ b/dump/SCCM-Tool/NA-Tool-GUI-3x.ps1 @@ -0,0 +1,518 @@ +#------------------------------------------------------------------------ +# Source File Information (DO NOT MODIFY) +# Source ID: 676f8db7-35c7-452d-b353-a4b40f26243a +# Source File: Form-Template.psf +#------------------------------------------------------------------------ +#region File Recovery Data (DO NOT MODIFY) +<#RecoveryData: +RAUAAB+LCAAAAAAABAC9VNtKwzAYvhd8h5Dr2oPd3AZtYXTuxtNwQ72TrP07o2lSknSzPr3p2g1x +QkHGKJSk+Q7/KQ0eIRFrkNWEaILMQlHBQ3xpezg6P0MoeJB0RTlhU8rgnuQQTYXMLxaQF4xosAuV +Bc4BpmEu3yHRSFcFhHheKQ25/Ux5KjbKrkWat4X+OrLQUxtKz3brx0JxyXQpIeRQakmYhWblktHk +BqqF+AAeLgcD0k/6V97I74E7HGHETSghzoyeh1HyRlkqDQ7HgmspmGoSNIHOpChA6qoljEst5glh +MKE58DoIA72ykOcHzg7aRb0TKWBTKq47OTGjwPWcfhnCwDU+/nDYSaqrjKNtap3YBXxqvG3bIfR6 +bbxb3K0gaav5Wq8DZ3vaNNNputlsxkpBbooPaqfTfqmiXCVCMro8QgMDZ6/626UZmVN4HH0sux3r +m3gaI0k2lK/+4+X6WT8bZJ6X9l3ik26vl5ydJKdYSDi+0X7bjHzg/PxrRt9OzyrdRAUAAA==#> +#endregion + +<# + .NOTES + -------------------------------------------------------------------------------- + Code generated by: SAPIEN Technologies, Inc., PowerShell Studio 2017 v5.4.141 + Generated on: 8/29/2017 11:53 AM + Generated by: Haidey2 + -------------------------------------------------------------------------------- + .DESCRIPTION + GUI script generated by PowerShell Studio 2017 +#> + + +#---------------------------------------------- +#region Application Functions +#---------------------------------------------- + +#endregion Application Functions + +#---------------------------------------------- +# Generated Form Function +#---------------------------------------------- +function Show-Form-Template_psf { + + #---------------------------------------------- + #region Import the Assemblies + #---------------------------------------------- + [void][reflection.assembly]::Load('System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') + [void][reflection.assembly]::Load('System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') + [void][reflection.assembly]::Load('System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') + #endregion Import Assemblies + + #---------------------------------------------- + #region Generated Form Objects + #---------------------------------------------- + [System.Windows.Forms.Application]::EnableVisualStyles() + $form1 = New-Object 'System.Windows.Forms.Form' + $InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState' + + + $Script:Output = New-Object System.Windows.Forms.TextBox + $Script:Collection_DropDownBox = New-Object System.Windows.Forms.ComboBox + $Script:Deployment_DropDownBox = New-Object System.Windows.Forms.ComboBox + + $GroupBox = New-Object System.Windows.Forms.GroupBox + $Script:RadioButton_Window = New-Object System.Windows.Forms.RadioButton + $Script:RadioButton_GridView = New-Object System.Windows.Forms.RadioButton + $Script:RadioButton_CSV = New-Object System.Windows.Forms.RadioButton + $Button_Go = New-Object System.Windows.Forms.Button + $Script:TextBox_CollectionName = New-Object “System.Windows.Forms.TextBox” + + #$PanelEventLogs_Events = New-Object 'System.Windows.Forms.Panel' + #$PanelEventLogs_Filter = New-Object 'System.Windows.Forms.Panel' + + + $Text_ELogs_ServerName = New-Object 'System.Windows.Forms.TextBox' + $Text_ELogs_EventID = New-Object 'System.Windows.Forms.TextBox' + $Text_Elogs_DaysBack = New-Object 'System.Windows.Forms.TextBox' + + $Button_ELogs_Connect = New-Object 'System.Windows.Forms.Button' + + + + + $Location = Split-Path $MyInvocation.MyCommand.Path -Parent + + $Script:ALL_Patch_Servers = @() + $Script:Responding = @() + $Script:NotResponding = @() + $Global:Collection_Name = "" + $Global:Select_Tool + $Global:Output_Type = "" + + #endregion Generated Form Objects + + #---------------------------------------------- + # User Generated Script + #---------------------------------------------- + + $form1_Load={ + #TODO: Initialize Form Controls here + + } + + $Script:Collection_DropDownBox_SelectedIndexChanged={ + $Script:Output.Text = $Script:Collection_DropDownBox.Text + } + + $Button_Go_Click = { $Script:Output.Text = "Button clicked" } + + ############################################## + Function Update-Dropdown1 { + # $Collections += $Script:Collection_DropDownBox.text + $Collections = @("Collection-Servers","Ping-Collection","Check_Uptime","Test-Service","Remotely Update Policy","Software Update Status","Tool7") + $Collections | % { $Script:Collection_DropDownBox.Items.Add($_) } + } +################################################################################################################## + Function temp { + $outputBox.Clear() + #$Script:outputBox.text = $Script:Collection_DropDownBox.text | Out-String + $Global:Collection_Name = $Script:TextBox_CollectionName.Text + #$Global:Select_Tool = $RadioButton1.Checked + + $Global:Select_Tool = $DropDownBox.text + #$Global:Output_Type = + If ($Script:RadioButton_Window.Checked -eq $true) { $Global:Output_Type = "Window"; $outputBox.Text = "Window_Radio1 Checked: $($Script:RadioButton_Window.Checked)" | Out-String } + ElseIf ($Script:RadioButton_GridView.Checked -eq $true) { $Global:Output_Type = "Gridview"; $outputBox.Text = "Gridview_Radio2 Checked: $Script:RadioButton_GridView.Checked" | Out-String } + ElseIf ($Script:RadioButton_CSV.Checked -eq $true) { $Global:Output_Type = "Export"; $outputBox.Text = "CSV_Radio3 Checked: $Script:RadioButton_CSV.Checked" | Out-String } + + If($Global:Collection_Name -and $Global:Select_Tool) { + # If($DropDownBox.text = "Tool1"){gcc} + Run-Tool + $Script:TextBox_CollectionName.clear() + $DropDownBox.text = "----Select Tool----" + Clear-Variables + }#endIf + Else { #$T = { Write-Host "You must enter Collection Name ............!!" -ForegroundColor Red } + $Script:outputBox.SelectionColor = 'red' + $Script:outputBox.Text = "You must select 'Tool' and enter Collection Name............!!" + } + + Run-Defaults + }#endFunction + + +################################################################################################################## + Function SCCM-Module { + + If(!(Get-PSDrive).Name -eq "sccm-drive") { + Import-Module 'C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1' + New-PSDrive -Name SCCM-Drive -PSProvider "AdminUI.PS.Provider\CMSite" -Root "PNCRASCCM001.ccx.carecentrix.com" -Description "SCCM Site" + }#endIf + CD sccm-drive: + }#endFunction + +################################################################################################################## + Function Run-Tool { + + Switch($Global:Select_Tool) { + Collection-Servers { Collection-Servers; Write-Host "Tool Selected: $Global:Select_Tool" } + Ping-Collection { Ping_Collection } + Check_Uptime { Check_Uptime } + Test-Service { Test-Service } + #"Remotely Update Policy" { $outputBox.Text = Invoke-Expression $Location\Tool-Remotely-Restart-SCCMSyncCycle.ps1 | ft -AutoSize | Out-String } + "Remotely Update Policy" { $outputBox.Text = Invoke-Expression $Location\Tool-Remotely-Restart-SCCMSyncCycle.ps1 | ft -AutoSize | Out-String } + "Software Update Status" { $outputBox.Text = & "$Location\Tool-Get-SCCMSoftwareUpdateStatus.ps1" -Dep_ID 16778048 | ft -AutoSize | Out-String} + }#endSwitch + #Clear-Variables + }#endFunction +################################################################################################################## + Function Run-Defaults { + $Script:TextBox_CollectionName.Text = "Nabil - Test Collection" + $Script:RadioButton1.Checked = $true + } +################################################################################################################## + Function Clear-Variables { + $Global:Collection_Name = "" + $Global:Select_Tool = "" + $Global:Output_Type = "" + + $Script:ALL_Patch_Servers = @() + } +################################################################################################################## + Function Display-Results { + #Param($Global:Output_Type,$Final_Result) + Write-Host "DisplayType: $($Global:Output_Type)" + Switch ($Global:Output_Type){ + + Window { $Script:outputBox.Text = $Script:ALL_Patch_Servers | Out-String} + Gridview { $Script:ALL_Patch_Servers | Out-GridView } + Export { $Script:ALL_Patch_Servers | Export-Csv -Path $Location\Results.csv -NoTypeInformation; ii $Location\Results.csv } + + }#endSwitch + + } +############################################################################################################################################################# + Function Collection-Servers { + #Param($Coll_Name) + + Write-Host "Collection:$Global:Collection_Name" + + SCCM-Module + #CD sccm-drive: + $Script:DeviceCollection_MemberCount = Get-CMDeviceCollection -Name $Global:Collection_Name | select Name,MemberCount + $Script:DeviceCollection_ServerNames = Get-CMCollectionMember -CollectionName $Global:Collection_Name | select Name,IsClient #| Export-Csv "E:\SCCM-Files\SCCM-Scripts\Files\$Global:Collection_Name.csv" -NoTypeInformation + #$ServerName = $DeviceCollection_ServerNames.Name + Set-Location c: + + #$Script:Temp = Get-CMCollectionMember -CollectionName $Global:Collection_Name #| select Name,IsClient + + $Script:DeviceCollection_ServerNames | % { + $Obj = New-Object -TypeName PSObject + $Obj | Add-Member -MemberType NoteProperty -Name Server -Value $_.Name + $Obj | Add-Member -MemberType NoteProperty -Name ClientInstalled -Value $_.IsClient + $Obj | Add-Member -MemberType NoteProperty -Name CollectionName -Value $Global:Collection_Name + #$Obj | Add-Member -MemberType NoteProperty -Name CollectionMemberCount -Value {(Get-CMCollectionMember -Name $Global:Collection_Name).MemberCount} + + $Obj + $Script:ALL_Patch_Servers += $Obj + + }#end% + + # $Script:outputBox.Text = $Script:ALL_Patch_Servers | Out-String + Display-Results #-Final_Result $Script:ALL_Patch_Servers + Write-Host "$Script:ALL_Patch_Servers" + $Script:ALL_Patch_Servers | Export-Csv $Location\Current-Collection-Servers.csv -NoTypeInformation + + }#endFunction +############################################################################################################################################################# + Function Ping_Collection { + + $Ping_Result = @() + Write-Host "Total Server Count: $($Script:ALL_Patch_Servers.count)" -ForegroundColor Green + Write-Host "" + + SCCM-Module + #CD sccm-drive: + $Script:DeviceCollection_ServerNames1 = Get-CMCollectionMember -CollectionName $Global:Collection_Name | select Name + Set-Location c: + $Script:DeviceCollection_ServerNames1.Name | % { + + $Obj = New-Object -TypeName PSObject + If (Test-Connection $_ -Count 1 -ErrorAction SilentlyContinue ) { + #Write-Host "Responding:---- $_ " -ForegroundColor Green + #$Script:outputBox.AppendText("Responding: $_") + + $Obj | Add-Member -MemberType NoteProperty -Name Server -Value $_ + $Obj | Add-Member -MemberType NoteProperty -Name Responding -Value "No!" + $Ping_Result += $Obj + + }#endIf + + Else { + #$Script:outputBox.AppendText("NOT Responding: $_") + $NotResponding += $_ + $Obj | Add-Member -MemberType NoteProperty -Name Server -Value $_ + $Obj | Add-Member -MemberType NoteProperty -Name Responding -Value "No!" + $Ping_Result += $Obj + } + }#end% + $Script:outputBox.Text = $Ping_Result | ft -AutoSize | Out-String + + write-host "-------------------------------------------------------" + Write-host "$($Responding.count) / $($DeviceCollection_ServerNames1.count) -- Responding" -foregroundcolor Green + Write-host "$($NotResponding.count) / $($DeviceCollection_ServerNames1.count) -- NOT Responding" -foregroundcolor Red + + Write-Host "Servers NOT Responding: $NotResponding " -ForegroundColor Red + + }#endFunction +############################################################################################################################################################# + Function Check_Uptime { + SCCM-Module + $Script:DeviceCollection_ServerNames1 = Get-CMCollectionMember -CollectionName $Global:Collection_Name | select Name + $Script:outputBox.Text = $Script:DeviceCollection_ServerNames1.name | % { gwmi win32_operatingsystem -ComputerName $_ -ErrorAction SilentlyContinue | select @{n="Server";e={$_.PSComputername}},@{n="LastBootup";e={$_.Converttodatetime($_.LastBootUpTime)}}} | sort LastBootup -descending | Out-String + + } + +############################################################################################################################################################# + Function Deployment-List { + Param($Deployment_History) + SCCM-Module + $Deployments = Get-CMDeployment | ? { $_.deploymenttime -gt ((Get-Date).AddDays(-"$Deployment_History")) } + + #$T | select ApplicationName,CollectionName,DeploymentTime,AssignmentID,SoftwareName | % { $Deployment_DropDownBox.Items.Add($_) } + $i = 0 + $Q = "" #@() + + foreach ($D in $Deployments) { + $Q = $D.ApplicationName + "-------------------------------------------------------" + $D.CollectionName + + $Deployment_DropDownBox.Items.Add($Q) + $i++ + } + + + #$T.ApplicationName | % { $Deployment_DropDownBox.Items.Add($_) } + + }#endFunction +############################################################################################################################################################# + Function Test-Service { + $T = Get-Service + $outputBox.Text = $T | ft -AutoSize | Out-String + } +################################################################################################################## + +################################################################################################################## + # --End User Generated Script-- + #---------------------------------------------- + #region Generated Events + #---------------------------------------------- + + $Form_StateCorrection_Load= + { + #Correct the initial state of the form to prevent the .Net maximized form issue + $form1.WindowState = $InitialFormWindowState + } + + $Form_Cleanup_FormClosed= + { + #Remove all event handlers from the controls + try + { + $form1.remove_Load($form1_Load) + $form1.remove_Load($Form_StateCorrection_Load) + $form1.remove_FormClosed($Form_Cleanup_FormClosed) + + #$PanelEventLogs_Events.remove_Paint($PanelEventLogs_Events_Paint) + #$PanelEventLogs_Filter.remove_Paint($PanelEventLogs_Filter_Paint) + + $Text_Elogs_DaysBack.remove_TextChanged($Text_Elogs_DaysBack_TextChanged) + $Text_ELogs_ServerName.remove_TextChanged($Text_ELogs_ServerName_TextChanged) + $Text_ELogs_EventID.remove_TextChanged($Text_ELogs_EventID_TextChanged) + + $Script:Output.remove_TextChanged($Output_TextChanged) + $Script:Collection_DropDownBox.remove_SelectedIndexChanged($Script:Collection_DropDownBox_SelectedIndexChanged) + $Script:Deployment_DropDownBox.remove_SelectedIndexChanged($Script:Deployment_DropDownBox_SelectedIndexChanged) + $Script:RadioButton_Window.remove_SelectedIndexChanged($Script:RadioButton_Window_SelectedIndexChanged) + $Script:RadioButton_GridView.remove_SelectedIndexChanged($Script:RadioButton_GridView_SelectedIndexChanged) + $Script:RadioButton_CSV.remove_SelectedIndexChanged($Script:RadioButton_CSV_SelectedIndexChanged) + $Button_Go.remove_Click($Button_Go_Click) + + } + catch { Out-Null <# Prevent PSScriptAnalyzer warning #> } + } + + + #$PanelEventLogs_Events_Paint=[System.Windows.Forms.PaintEventHandler]{ <#Event Argument: $_ = [System.Windows.Forms.PaintEventArgs]#> } + #$PanelEventLogs_Filter_Paint=[System.Windows.Forms.PaintEventHandler]{ } + + $Text_ELogs_ServerName_TextChanged={} + $Text_Elogs_DaysBack_TextChanged={} + + #endregion Generated Events + + #---------------------------------------------- + #region Generated Form Code + #---------------------------------------------- + # + # form1 + # + #$form1.Controls.Add($PanelEventLogs_Events) + #$form1.Controls.Add($PanelEventLogs_Filter) + + $form1.Controls.Add($Output) + $form1.Controls.Add($Script:Collection_DropDownBox) + $form1.Controls.Add($Script:Deployment_DropDownBox) + $form1.Controls.Add($GroupBox) + $form1.controls.Add($Script:RadioButton_Window) + $form1.controls.Add($Script:RadioButton_GridView) + $form1.Controls.Add($Script:RadioButton_CSV) + $form1.Controls.Add($Button_Go) + $form1.Controls.Add($Script:TextBox_CollectionName) + + + $form1.AutoScaleDimensions = '6, 13' + $form1.AutoScaleMode = 'Font' + $form1.ClientSize = '1000, 800' + $form1.Name = 'form1' + $form1.Text = 'Form' + $form1.add_Load($form1_Load) + #endregion Generated Form Code + + #---------------------------------------------- +<# + $PanelEventLogs_Events.Controls.Add($Text_ELogs_ServerName) + $PanelEventLogs_Events.Controls.Add($Button_ELogs_Connect) + $PanelEventLogs_Events.Controls.Add($Button_ELogs_View) + $PanelEventLogs_Events.Controls.Add($Combobox_EventLogs_LogsList) + $PanelEventLogs_Events.Controls.Add($VCenterUserPassword) + $PanelEventLogs_Events.Controls.Add($CheckBoxUseWindowsLogin) + $PanelEventLogs_Events.Controls.Add($labelVCenterUserName) + $PanelEventLogs_Events.Controls.Add($labelVCenterPassword) + $PanelEventLogs_Events.Controls.Add($Script:Collection_DropDownBox) + $PanelEventLogs_Events.BackColor = '153,153,153' + $PanelEventLogs_Events.Location = '6, 6' + $PanelEventLogs_Events.Name = 'panelEventLogs_Events' + $PanelEventLogs_Events.Size = '598, 56' + $PanelEventLogs_Events.TabIndex = 0 + $PanelEventLogs_Events.add_Paint($PanelEventLogs_Events_Paint) + + $PanelEventLogs_Filter.Controls.Add($Combobox_ELogsFilter_Level) + $PanelEventLogs_Filter.Controls.Add($Text_ELogs_EventID) + $PanelEventLogs_Filter.Controls.Add($Text_Elogs_DaysBack) + $PanelEventLogs_Filter.Controls.Add($label_ELogs_Level) + $PanelEventLogs_Filter.Controls.Add($label_ELogs_EventID) + $PanelEventLogs_Filter.Controls.Add($label_ELogs_DaysBack) + $PanelEventLogs_Filter.BackColor = '255,255,212' + $PanelEventLogs_Filter.Location = '6, 62' + $PanelEventLogs_Filter.Name = 'PanelEventLogs_Filter' + $PanelEventLogs_Filter.Size = '598, 56' + $PanelEventLogs_Filter.BorderStyle = 'FixedSingle' + $PanelEventLogs_Filter.TabIndex = 0 + $PanelEventLogs_Filter.add_Paint($PanelEventLogs_Filter_Paint) +#> + # + # $Text_ELogs_ServerName + # + $Text_ELogs_ServerName.Location = '8, 26' + $Text_ELogs_ServerName.Name = '$Text_ELogs_ServerName' + $Text_ELogs_ServerName.Size = '100, 20' + $Text_ELogs_ServerName.text = "l2012" + $Text_ELogs_ServerName.TabIndex = 6 + $Text_ELogs_ServerName.add_TextChanged($Text_ELogs_ServerName_TextChanged) + # + # + # Text_ELogs_EventID + # + $Text_ELogs_EventID.Location = '115, 26' + $Text_ELogs_EventID.Name = 'Text_ELogs_EventID' + $Text_ELogs_EventID.Size = '40, 20' + $Text_ELogs_EventID.TabIndex = 7 + $Text_ELogs_EventID.add_TextChanged($Text_ELogs_EventID_TextChanged) + # + # Text_Elogs_DaysBack + # + $Text_Elogs_DaysBack.Location = '175, 26' + $Text_Elogs_DaysBack.Name = 'Text_Elogs_DaysBack' + $Text_Elogs_DaysBack.Size = '40, 20' + $Text_Elogs_DaysBack.TabIndex = 7 + $Text_Elogs_DaysBack.add_TextChanged($Text_Elogs_DaysBack_TextChanged) + # + # Output + # + $Output.Location = '10, 250' + $Output.Multiline = $True + $Output.Name = 'Output' + $Output.ScrollBars = 'both' + $Output.Size = '965, 500' + $Output.Font = 'Consolas, 8.25pt' + $Output.WordWrap = $False + $Output.TabIndex = 5 + $Output.add_TextChanged($Output_TextChanged) + # + # ComboboxServiceStartMode + # + $Script:Collection_DropDownBox.FormattingEnabled = $True + $Script:Collection_DropDownBox.Location = '20, 80' + $Script:Collection_DropDownBox.Name = 'Script:Collection_DropDownBox' + $Script:Collection_DropDownBox.Size = '180, 20' + $Script:Collection_DropDownBox.TabIndex = 2 + $Script:Collection_DropDownBox.Text = '--Tools--' + $Script:Collection_DropDownBox.add_SelectedIndexChanged($Script:Collection_DropDownBox_SelectedIndexChanged) + # + $Script:Deployment_DropDownBox.Location = '20,30' + $Script:Deployment_DropDownBox.Size = New-Object System.Drawing.Size(580,50) + $Script:Deployment_DropDownBox.DropDownHeight = 200 + $Script:Deployment_DropDownBox.text = "----Select Deployment----" + #$Script:Deployment_DropDownBox.Visible = $false + # + $groupBox.Location = '270,70' + $groupBox.size = New-Object System.Drawing.Size(150,90) + $groupBox.text = "Select Output:" + + $GroupBox.Controls.Add($Script:RadioButton_Window) + $GroupBox.Controls.Add($Script:RadioButton_GridView) + $GroupBox.Controls.Add($Script:RadioButton_CSV) + # + $Script:RadioButton_Window.Location = new-object System.Drawing.Point(15,15) + $Script:RadioButton_Window.size = New-Object System.Drawing.Size(130,20) + $Script:RadioButton_Window.Checked = $true + $Script:RadioButton_Window.Text = "Window" + # + $Script:RadioButton_GridView.Location = new-object System.Drawing.Point(15,35) + $Script:RadioButton_GridView.size = New-Object System.Drawing.Size(80,20) + $Script:RadioButton_GridView.Checked = $False + $Script:RadioButton_GridView.Text = "GridView" + # + $Script:RadioButton_CSV.Location = new-object System.Drawing.Point(15,55) + $Script:RadioButton_CSV.size = New-Object System.Drawing.Size(80,20) + $Script:RadioButton_CSV.Checked = $False + $Script:RadioButton_CSV.Text = "CSV" + # + $Button_Go.Location = New-Object System.Drawing.Size(450,75) + $Button_Go.Size = New-Object System.Drawing.Size(110,80) + $Button_Go.Text = "Go" + #$Button_Go.Add_Click({temp}) + $Button_Go.Add_Click($Button_Go_Click) + # + $Script:TextBox_CollectionName.Left = 20; + $Script:TextBox_CollectionName.Top = 130; + $Script:TextBox_CollectionName.width = 200; + $Script:TextBox_CollectionName.Text = "Nabil - Test Collection" + # + ############################################################################ + Update-Dropdown1 + $Script:Output.Text = "hello" + + + ############################################################################ + +#Save the initial state of the form + $InitialFormWindowState = $form1.WindowState + #Init the OnLoad event to correct the initial state of the form + $form1.add_Load($Form_StateCorrection_Load) + #Clean up the control events + $form1.add_FormClosed($Form_Cleanup_FormClosed) + #Show the Form + return $form1.ShowDialog() + +} #End Function + +#Call the form +Show-Form-Template_psf | Out-Null diff --git a/dump/SCCM-Tool/NA-Tool-GUI-4x.ps1 b/dump/SCCM-Tool/NA-Tool-GUI-4x.ps1 new file mode 100644 index 0000000..113b8f0 --- /dev/null +++ b/dump/SCCM-Tool/NA-Tool-GUI-4x.ps1 @@ -0,0 +1,626 @@ +#------------------------------------------------------------------------ +# Source File Information (DO NOT MODIFY) +# Source ID: 676f8db7-35c7-452d-b353-a4b40f26243a +# Source File: Form-Template.psf +#------------------------------------------------------------------------ +#region File Recovery Data (DO NOT MODIFY) +<#RecoveryData: +RAUAAB+LCAAAAAAABAC9VNtKwzAYvhd8h5Dr2oPd3AZtYXTuxtNwQ72TrP07o2lSknSzPr3p2g1x +QkHGKJSk+Q7/KQ0eIRFrkNWEaILMQlHBQ3xpezg6P0MoeJB0RTlhU8rgnuQQTYXMLxaQF4xosAuV +Bc4BpmEu3yHRSFcFhHheKQ25/Ux5KjbKrkWat4X+OrLQUxtKz3brx0JxyXQpIeRQakmYhWblktHk +BqqF+AAeLgcD0k/6V97I74E7HGHETSghzoyeh1HyRlkqDQ7HgmspmGoSNIHOpChA6qoljEst5glh +MKE58DoIA72ykOcHzg7aRb0TKWBTKq47OTGjwPWcfhnCwDU+/nDYSaqrjKNtap3YBXxqvG3bIfR6 +bbxb3K0gaav5Wq8DZ3vaNNNputlsxkpBbooPaqfTfqmiXCVCMro8QgMDZ6/626UZmVN4HH0sux3r +m3gaI0k2lK/+4+X6WT8bZJ6X9l3ik26vl5ydJKdYSDi+0X7bjHzg/PxrRt9OzyrdRAUAAA==#> +#endregion + +<# + .NOTES + -------------------------------------------------------------------------------- + Code generated by: SAPIEN Technologies, Inc., PowerShell Studio 2017 v5.4.141 + Generated on: 8/29/2017 11:53 AM + Generated by: Haidey2 + -------------------------------------------------------------------------------- + .DESCRIPTION + GUI script generated by PowerShell Studio 2017 +#> + + +#---------------------------------------------- +#region Application Functions +#---------------------------------------------- + +#endregion Application Functions + +#---------------------------------------------- +# Generated Form Function +#---------------------------------------------- +function Show-Form-Template_psf { + + #---------------------------------------------- + #region Import the Assemblies + #---------------------------------------------- + [void][reflection.assembly]::Load('System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') + [void][reflection.assembly]::Load('System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') + [void][reflection.assembly]::Load('System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') + #endregion Import Assemblies + + #---------------------------------------------- + #region Generated Form Objects + #---------------------------------------------- + [System.Windows.Forms.Application]::EnableVisualStyles() + $form1 = New-Object 'System.Windows.Forms.Form' + $InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState' + + + $Script:Output = New-Object System.Windows.Forms.TextBox + $Script:Collection_DropDownBox = New-Object System.Windows.Forms.ComboBox + $Script:Deployment_DropDownBox = New-Object System.Windows.Forms.ComboBox + $Script:Combobox_Tools = New-Object System.Windows.Forms.ComboBox + + $GroupBox = New-Object System.Windows.Forms.GroupBox + $Script:RadioButton_Window = New-Object System.Windows.Forms.RadioButton + $Script:RadioButton_GridView = New-Object System.Windows.Forms.RadioButton + $Script:RadioButton_CSV = New-Object System.Windows.Forms.RadioButton + $Button_Go = New-Object System.Windows.Forms.Button + $Script:TextBox_CollectionName = New-Object “System.Windows.Forms.TextBox” + + #$PanelEventLogs_Events = New-Object 'System.Windows.Forms.Panel' + #$PanelEventLogs_Filter = New-Object 'System.Windows.Forms.Panel' + + + $Text_ELogs_ServerName = New-Object 'System.Windows.Forms.TextBox' + $Text_ELogs_EventID = New-Object 'System.Windows.Forms.TextBox' + $Text_Elogs_DaysBack = New-Object 'System.Windows.Forms.TextBox' + + $Button_ELogs_Connect = New-Object 'System.Windows.Forms.Button' + + + + +# $Location = Split-Path $MyInvocation.MyCommand.Path -Parent + + $Script:ALL_Patch_Servers = @() + $Script:Responding = @() + $Script:NotResponding = @() + $Global:Collection_Name = "" + $Global:Select_Tool + $Global:Output_Type = "" + $Global:Deployments = "" + + #endregion Generated Form Objects + + #---------------------------------------------- + # User Generated Script + #---------------------------------------------- + + $form1_Load={ + #TODO: Initialize Form Controls here + + } + + $Script:Collection_DropDownBox_SelectedIndexChanged={ + + $Script:Output.Text = $Script:Collection_DropDownBox.Text + } + + $Script:Deployment_DropDownBox_SelectedIndexChanged={ + Deployed-to-Collections + $Script:Output.Text = $Script:Deployment_DropDownBox.Text + } + + $Script:Combobox_Tools_SelectedIndexChanged= { + $Script:Output.Text = $Script:Combobox_Tools.Text + } + + $Button_Go_Click = { + temp + #SCCM-Module + # $Global:Collection_Name = $Script:TextBox_CollectionName.Text #$Script:TextBox_CollectionName.Text + # $Global:Select_Tool = $Script:Combobox_Tools.Text + + + #$Output.Text = "$Global:Collection_Name --- $Global:Select_Tool " | Out-String + #$Output.Text = | Out-String + } + + +################################################################################################################## + Function ConnectTo-SCCM { + + If(!(Get-PSDrive).Name -ne "CCX") { + # + # Press 'F5' to run this script. Running this script will load the ConfigurationManager + # module for Windows PowerShell and will connect to the site. + # + # This script was auto-generated at '2/18/2021 10:12:39 AM'. + + # Uncomment the line below if running in an environment where script signing is + # required. + #Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process + + # Site configuration + $SiteCode = "CCX" # Site code + $ProviderMachineName = "PNCRASCCM001.ccx.carecentrix.com" # SMS Provider machine name + + # Customizations + $initParams = @{} + #$initParams.Add("Verbose", $true) # Uncomment this line to enable verbose logging + #$initParams.Add("ErrorAction", "Stop") # Uncomment this line to stop the script on any errors + + # Do not change anything below this line + + # Import the ConfigurationManager.psd1 module + if((Get-Module ConfigurationManager) -eq $null) { + Import-Module "$($ENV:SMS_ADMIN_UI_PATH)\..\ConfigurationManager.psd1" @initParams + } + + # Connect to the site's drive if it is not already present + if((Get-PSDrive -Name $SiteCode -PSProvider CMSite -ErrorAction SilentlyContinue) -eq $null) { + New-PSDrive -Name $SiteCode -PSProvider CMSite -Root $ProviderMachineName @initParams + } + + # Set the current location to be the site code. + Set-Location "$($SiteCode):\" @initParams + + #$Script:Output.Text = "inside connectoSCCM function" + }#endIf + }#endFunction +################################################################################################################## + Function SCCM-Module { + Write-Host "Inside SCCM function" -ForegroundColor Cyan + If(!(Get-PSDrive).Name -eq "sccm-drive") { + + Import-Module 'C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1' + New-PSDrive -Name SCCM-Drive -PSProvider "AdminUI.PS.Provider\CMSite" -Root "PNCRASCCM001.ccx.carecentrix.com" -Description "SCCM Site" + }#endIf + $Script:Output.Text | Get-PSDrive | ft -AutoSize | Out-String + CD sccm-drive: + }#endFunction +################################################################################################################## + Function Update-Dropdown1 { + # $Collections += $Script:Collection_DropDownBox.text + $Collections = @("Collection-Servers","Ping-Collection","Check_Uptime","Test-Service","Remotely Update Policy","Software Update Status","Test-Sccm") + $Collections | % { $Script:Combobox_Tools.Items.Add($_) } + } +################################################################################################################## + Function temp { + $Script:Output.Clear() + #$Script:Script:Output.text = $Script:Collection_DropDownBox.text | Out-String + + $Global:Collection_Name = $Script:TextBox_CollectionName.Text #$Script:TextBox_CollectionName.Text + $Global:Select_Tool = $Script:Combobox_Tools.Text + + + If ($Script:RadioButton_Window.Checked -eq $true) { $Global:Output_Type = "Window" <#; $Script:Output.Text = "Window_Radio1 Checked: $($Script:RadioButton_Window.Checked)" | Out-String #> } + ElseIf ($Script:RadioButton_GridView.Checked -eq $true) { $Global:Output_Type = "Gridview" <#; $Script:Output.Text = "Gridview_Radio2 Checked: $($Script:RadioButton_GridView.Checked)" | Out-String #> } + ElseIf ($Script:RadioButton_CSV.Checked -eq $true) { $Global:Output_Type = "Export" <#; $Script:Output.Text = "CSV_Radio3 Checked: $($Script:RadioButton_CSV.Checked)" | Out-String #> } + + + If($Global:Collection_Name -and $Global:Select_Tool) { + # If($Script:Collection_DropDownBox.text = "Tool1"){gcc} + Run-Tool + #$Script:TextBox_CollectionName.clear() + $Script:Collection_DropDownBox.text = "----Select Tool----" + #Clear-Variables + }#endIf + Else { #$T = { Write-Host "You must enter Collection Name ............!!" -ForegroundColor Red } + $Script:Output.SelectionColor = 'red' + $Script:Output.Text = "You must select 'Tool' and enter Collection Name............!!" + } + + Run-Defaults + }#endFunction + + + + +################################################################################################################## + Function Run-Tool { + + Switch($Global:Select_Tool) { + Collection-Servers { Collection-Servers; Write-Host "Tool Selected: $Global:Select_Tool" } + Ping-Collection { Ping_Collection } + Check_Uptime { Check_Uptime } + Test-Service { Test-Service } + Test-SCCM { SCCM-Module } + #"Remotely Update Policy" { $Script:Output.Text = Invoke-Expression $Location\Tool-Remotely-Restart-SCCMSyncCycle.ps1 | ft -AutoSize | Out-String } + "Remotely Update Policy" { $Script:Output.Text = Invoke-Expression $Location\Tool-Remotely-Restart-SCCMSyncCycle.ps1 | ft -AutoSize | Out-String } + "Software Update Status" { $Script:Output.Text = & "$Location\Tool-Get-SCCMSoftwareUpdateStatus.ps1" -Dep_ID 16778048 | ft -AutoSize | Out-String} + }#endSwitch + #Clear-Variables + }#endFunction +################################################################################################################## + Function Run-Defaults { + #$Script:TextBox_CollectionName.Text = "Nabil - Test Collection" + $Script:RadioButton_Window.Checked = $true + + <# + If(!$Location) { + $Location = Split-Path $MyInvocation.MyCommand.Path -Parent + } + #> + } +################################################################################################################## + Function xClear-Variables { + $Global:Collection_Name = "" + $Global:Select_Tool = "" + $Global:Output_Type = "" + + $Script:ALL_Patch_Servers = @() + } +################################################################################################################## + Function Display-Results { + #Param($Global:Output_Type,$Final_Result) + Write-Host "DisplayType: $($Global:Output_Type)" + Switch ($Global:Output_Type){ + + Window { $Script:Output.Text = $Script:ALL_Patch_Servers | Out-String} + Gridview { $Script:ALL_Patch_Servers | Out-GridView } + Export { $Script:ALL_Patch_Servers | Export-Csv -Path $Location\Results.csv -NoTypeInformation; ii $Location\Results.csv } + + }#endSwitch + + } +############################################################################################################################################################# + Function Collection-Servers { + #Param($Coll_Name) + + Write-Host "Collection:$Global:Collection_Name" + $Script:ALL_Patch_Servers = @() + + ConnectTo-SCCM + #SCCM-Module + #CD sccm-drive: + $Script:DeviceCollection_MemberCount = Get-CMDeviceCollection -Name $Global:Collection_Name | select Name,MemberCount + $Script:DeviceCollection_ServerNames = Get-CMCollectionMember -CollectionName $Global:Collection_Name | select Name,IsClient #| Export-Csv "E:\SCCM-Files\SCCM-Scripts\Files\$Global:Collection_Name.csv" -NoTypeInformation + #$ServerName = $DeviceCollection_ServerNames.Name + #Set-Location c: + + #$Script:Temp = Get-CMCollectionMember -CollectionName $Global:Collection_Name #| select Name,IsClient + + $Script:DeviceCollection_ServerNames | % { + $Obj = New-Object -TypeName PSObject + $Obj | Add-Member -MemberType NoteProperty -Name Server -Value $_.Name + $Obj | Add-Member -MemberType NoteProperty -Name ClientInstalled -Value $_.IsClient + $Obj | Add-Member -MemberType NoteProperty -Name CollectionName -Value $Global:Collection_Name + #$Obj | Add-Member -MemberType NoteProperty -Name CollectionMemberCount -Value {(Get-CMCollectionMember -Name $Global:Collection_Name).MemberCount} + + $Obj + $Script:ALL_Patch_Servers += $Obj + + }#end% + + # $Script:Output.Text = $Script:ALL_Patch_Servers | Out-String + Display-Results #-Final_Result $Script:ALL_Patch_Servers + Write-Host "$Script:ALL_Patch_Servers" + $Script:ALL_Patch_Servers | Export-Csv $Location\Current-Collection-Servers.csv -NoTypeInformation + + }#endFunction +############################################################################################################################################################# + Function Ping_Collection { + + $Ping_Result = @() + $NotResponding = @() + $Responding = @() + + ConnectTo-SCCM + #SCCM-Module + #CD sccm-drive: + $Script:DeviceCollection_ServerNames1 = Get-CMCollectionMember -CollectionName $Global:Collection_Name | select Name + #Set-Location c: + + Write-Host "Total Server Count: $($Script:ALL_Patch_Servers.count)" -ForegroundColor Green + Write-Host "" + + ############ + # $Script:Output.Text = "CollectionName: $($Global:Collection_Name) ------ hello " + ############ + $Script:DeviceCollection_ServerNames1.Name | % { + $Server = $_ + $Obj = New-Object -TypeName PSObject + + If (Test-Connection $Server -Count 1 -ErrorAction SilentlyContinue ) { + #Write-Host "Responding:---- $_ " -ForegroundColor Green + #$Script:Output.AppendText("Responding: $_") + + $Obj | Add-Member -MemberType NoteProperty -Name Server -Value $Server + $Obj | Add-Member -MemberType NoteProperty -Name Responding -Value "Yes" + $Ping_Result += $Obj + $Responding += $Server + }#endIf + + Else { + $Obj | Add-Member -MemberType NoteProperty -Name Server -Value $Server + $Obj | Add-Member -MemberType NoteProperty -Name Responding -Value "No!" + $Ping_Result += $Obj + $NotResponding += $Server + } + }#end% + $Script:Output.Text = $Ping_Result | ft -AutoSize | Out-String + + write-host "-------------------------------------------------------" + Write-host "$($Responding.count) / $($DeviceCollection_ServerNames1.count) -- Responding" -foregroundcolor Green + Write-host "$($NotResponding.count) / $($DeviceCollection_ServerNames1.count) -- NOT Responding" -foregroundcolor Red + + #Write-Host "Servers NOT Responding: $NotResponding " -ForegroundColor Red + + }#endFunction +############################################################################################################################################################# + Function Check_Uptime { + ConnectTo-SCCM + $Script:DeviceCollection_ServerNames1 = Get-CMCollectionMember -CollectionName $Global:Collection_Name | select Name + $Script:Output.Text = $Script:DeviceCollection_ServerNames1.name | % { gwmi win32_operatingsystem -ComputerName $_ -ErrorAction SilentlyContinue | select @{n="Server";e={$_.PSComputername}},@{n="LastReboot";e={$_.Converttodatetime($_.LastBootUpTime)}}} | sort LastBootup -descending | Out-String + + } + +############################################################################################################################################################# + Function Deployment-List { + Param($Deployment_History) + # SCCM-Module + $Global:Deployments = Get-CMDeployment | ? { $_.deploymenttime -gt ((Get-Date).AddDays(-"$Deployment_History")) } + + #$T | select ApplicationName,CollectionName,DeploymentTime,AssignmentID,SoftwareName | % { $Deployment_DropDownBox.Items.Add($_) } + $i = 0 + $Q = "" #@() + + $Global:Deployments.ApplicationName | % { $Script:Deployment_DropDownBox.Items.Add($_)} + <# + foreach ($D in $Deployments) { + $Q = $D.ApplicationName + "-------------------------------------------------------" + $D.CollectionName + + $Deployment_DropDownBox.Items.Add($Q) + $i++ + } + #> + + #$T.ApplicationName | % { $Deployment_DropDownBox.Items.Add($_) } + + }#endFunction +############################################################################################################################################################# + Function Deployed-to-Collections { + $T = $Global:Deployments | ? { $_.ApplicationName -eq "$($Script:Deployment_DropDownBox.text)" } | Select -ExpandProperty CollectionName + $Script:Collection_DropDownBox.Items.Clear() + $T | % { $Script:Collection_DropDownBox.Items.Add("$_")} + } + +############################################################################################################################################################# + Function Test-Service { + $T = Get-Service + $Script:Output.Text = $T | ft -AutoSize | Out-String + } +################################################################################################################## + +################################################################################################################## + # --End User Generated Script-- + #---------------------------------------------- + #region Generated Events + #---------------------------------------------- + + $Form_StateCorrection_Load= + { + #Correct the initial state of the form to prevent the .Net maximized form issue + $form1.WindowState = $InitialFormWindowState + } + + $Form_Cleanup_FormClosed= + { + #Remove all event handlers from the controls + try + { + $form1.remove_Load($form1_Load) + $form1.remove_Load($Form_StateCorrection_Load) + $form1.remove_FormClosed($Form_Cleanup_FormClosed) + + #$PanelEventLogs_Events.remove_Paint($PanelEventLogs_Events_Paint) + #$PanelEventLogs_Filter.remove_Paint($PanelEventLogs_Filter_Paint) + + $Text_Elogs_DaysBack.remove_TextChanged($Text_Elogs_DaysBack_TextChanged) + $Text_ELogs_ServerName.remove_TextChanged($Text_ELogs_ServerName_TextChanged) + $Text_ELogs_EventID.remove_TextChanged($Text_ELogs_EventID_TextChanged) + + $Script:Output.remove_TextChanged($Output_TextChanged) + $Script:Collection_DropDownBox.remove_SelectedIndexChanged($Script:Collection_DropDownBox_SelectedIndexChanged) + $Script:Deployment_DropDownBox.remove_SelectedIndexChanged($Script:Deployment_DropDownBox_SelectedIndexChanged) + $Script:Combobox_Tools.remove_SelectedIndexChanged($Script:Combobox_Tools_SelectedIndexChanged) + $Script:RadioButton_Window.remove_SelectedIndexChanged($Script:RadioButton_Window_SelectedIndexChanged) + $Script:RadioButton_GridView.remove_SelectedIndexChanged($Script:RadioButton_GridView_SelectedIndexChanged) + $Script:RadioButton_CSV.remove_SelectedIndexChanged($Script:RadioButton_CSV_SelectedIndexChanged) + $Button_Go.remove_Click($Button_Go_Click) + + } + catch { Out-Null <# Prevent PSScriptAnalyzer warning #> } + } + + + #$PanelEventLogs_Events_Paint=[System.Windows.Forms.PaintEventHandler]{ <#Event Argument: $_ = [System.Windows.Forms.PaintEventArgs]#> } + #$PanelEventLogs_Filter_Paint=[System.Windows.Forms.PaintEventHandler]{ } + + $Text_ELogs_ServerName_TextChanged={} + $Text_Elogs_DaysBack_TextChanged={} + + #endregion Generated Events + + #---------------------------------------------- + #region Generated Form Code + #---------------------------------------------- + # + # form1 + # + #$form1.Controls.Add($PanelEventLogs_Events) + #$form1.Controls.Add($PanelEventLogs_Filter) + + $form1.Controls.Add($Output) + $form1.Controls.Add($Script:Collection_DropDownBox) + $form1.Controls.Add($Script:Deployment_DropDownBox) + $form1.Controls.Add($Script:Combobox_Tools) + $form1.Controls.Add($GroupBox) + $form1.controls.Add($Script:RadioButton_Window) + $form1.controls.Add($Script:RadioButton_GridView) + $form1.Controls.Add($Script:RadioButton_CSV) + $form1.Controls.Add($Button_Go) + $form1.Controls.Add($Script:TextBox_CollectionName) + + + $form1.AutoScaleDimensions = '6, 13' + $form1.AutoScaleMode = 'Font' + $form1.ClientSize = '1000, 800' + $form1.Name = 'form1' + $form1.Text = 'Form' + $form1.add_Load($form1_Load) + #endregion Generated Form Code + + #---------------------------------------------- +<# + $PanelEventLogs_Events.Controls.Add($Text_ELogs_ServerName) + $PanelEventLogs_Events.Controls.Add($Button_ELogs_Connect) + $PanelEventLogs_Events.Controls.Add($Button_ELogs_View) + $PanelEventLogs_Events.Controls.Add($Combobox_EventLogs_LogsList) + $PanelEventLogs_Events.Controls.Add($VCenterUserPassword) + $PanelEventLogs_Events.Controls.Add($CheckBoxUseWindowsLogin) + $PanelEventLogs_Events.Controls.Add($labelVCenterUserName) + $PanelEventLogs_Events.Controls.Add($labelVCenterPassword) + $PanelEventLogs_Events.Controls.Add($Script:Collection_DropDownBox) + $PanelEventLogs_Events.BackColor = '153,153,153' + $PanelEventLogs_Events.Location = '6, 6' + $PanelEventLogs_Events.Name = 'panelEventLogs_Events' + $PanelEventLogs_Events.Size = '598, 56' + $PanelEventLogs_Events.TabIndex = 0 + $PanelEventLogs_Events.add_Paint($PanelEventLogs_Events_Paint) + + $PanelEventLogs_Filter.Controls.Add($Combobox_ELogsFilter_Level) + $PanelEventLogs_Filter.Controls.Add($Text_ELogs_EventID) + $PanelEventLogs_Filter.Controls.Add($Text_Elogs_DaysBack) + $PanelEventLogs_Filter.Controls.Add($label_ELogs_Level) + $PanelEventLogs_Filter.Controls.Add($label_ELogs_EventID) + $PanelEventLogs_Filter.Controls.Add($label_ELogs_DaysBack) + $PanelEventLogs_Filter.BackColor = '255,255,212' + $PanelEventLogs_Filter.Location = '6, 62' + $PanelEventLogs_Filter.Name = 'PanelEventLogs_Filter' + $PanelEventLogs_Filter.Size = '598, 56' + $PanelEventLogs_Filter.BorderStyle = 'FixedSingle' + $PanelEventLogs_Filter.TabIndex = 0 + $PanelEventLogs_Filter.add_Paint($PanelEventLogs_Filter_Paint) +#> + # + # $Text_ELogs_ServerName + <# + $Text_ELogs_ServerName.Location = '8, 26' + $Text_ELogs_ServerName.Name = '$Text_ELogs_ServerName' + $Text_ELogs_ServerName.Size = '100, 20' + $Text_ELogs_ServerName.text = "l2012" + $Text_ELogs_ServerName.TabIndex = 6 + $Text_ELogs_ServerName.add_TextChanged($Text_ELogs_ServerName_TextChanged) + # + # + # Text_ELogs_EventID + # + $Text_ELogs_EventID.Location = '115, 26' + $Text_ELogs_EventID.Name = 'Text_ELogs_EventID' + $Text_ELogs_EventID.Size = '40, 20' + $Text_ELogs_EventID.TabIndex = 7 + $Text_ELogs_EventID.add_TextChanged($Text_ELogs_EventID_TextChanged) + # + # Text_Elogs_DaysBack + # + $Text_Elogs_DaysBack.Location = '175, 26' + $Text_Elogs_DaysBack.Name = 'Text_Elogs_DaysBack' + $Text_Elogs_DaysBack.Size = '40, 20' + $Text_Elogs_DaysBack.TabIndex = 7 + $Text_Elogs_DaysBack.add_TextChanged($Text_Elogs_DaysBack_TextChanged) + #> + # Output + # + $Output.Location = '10, 250' + $Output.Multiline = $True + $Output.Name = 'Output' + $Output.ScrollBars = 'both' + $Output.Size = '965, 500' + $Output.Font = 'Consolas, 8.25pt' + $Output.WordWrap = $False + $Output.TabIndex = 5 + $Output.add_TextChanged($Output_TextChanged) + # + # ComboboxServiceStartMode + # + $Script:Collection_DropDownBox.FormattingEnabled = $True + $Script:Collection_DropDownBox.Location = '20, 80' + $Script:Collection_DropDownBox.Name = 'Script:Collection_DropDownBox' + $Script:Collection_DropDownBox.Size = '180, 20' + $Script:Collection_DropDownBox.TabIndex = 2 + $Script:Collection_DropDownBox.Text = '--Deployed to Collections--' + $Script:Collection_DropDownBox.add_SelectedIndexChanged($Script:Collection_DropDownBox_SelectedIndexChanged) + # + $Script:Deployment_DropDownBox.Location = '20,30' + #$Script:Deployment_DropDownBox.Size = New-Object System.Drawing.Size(580,50) + $Script:Deployment_DropDownBox.Size = '580,50' + #$Script:Deployment_DropDownBox.DropDownHeight = 200 + $Script:Deployment_DropDownBox.text = "----Select Deployment----" + #$Script:Deployment_DropDownBox.Visible = $false + $Script:Deployment_DropDownBox.add_SelectedIndexChanged($Script:Deployment_DropDownBox_SelectedIndexChanged) + # + #$Script:Combobox_Tools.Size = New-Object System.Drawing.Size(180,20) + #$Script:Combobox_Tools.DropDownHeight = 200 + $Script:Combobox_Tools.text = "----Select Tool----" + $Script:Combobox_Tools.Location = '20,170' + $Script:Combobox_Tools.Size = '180,10' + $Script:Combobox_Tools.add_SelectedIndexChanged($Script:Combobox_Tools_SelectedIndexChanged) + # + $groupBox.Location = '270,70' + $groupBox.size = New-Object System.Drawing.Size(150,90) + $groupBox.text = "Select Output:" + + $GroupBox.Controls.Add($Script:RadioButton_Window) + $GroupBox.Controls.Add($Script:RadioButton_GridView) + $GroupBox.Controls.Add($Script:RadioButton_CSV) + # + $Script:RadioButton_Window.Location = new-object System.Drawing.Point(15,15) + $Script:RadioButton_Window.size = New-Object System.Drawing.Size(130,20) + $Script:RadioButton_Window.Checked = $true + $Script:RadioButton_Window.Text = "Window" + #$Script:RadioButton_Window. + # + $Script:RadioButton_GridView.Location = new-object System.Drawing.Point(15,35) + $Script:RadioButton_GridView.size = New-Object System.Drawing.Size(80,20) + $Script:RadioButton_GridView.Checked = $False + $Script:RadioButton_GridView.Text = "GridView" + # + $Script:RadioButton_CSV.Location = new-object System.Drawing.Point(15,55) + $Script:RadioButton_CSV.size = New-Object System.Drawing.Size(80,20) + $Script:RadioButton_CSV.Checked = $False + $Script:RadioButton_CSV.Text = "CSV" + # + $Button_Go.Location = New-Object System.Drawing.Size(450,75) + $Button_Go.Size = New-Object System.Drawing.Size(110,80) + $Button_Go.Text = "Go" + #$Button_Go.Add_Click({temp}) + $Button_Go.Add_Click($Button_Go_Click) + # + $Script:TextBox_CollectionName.Left = 20; + $Script:TextBox_CollectionName.Top = 130; + $Script:TextBox_CollectionName.width = 200; + $Script:TextBox_CollectionName.Text = "Nabil - Test Collection" + # + ############################################################################ + Update-Dropdown1 + ConnectTo-SCCM + Deployment-List -Deployment_History 10 + $Script:Output.Text = "helloooooooo" + #cd c: + + + ############################################################################ + +#Save the initial state of the form + $InitialFormWindowState = $form1.WindowState + #Init the OnLoad event to correct the initial state of the form + $form1.add_Load($Form_StateCorrection_Load) + #Clean up the control events + $form1.add_FormClosed($Form_Cleanup_FormClosed) + #Show the Form + return $form1.ShowDialog() + +} #End Function + +#Call the form +Show-Form-Template_psf | Out-Null diff --git a/dump/SCCM-Tool/NA-Tool-GUI-5x.ps1 b/dump/SCCM-Tool/NA-Tool-GUI-5x.ps1 new file mode 100644 index 0000000..29b5e43 --- /dev/null +++ b/dump/SCCM-Tool/NA-Tool-GUI-5x.ps1 @@ -0,0 +1,693 @@ +#------------------------------------------------------------------------ +# Source File Information (DO NOT MODIFY) +# Source ID: 676f8db7-35c7-452d-b353-a4b40f26243a +# Source File: Form-Template.psf +#------------------------------------------------------------------------ +#region File Recovery Data (DO NOT MODIFY) +<#RecoveryData: +RAUAAB+LCAAAAAAABAC9VNtKwzAYvhd8h5Dr2oPd3AZtYXTuxtNwQ72TrP07o2lSknSzPr3p2g1x +QkHGKJSk+Q7/KQ0eIRFrkNWEaILMQlHBQ3xpezg6P0MoeJB0RTlhU8rgnuQQTYXMLxaQF4xosAuV +Bc4BpmEu3yHRSFcFhHheKQ25/Ux5KjbKrkWat4X+OrLQUxtKz3brx0JxyXQpIeRQakmYhWblktHk +BqqF+AAeLgcD0k/6V97I74E7HGHETSghzoyeh1HyRlkqDQ7HgmspmGoSNIHOpChA6qoljEst5glh +MKE58DoIA72ykOcHzg7aRb0TKWBTKq47OTGjwPWcfhnCwDU+/nDYSaqrjKNtap3YBXxqvG3bIfR6 +bbxb3K0gaav5Wq8DZ3vaNNNputlsxkpBbooPaqfTfqmiXCVCMro8QgMDZ6/626UZmVN4HH0sux3r +m3gaI0k2lK/+4+X6WT8bZJ6X9l3ik26vl5ydJKdYSDi+0X7bjHzg/PxrRt9OzyrdRAUAAA==#> +#endregion + +<# + .NOTES + -------------------------------------------------------------------------------- + Code generated by: SAPIEN Technologies, Inc., PowerShell Studio 2017 v5.4.141 + Generated on: 8/29/2017 11:53 AM + Generated by: Haidey2 + -------------------------------------------------------------------------------- + .DESCRIPTION + GUI script generated by PowerShell Studio 2017 +#> + + +#---------------------------------------------- +#region Application Functions +#---------------------------------------------- + +#endregion Application Functions + +#---------------------------------------------- +# Generated Form Function +#---------------------------------------------- +function Show-Form-Template_psf { + + #---------------------------------------------- + #region Import the Assemblies + #---------------------------------------------- + [void][reflection.assembly]::Load('System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') + [void][reflection.assembly]::Load('System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') + [void][reflection.assembly]::Load('System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') + #endregion Import Assemblies + + #---------------------------------------------- + #region Generated Form Objects + #---------------------------------------------- + [System.Windows.Forms.Application]::EnableVisualStyles() + $form1 = New-Object 'System.Windows.Forms.Form' + $InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState' + + + $Script:Output = New-Object System.Windows.Forms.TextBox + $Script:Collection_DropDownBox = New-Object System.Windows.Forms.ComboBox + $Script:Deployment_DropDownBox = New-Object System.Windows.Forms.ComboBox + $Script:Combobox_Tools = New-Object System.Windows.Forms.ComboBox + + $GroupBox = New-Object System.Windows.Forms.GroupBox + $GroupBox_Info = New-Object System.Windows.Forms.GroupBox + + $Script:RadioButton_Window = New-Object System.Windows.Forms.RadioButton + $Script:RadioButton_GridView = New-Object System.Windows.Forms.RadioButton + $Script:RadioButton_CSV = New-Object System.Windows.Forms.RadioButton + $Button_Go = New-Object System.Windows.Forms.Button + $Script:TextBox_CollectionName = New-Object “System.Windows.Forms.TextBox” + + #$PanelEventLogs_Events = New-Object 'System.Windows.Forms.Panel' + #$PanelEventLogs_Filter = New-Object 'System.Windows.Forms.Panel' + + + #$Text_ELogs_ServerName = New-Object 'System.Windows.Forms.TextBox' + #$Text_ELogs_EventID = New-Object 'System.Windows.Forms.TextBox' + #$Text_Elogs_DaysBack = New-Object 'System.Windows.Forms.TextBox' + + $label_CollectionName = New-Object 'System.Windows.Forms.Label' + $label_DeploymentName = New-Object 'System.Windows.Forms.Label' + $label_DeploymentTime = New-Object 'System.Windows.Forms.Label' + $label_DeviceCount = New-Object 'System.Windows.Forms.Label' + + + $Button_ELogs_Connect = New-Object 'System.Windows.Forms.Button' + + + + +# $Location = Split-Path $MyInvocation.MyCommand.Path -Parent + + $Script:ALL_Patch_Servers = @() + $Script:Responding = @() + $Script:NotResponding = @() + $Global:Collection_Name = "" + $Global:Select_Tool + $Global:Output_Type = "" + $Global:Deployments = "" + + #endregion Generated Form Objects + + #---------------------------------------------- + # User Generated Script + #---------------------------------------------- + + $form1_Load={ + #TODO: Initialize Form Controls here + + } + + $Script:Collection_DropDownBox_SelectedIndexChanged={ + + $Script:Output.Text = $Script:Collection_DropDownBox.Text + } + + $Script:Deployment_DropDownBox_SelectedIndexChanged={ + Deployed-to-Collections + $Script:Output.Text = $Script:Deployment_DropDownBox.Text + } + + $Script:Combobox_Tools_SelectedIndexChanged= { + $Script:Output.Text = $Script:Combobox_Tools.Text + } + + $Button_Go_Click = { + temp + #SCCM-Module + # $Global:Collection_Name = $Script:TextBox_CollectionName.Text #$Script:TextBox_CollectionName.Text + # $Global:Select_Tool = $Script:Combobox_Tools.Text + + + #$Output.Text = "$Global:Collection_Name --- $Global:Select_Tool " | Out-String + #$Output.Text = | Out-String + } + + +################################################################################################################## + Function ConnectTo-SCCM { + + If(!(Get-PSDrive).Name -ne "CCX") { + # + # Press 'F5' to run this script. Running this script will load the ConfigurationManager + # module for Windows PowerShell and will connect to the site. + # + # This script was auto-generated at '2/18/2021 10:12:39 AM'. + + # Uncomment the line below if running in an environment where script signing is + # required. + #Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process + + # Site configuration + $SiteCode = "CCX" # Site code + $ProviderMachineName = "PNCRASCCM001.ccx.carecentrix.com" # SMS Provider machine name + + # Customizations + $initParams = @{} + #$initParams.Add("Verbose", $true) # Uncomment this line to enable verbose logging + #$initParams.Add("ErrorAction", "Stop") # Uncomment this line to stop the script on any errors + + # Do not change anything below this line + + # Import the ConfigurationManager.psd1 module + if((Get-Module ConfigurationManager) -eq $null) { + Import-Module "$($ENV:SMS_ADMIN_UI_PATH)\..\ConfigurationManager.psd1" @initParams + } + + # Connect to the site's drive if it is not already present + if((Get-PSDrive -Name $SiteCode -PSProvider CMSite -ErrorAction SilentlyContinue) -eq $null) { + New-PSDrive -Name $SiteCode -PSProvider CMSite -Root $ProviderMachineName @initParams + } + + # Set the current location to be the site code. + Set-Location "$($SiteCode):\" @initParams + + #$Script:Output.Text = "inside connectoSCCM function" + }#endIf + }#endFunction +################################################################################################################## + Function SCCM-Module { + Write-Host "Inside SCCM function" -ForegroundColor Cyan + If(!(Get-PSDrive).Name -eq "sccm-drive") { + + Import-Module 'C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1' + New-PSDrive -Name SCCM-Drive -PSProvider "AdminUI.PS.Provider\CMSite" -Root "PNCRASCCM001.ccx.carecentrix.com" -Description "SCCM Site" + }#endIf + $Script:Output.Text | Get-PSDrive | ft -AutoSize | Out-String + CD sccm-drive: + }#endFunction +################################################################################################################## + Function Update-Dropdown1 { + # $Collections += $Script:Collection_DropDownBox.text + $Collections = @("Collection-Servers","Ping-Collection","Check_Uptime","Test-Service","Remotely Update Policy","Software Update Status","Test-Sccm") + $Collections | % { $Script:Combobox_Tools.Items.Add($_) } + } +################################################################################################################## + Function temp { + $Script:Output.Clear() + #$Script:Script:Output.text = $Script:Collection_DropDownBox.text | Out-String + + $Global:Collection_Name = $Script:TextBox_CollectionName.Text #$Script:TextBox_CollectionName.Text + $Global:Select_Tool = $Script:Combobox_Tools.Text + + + If ($Script:RadioButton_Window.Checked -eq $true) { $Global:Output_Type = "Window" <#; $Script:Output.Text = "Window_Radio1 Checked: $($Script:RadioButton_Window.Checked)" | Out-String #> } + ElseIf ($Script:RadioButton_GridView.Checked -eq $true) { $Global:Output_Type = "Gridview" <#; $Script:Output.Text = "Gridview_Radio2 Checked: $($Script:RadioButton_GridView.Checked)" | Out-String #> } + ElseIf ($Script:RadioButton_CSV.Checked -eq $true) { $Global:Output_Type = "Export" <#; $Script:Output.Text = "CSV_Radio3 Checked: $($Script:RadioButton_CSV.Checked)" | Out-String #> } + + + If($Global:Collection_Name -and $Global:Select_Tool) { + # If($Script:Collection_DropDownBox.text = "Tool1"){gcc} + Run-Tool + #$Script:TextBox_CollectionName.clear() + $Script:Collection_DropDownBox.text = "----Select Tool----" + #Clear-Variables + }#endIf + Else { #$T = { Write-Host "You must enter Collection Name ............!!" -ForegroundColor Red } + $Script:Output.SelectionColor = 'red' + $Script:Output.Text = "You must select 'Tool' and enter Collection Name............!!" + } + + Run-Defaults + }#endFunction + + + + +################################################################################################################## + Function Run-Tool { + + Switch($Global:Select_Tool) { + Collection-Servers { Collection-Servers; Write-Host "Tool Selected: $Global:Select_Tool" } + Ping-Collection { Ping_Collection } + Check_Uptime { Check_Uptime } + Test-Service { Test-Service } + Test-SCCM { SCCM-Module } + #"Remotely Update Policy" { $Script:Output.Text = Invoke-Expression $Location\Tool-Remotely-Restart-SCCMSyncCycle.ps1 | ft -AutoSize | Out-String } + "Remotely Update Policy" { $Script:Output.Text = Invoke-Expression $Location\Tool-Remotely-Restart-SCCMSyncCycle.ps1 | ft -AutoSize | Out-String } + "Software Update Status" { $Script:Output.Text = & "$Location\Tool-Get-SCCMSoftwareUpdateStatus.ps1" -Dep_ID 16778048 | ft -AutoSize | Out-String} + }#endSwitch + #Clear-Variables + }#endFunction +################################################################################################################## + Function Run-Defaults { + #$Script:TextBox_CollectionName.Text = "Nabil - Test Collection" + $Script:RadioButton_Window.Checked = $true + + <# + If(!$Location) { + $Location = Split-Path $MyInvocation.MyCommand.Path -Parent + } + #> + } +################################################################################################################## + Function xClear-Variables { + $Global:Collection_Name = "" + $Global:Select_Tool = "" + $Global:Output_Type = "" + + $Script:ALL_Patch_Servers = @() + } +################################################################################################################## + Function Display-Results { + #Param($Global:Output_Type,$Final_Result) + Write-Host "DisplayType: $($Global:Output_Type)" + Switch ($Global:Output_Type){ + + Window { $Script:Output.Text = $Script:ALL_Patch_Servers | Out-String} + Gridview { $Script:ALL_Patch_Servers | Out-GridView } + Export { $Script:ALL_Patch_Servers | Export-Csv -Path $Location\Results.csv -NoTypeInformation; ii $Location\Results.csv } + + }#endSwitch + + } +############################################################################################################################################################# + Function Collection-Servers { + #Param($Coll_Name) + + Write-Host "Collection:$Global:Collection_Name" + $Script:ALL_Patch_Servers = @() + + ConnectTo-SCCM + #SCCM-Module + #CD sccm-drive: + $Script:DeviceCollection_MemberCount = Get-CMDeviceCollection -Name $Global:Collection_Name | select Name,MemberCount + $Script:DeviceCollection_ServerNames = Get-CMCollectionMember -CollectionName $Global:Collection_Name | select Name,IsClient #| Export-Csv "E:\SCCM-Files\SCCM-Scripts\Files\$Global:Collection_Name.csv" -NoTypeInformation + #$ServerName = $DeviceCollection_ServerNames.Name + #Set-Location c: + + #$Script:Temp = Get-CMCollectionMember -CollectionName $Global:Collection_Name #| select Name,IsClient + + $Script:DeviceCollection_ServerNames | % { + $Obj = New-Object -TypeName PSObject + $Obj | Add-Member -MemberType NoteProperty -Name Server -Value $_.Name + $Obj | Add-Member -MemberType NoteProperty -Name ClientInstalled -Value $_.IsClient + $Obj | Add-Member -MemberType NoteProperty -Name CollectionName -Value $Global:Collection_Name + #$Obj | Add-Member -MemberType NoteProperty -Name CollectionMemberCount -Value {(Get-CMCollectionMember -Name $Global:Collection_Name).MemberCount} + + $Obj + $Script:ALL_Patch_Servers += $Obj + + }#end% + + # $Script:Output.Text = $Script:ALL_Patch_Servers | Out-String + Display-Results #-Final_Result $Script:ALL_Patch_Servers + Write-Host "$Script:ALL_Patch_Servers" + $Script:ALL_Patch_Servers | Export-Csv $Location\Current-Collection-Servers.csv -NoTypeInformation + + }#endFunction +############################################################################################################################################################# + Function Ping_Collection { + + $Ping_Result = @() + $NotResponding = @() + $Responding = @() + + ConnectTo-SCCM + #SCCM-Module + #CD sccm-drive: + $Script:DeviceCollection_ServerNames1 = Get-CMCollectionMember -CollectionName $Global:Collection_Name | select Name + #Set-Location c: + + Write-Host "Total Server Count: $($Script:ALL_Patch_Servers.count)" -ForegroundColor Green + Write-Host "" + + ############ + # $Script:Output.Text = "CollectionName: $($Global:Collection_Name) ------ hello " + ############ + $Script:DeviceCollection_ServerNames1.Name | % { + $Server = $_ + $Obj = New-Object -TypeName PSObject + + If (Test-Connection $Server -Count 1 -ErrorAction SilentlyContinue ) { + #Write-Host "Responding:---- $_ " -ForegroundColor Green + #$Script:Output.AppendText("Responding: $_") + + $Obj | Add-Member -MemberType NoteProperty -Name Server -Value $Server + $Obj | Add-Member -MemberType NoteProperty -Name Responding -Value "Yes" + $Ping_Result += $Obj + $Responding += $Server + }#endIf + + Else { + $Obj | Add-Member -MemberType NoteProperty -Name Server -Value $Server + $Obj | Add-Member -MemberType NoteProperty -Name Responding -Value "No!" + $Ping_Result += $Obj + $NotResponding += $Server + } + }#end% + $Script:Output.Text = $Ping_Result | ft -AutoSize | Out-String + + write-host "-------------------------------------------------------" + Write-host "$($Responding.count) / $($DeviceCollection_ServerNames1.count) -- Responding" -foregroundcolor Green + Write-host "$($NotResponding.count) / $($DeviceCollection_ServerNames1.count) -- NOT Responding" -foregroundcolor Red + + #Write-Host "Servers NOT Responding: $NotResponding " -ForegroundColor Red + + }#endFunction +############################################################################################################################################################# + Function Check_Uptime { + ConnectTo-SCCM + $Script:DeviceCollection_ServerNames1 = Get-CMCollectionMember -CollectionName $Global:Collection_Name | select Name + $Script:Output.Text = $Script:DeviceCollection_ServerNames1.name | % { gwmi win32_operatingsystem -ComputerName $_ -ErrorAction SilentlyContinue | select @{n="Server";e={$_.PSComputername}},@{n="LastReboot";e={$_.Converttodatetime($_.LastBootUpTime)}}} | sort LastBootup -descending | Out-String + + } + +############################################################################################################################################################# + Function Deployment-List { + Param($Deployment_History) + # SCCM-Module + $Global:Deployments = Get-CMDeployment | ? { $_.deploymenttime -gt ((Get-Date).AddDays(-"$Deployment_History")) } + + #$T | select ApplicationName,CollectionName,DeploymentTime,AssignmentID,SoftwareName | % { $Deployment_DropDownBox.Items.Add($_) } + $i = 0 + $Q = "" #@() + + $Global:Deployments.ApplicationName | % { $Script:Deployment_DropDownBox.Items.Add($_)} + <# + foreach ($D in $Deployments) { + $Q = $D.ApplicationName + "-------------------------------------------------------" + $D.CollectionName + + $Deployment_DropDownBox.Items.Add($Q) + $i++ + } + #> + + #$T.ApplicationName | % { $Deployment_DropDownBox.Items.Add($_) } + + }#endFunction +############################################################################################################################################################# + Function Deployed-to-Collections { + $T = $Global:Deployments | ? { $_.ApplicationName -eq "$($Script:Deployment_DropDownBox.text)" } | Select -ExpandProperty CollectionName + $Script:Collection_DropDownBox.Items.Clear() + $T | % { $Script:Collection_DropDownBox.Items.Add("$_")} + } + +############################################################################################################################################################# + Function Test-Service { + $T = Get-Service + $Script:Output.Text = $T | ft -AutoSize | Out-String + } +################################################################################################################## + +################################################################################################################## + # --End User Generated Script-- + #---------------------------------------------- + #region Generated Events + #---------------------------------------------- + + $Form_StateCorrection_Load= + { + #Correct the initial state of the form to prevent the .Net maximized form issue + $form1.WindowState = $InitialFormWindowState + } + + $Form_Cleanup_FormClosed= + { + #Remove all event handlers from the controls + try + { + $form1.remove_Load($form1_Load) + $form1.remove_Load($Form_StateCorrection_Load) + $form1.remove_FormClosed($Form_Cleanup_FormClosed) + + #$PanelEventLogs_Events.remove_Paint($PanelEventLogs_Events_Paint) + #$PanelEventLogs_Filter.remove_Paint($PanelEventLogs_Filter_Paint) + + $Text_Elogs_DaysBack.remove_TextChanged($Text_Elogs_DaysBack_TextChanged) + $Text_ELogs_ServerName.remove_TextChanged($Text_ELogs_ServerName_TextChanged) + $Text_ELogs_EventID.remove_TextChanged($Text_ELogs_EventID_TextChanged) + + $Script:Output.remove_TextChanged($Output_TextChanged) + $Script:Collection_DropDownBox.remove_SelectedIndexChanged($Script:Collection_DropDownBox_SelectedIndexChanged) + $Script:Deployment_DropDownBox.remove_SelectedIndexChanged($Script:Deployment_DropDownBox_SelectedIndexChanged) + $Script:Combobox_Tools.remove_SelectedIndexChanged($Script:Combobox_Tools_SelectedIndexChanged) + $Script:RadioButton_Window.remove_SelectedIndexChanged($Script:RadioButton_Window_SelectedIndexChanged) + $Script:RadioButton_GridView.remove_SelectedIndexChanged($Script:RadioButton_GridView_SelectedIndexChanged) + $Script:RadioButton_CSV.remove_SelectedIndexChanged($Script:RadioButton_CSV_SelectedIndexChanged) + $Button_Go.remove_Click($Button_Go_Click) + + } + catch { Out-Null <# Prevent PSScriptAnalyzer warning #> } + } + + + #$PanelEventLogs_Events_Paint=[System.Windows.Forms.PaintEventHandler]{ <#Event Argument: $_ = [System.Windows.Forms.PaintEventArgs]#> } + #$PanelEventLogs_Filter_Paint=[System.Windows.Forms.PaintEventHandler]{ } + + $Text_ELogs_ServerName_TextChanged={} + $Text_Elogs_DaysBack_TextChanged={} + + #endregion Generated Events + + #---------------------------------------------- + #region Generated Form Code + #---------------------------------------------- + # + # form1 + # + #$form1.Controls.Add($PanelEventLogs_Events) + #$form1.Controls.Add($PanelEventLogs_Filter) + + $form1.Controls.Add($Output) + $form1.Controls.Add($Script:Collection_DropDownBox) + $form1.Controls.Add($Script:Deployment_DropDownBox) + $form1.Controls.Add($Script:Combobox_Tools) + $form1.Controls.Add($GroupBox) + $form1.Controls.Add($GroupBox_Info) + $form1.controls.Add($Script:RadioButton_Window) + $form1.controls.Add($Script:RadioButton_GridView) + $form1.Controls.Add($Script:RadioButton_CSV) + $form1.Controls.Add($Button_Go) + $form1.Controls.Add($Script:TextBox_CollectionName) + $form1.Controls.Add($label_CollectionName) + $form1.Controls.Add($label_DeploymentName) + $form1.Controls.Add($label_DeploymentTime) + $form1.Controls.Add($label_DeviceCount) + + + $form1.AutoScaleDimensions = '6, 13' + $form1.AutoScaleMode = 'Font' + $form1.ClientSize = '1000, 800' + $form1.Name = 'form1' + $form1.Text = 'Form' + $form1.add_Load($form1_Load) + #endregion Generated Form Code + + #---------------------------------------------- +<# + $PanelEventLogs_Events.Controls.Add($Text_ELogs_ServerName) + $PanelEventLogs_Events.Controls.Add($Button_ELogs_Connect) + $PanelEventLogs_Events.Controls.Add($Button_ELogs_View) + $PanelEventLogs_Events.Controls.Add($Combobox_EventLogs_LogsList) + $PanelEventLogs_Events.Controls.Add($VCenterUserPassword) + $PanelEventLogs_Events.Controls.Add($CheckBoxUseWindowsLogin) + $PanelEventLogs_Events.Controls.Add($labelVCenterUserName) + $PanelEventLogs_Events.Controls.Add($labelVCenterPassword) + $PanelEventLogs_Events.Controls.Add($Script:Collection_DropDownBox) + $PanelEventLogs_Events.BackColor = '153,153,153' + $PanelEventLogs_Events.Location = '6, 6' + $PanelEventLogs_Events.Name = 'panelEventLogs_Events' + $PanelEventLogs_Events.Size = '598, 56' + $PanelEventLogs_Events.TabIndex = 0 + $PanelEventLogs_Events.add_Paint($PanelEventLogs_Events_Paint) + + $PanelEventLogs_Filter.Controls.Add($Combobox_ELogsFilter_Level) + $PanelEventLogs_Filter.Controls.Add($Text_ELogs_EventID) + $PanelEventLogs_Filter.Controls.Add($Text_Elogs_DaysBack) + $PanelEventLogs_Filter.Controls.Add($label_ELogs_Level) + $PanelEventLogs_Filter.Controls.Add($label_ELogs_EventID) + $PanelEventLogs_Filter.Controls.Add($label_ELogs_DaysBack) + $PanelEventLogs_Filter.BackColor = '255,255,212' + $PanelEventLogs_Filter.Location = '6, 62' + $PanelEventLogs_Filter.Name = 'PanelEventLogs_Filter' + $PanelEventLogs_Filter.Size = '598, 56' + $PanelEventLogs_Filter.BorderStyle = 'FixedSingle' + $PanelEventLogs_Filter.TabIndex = 0 + $PanelEventLogs_Filter.add_Paint($PanelEventLogs_Filter_Paint) +#> + # + # $Text_ELogs_ServerName + <# + $Text_ELogs_ServerName.Location = '8, 26' + $Text_ELogs_ServerName.Name = '$Text_ELogs_ServerName' + $Text_ELogs_ServerName.Size = '100, 20' + $Text_ELogs_ServerName.text = "l2012" + $Text_ELogs_ServerName.TabIndex = 6 + $Text_ELogs_ServerName.add_TextChanged($Text_ELogs_ServerName_TextChanged) + # + # + # Text_ELogs_EventID + # + $Text_ELogs_EventID.Location = '115, 26' + $Text_ELogs_EventID.Name = 'Text_ELogs_EventID' + $Text_ELogs_EventID.Size = '40, 20' + $Text_ELogs_EventID.TabIndex = 7 + $Text_ELogs_EventID.add_TextChanged($Text_ELogs_EventID_TextChanged) + # + # Text_Elogs_DaysBack + # + $Text_Elogs_DaysBack.Location = '175, 26' + $Text_Elogs_DaysBack.Name = 'Text_Elogs_DaysBack' + $Text_Elogs_DaysBack.Size = '40, 20' + $Text_Elogs_DaysBack.TabIndex = 7 + $Text_Elogs_DaysBack.add_TextChanged($Text_Elogs_DaysBack_TextChanged) + #> + # Output + # + $Output.Location = '10, 250' + $Output.Multiline = $True + $Output.Name = 'Output' + $Output.ScrollBars = 'both' + $Output.Size = '965, 500' + $Output.Font = 'Consolas, 8.25pt' + $Output.WordWrap = $False + $Output.TabIndex = 5 + $Output.add_TextChanged($Output_TextChanged) + # + # ComboboxServiceStartMode + # + $Script:Collection_DropDownBox.FormattingEnabled = $True + $Script:Collection_DropDownBox.Location = '20, 80' + $Script:Collection_DropDownBox.Name = 'Script:Collection_DropDownBox' + $Script:Collection_DropDownBox.Size = '180, 20' + $Script:Collection_DropDownBox.TabIndex = 2 + $Script:Collection_DropDownBox.Text = '--Deployed to Collections--' + $Script:Collection_DropDownBox.add_SelectedIndexChanged($Script:Collection_DropDownBox_SelectedIndexChanged) + # + $Script:Deployment_DropDownBox.Location = '20,30' + #$Script:Deployment_DropDownBox.Size = New-Object System.Drawing.Size(580,50) + $Script:Deployment_DropDownBox.Size = '580,50' + #$Script:Deployment_DropDownBox.DropDownHeight = 200 + $Script:Deployment_DropDownBox.text = "----Select Deployment----" + #$Script:Deployment_DropDownBox.Visible = $false + $Script:Deployment_DropDownBox.add_SelectedIndexChanged($Script:Deployment_DropDownBox_SelectedIndexChanged) + # + #$Script:Combobox_Tools.Size = New-Object System.Drawing.Size(180,20) + #$Script:Combobox_Tools.DropDownHeight = 200 + $Script:Combobox_Tools.text = "----Select Tool----!" + $Script:Combobox_Tools.Location = '20,170' + $Script:Combobox_Tools.Size = '180,10' + $Script:Combobox_Tools.add_SelectedIndexChanged($Script:Combobox_Tools_SelectedIndexChanged) + # + $groupBox.Location = '270,70' + $groupBox.size = New-Object System.Drawing.Size(150,90) + $groupBox.text = "Select Output:" + + + $GroupBox.Controls.Add($Script:RadioButton_Window) + $GroupBox.Controls.Add($Script:RadioButton_GridView) + $GroupBox.Controls.Add($Script:RadioButton_CSV) + # + $GroupBox_Info.Location = '670,25' + $GroupBox_Info.Size = '300,200' + $GroupBox_Info.Text = "Deployment Info" + ############ + $GroupBox_Info.Controls.Add($label_CollectionName) + $GroupBox_Info.Controls.Add($label_DeploymentName) + $GroupBox_Info.Controls.Add($label_DeploymentTime) + $GroupBox_Info.Controls.Add($label_DeviceCount) + ############ + $label_CollectionName.AutoSize = $True + $label_CollectionName.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_CollectionName.ForeColor = 'DarkGreen' + #$label_CollectionName.TextAlign = 'MiddleRight' + $label_CollectionName.Location = '20,25' + $label_CollectionName.Name = 'Collection_Name' + $label_CollectionName.Size = '41, 13' + #$label_CollectionName.TabIndex = 6 + $label_CollectionName.Text = 'Collection Name:' + #$label_CollectionName.add_Click($label_CollectionName_Click) + ############ + $label_DeploymentName.AutoSize = $True + $label_DeploymentName.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_DeploymentName.ForeColor = 'DarkGreen' + #$label_DeploymentName.TextAlign = 'MiddleRight' + $label_DeploymentName.Location = '20,45' + $label_DeploymentName.Name = 'Deployment_Name' + $label_DeploymentName.Size = '41, 13' + #$label_DeploymentName.TabIndex = 6 + $label_DeploymentName.Text = 'Deployment Name:' + #$label_DeploymentName.add_Click($label_DeploymentName_Click) + ############ + $label_DeploymentTime.AutoSize = $True + $label_DeploymentTime.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_DeploymentTime.ForeColor = 'DarkGreen' + #$label_DeploymentTime.TextAlign = 'MiddleRight' + $label_DeploymentTime.Location = '20,65' + $label_DeploymentTime.Name = 'Deployment_Time' + $label_DeploymentTime.Size = '41, 13' + #$label_DeploymentTime.TabIndex = 6 + $label_DeploymentTime.Text = 'Collection Name:' + #$label_DeploymentTime.add_Click($label_CollectionName_Click) + ############ + $label_DeviceCount.AutoSize = $True + $label_DeviceCount.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_DeviceCount.ForeColor = 'DarkGreen' + #$label_DeviceCount.TextAlign = 'MiddleRight' + $label_DeviceCount.Location = '20,85' + $label_DeviceCount.Name = 'Device_Count' + $label_DeviceCount.Size = '41, 13' + #$label_DeviceCount.TabIndex = 6 + $label_DeviceCount.Text = 'Device Count:' + #$label_DeviceCount.add_Click($label_DeviceCount_Click) + ############ + $Script:RadioButton_Window.Location = new-object System.Drawing.Point(15,15) + $Script:RadioButton_Window.size = New-Object System.Drawing.Size(130,20) + $Script:RadioButton_Window.Checked = $true + $Script:RadioButton_Window.Text = "Window" + #$Script:RadioButton_Window. + # + $Script:RadioButton_GridView.Location = new-object System.Drawing.Point(15,35) + $Script:RadioButton_GridView.size = New-Object System.Drawing.Size(80,20) + $Script:RadioButton_GridView.Checked = $False + $Script:RadioButton_GridView.Text = "GridView" + # + $Script:RadioButton_CSV.Location = new-object System.Drawing.Point(15,55) + $Script:RadioButton_CSV.size = New-Object System.Drawing.Size(80,20) + $Script:RadioButton_CSV.Checked = $False + $Script:RadioButton_CSV.Text = "CSV" + # + $Button_Go.Location = New-Object System.Drawing.Size(450,75) + $Button_Go.Size = New-Object System.Drawing.Size(110,80) + $Button_Go.Text = "Go" + #$Button_Go.Add_Click({temp}) + $Button_Go.Add_Click($Button_Go_Click) + # + $Script:TextBox_CollectionName.Left = 20; + $Script:TextBox_CollectionName.Top = 130; + $Script:TextBox_CollectionName.width = 200; + $Script:TextBox_CollectionName.Text = "Nabil - Test Collection" + # + ############################################################################ + Update-Dropdown1 + ConnectTo-SCCM + Deployment-List -Deployment_History 10 + $Script:Output.Text = "helloooooooo" + #cd c: + + + ############################################################################ + +#Save the initial state of the form + $InitialFormWindowState = $form1.WindowState + #Init the OnLoad event to correct the initial state of the form + $form1.add_Load($Form_StateCorrection_Load) + #Clean up the control events + $form1.add_FormClosed($Form_Cleanup_FormClosed) + #Show the Form + return $form1.ShowDialog() + +} #End Function + +#Call the form +Show-Form-Template_psf | Out-Null diff --git a/dump/SCCM-Tool/NA-Tool-GUI-6x.ps1 b/dump/SCCM-Tool/NA-Tool-GUI-6x.ps1 new file mode 100644 index 0000000..c0930f3 --- /dev/null +++ b/dump/SCCM-Tool/NA-Tool-GUI-6x.ps1 @@ -0,0 +1,713 @@ +#------------------------------------------------------------------------ +# Source File Information (DO NOT MODIFY) +# Source ID: 676f8db7-35c7-452d-b353-a4b40f26243a +# Source File: Form-Template.psf +#------------------------------------------------------------------------ +#region File Recovery Data (DO NOT MODIFY) +<#RecoveryData: +RAUAAB+LCAAAAAAABAC9VNtKwzAYvhd8h5Dr2oPd3AZtYXTuxtNwQ72TrP07o2lSknSzPr3p2g1x +QkHGKJSk+Q7/KQ0eIRFrkNWEaILMQlHBQ3xpezg6P0MoeJB0RTlhU8rgnuQQTYXMLxaQF4xosAuV +Bc4BpmEu3yHRSFcFhHheKQ25/Ux5KjbKrkWat4X+OrLQUxtKz3brx0JxyXQpIeRQakmYhWblktHk +BqqF+AAeLgcD0k/6V97I74E7HGHETSghzoyeh1HyRlkqDQ7HgmspmGoSNIHOpChA6qoljEst5glh +MKE58DoIA72ykOcHzg7aRb0TKWBTKq47OTGjwPWcfhnCwDU+/nDYSaqrjKNtap3YBXxqvG3bIfR6 +bbxb3K0gaav5Wq8DZ3vaNNNputlsxkpBbooPaqfTfqmiXCVCMro8QgMDZ6/626UZmVN4HH0sux3r +m3gaI0k2lK/+4+X6WT8bZJ6X9l3ik26vl5ydJKdYSDi+0X7bjHzg/PxrRt9OzyrdRAUAAA==#> +#endregion + +<# + .NOTES + -------------------------------------------------------------------------------- + Code generated by: SAPIEN Technologies, Inc., PowerShell Studio 2017 v5.4.141 + Generated on: 8/29/2017 11:53 AM + Generated by: Haidey2 + -------------------------------------------------------------------------------- + .DESCRIPTION + GUI script generated by PowerShell Studio 2017 +#> + + +#---------------------------------------------- +#region Application Functions +#---------------------------------------------- + +#endregion Application Functions + +#---------------------------------------------- +# Generated Form Function +#---------------------------------------------- +function Show-Form-Template_psf { + + #---------------------------------------------- + #region Import the Assemblies + #---------------------------------------------- + [void][reflection.assembly]::Load('System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') + [void][reflection.assembly]::Load('System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') + [void][reflection.assembly]::Load('System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') + #endregion Import Assemblies + + #---------------------------------------------- + #region Generated Form Objects + #---------------------------------------------- + [System.Windows.Forms.Application]::EnableVisualStyles() + $form1 = New-Object 'System.Windows.Forms.Form' + $InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState' + + + $Script:Output = New-Object System.Windows.Forms.TextBox + $Script:Collection_DropDownBox = New-Object System.Windows.Forms.ComboBox + $Script:Deployment_DropDownBox = New-Object System.Windows.Forms.ComboBox + $Script:Combobox_Tools = New-Object System.Windows.Forms.ComboBox + + $GroupBox = New-Object System.Windows.Forms.GroupBox + $GroupBox_Info = New-Object System.Windows.Forms.GroupBox + + $Script:RadioButton_Window = New-Object System.Windows.Forms.RadioButton + $Script:RadioButton_GridView = New-Object System.Windows.Forms.RadioButton + $Script:RadioButton_CSV = New-Object System.Windows.Forms.RadioButton + $Button_Go = New-Object System.Windows.Forms.Button + $Script:TextBox_CollectionName = New-Object “System.Windows.Forms.TextBox” + + #$PanelEventLogs_Events = New-Object 'System.Windows.Forms.Panel' + #$PanelEventLogs_Filter = New-Object 'System.Windows.Forms.Panel' + + + #$Text_ELogs_ServerName = New-Object 'System.Windows.Forms.TextBox' + #$Text_ELogs_EventID = New-Object 'System.Windows.Forms.TextBox' + #$Text_Elogs_DaysBack = New-Object 'System.Windows.Forms.TextBox' + + $label_CollectionName = New-Object 'System.Windows.Forms.Label' + $label_CollectionName_Value = New-Object 'System.Windows.Forms.Label' + $label_DeploymentName = New-Object 'System.Windows.Forms.Label' + $label_DeploymentTime = New-Object 'System.Windows.Forms.Label' + $label_DeviceCount = New-Object 'System.Windows.Forms.Label' + + + $Button_ELogs_Connect = New-Object 'System.Windows.Forms.Button' + + + + +# $Location = Split-Path $MyInvocation.MyCommand.Path -Parent + + $Script:ALL_Patch_Servers = @() + $Script:Responding = @() + $Script:NotResponding = @() + $Global:Collection_Name = "" + $Global:Select_Tool + $Global:Output_Type = "" + $Global:Deployments = "" + + #endregion Generated Form Objects + + #---------------------------------------------- + # User Generated Script + #---------------------------------------------- + + $form1_Load={ + #TODO: Initialize Form Controls here + + } + + $Script:Collection_DropDownBox_SelectedIndexChanged={ + + $Script:Output.Text = $Script:Collection_DropDownBox.Text + $T = Get-CMDeviceCollection -Name $Script:Collection_DropDownBox.text | select Name,MemberCount + $label_CollectionName_Value.Text = $T.MemberCount + + } + + $Script:Deployment_DropDownBox_SelectedIndexChanged={ + Deployed-to-Collections + $Script:Output.Text = $Script:Deployment_DropDownBox.Text + } + + $Script:Combobox_Tools_SelectedIndexChanged= { + $Script:Output.Text = $Script:Combobox_Tools.Text + + + } + + $Button_Go_Click = { + temp + #SCCM-Module + # $Global:Collection_Name = $Script:TextBox_CollectionName.Text #$Script:TextBox_CollectionName.Text + # $Global:Select_Tool = $Script:Combobox_Tools.Text + + + #$Output.Text = "$Global:Collection_Name --- $Global:Select_Tool " | Out-String + #$Output.Text = | Out-String + } + + +################################################################################################################## + Function ConnectTo-SCCM { + + If(!(Get-PSDrive).Name -ne "CCX") { + # + # Press 'F5' to run this script. Running this script will load the ConfigurationManager + # module for Windows PowerShell and will connect to the site. + # + # This script was auto-generated at '2/18/2021 10:12:39 AM'. + + # Uncomment the line below if running in an environment where script signing is + # required. + #Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process + + # Site configuration + $SiteCode = "CCX" # Site code + $ProviderMachineName = "PNCRASCCM001.ccx.carecentrix.com" # SMS Provider machine name + + # Customizations + $initParams = @{} + #$initParams.Add("Verbose", $true) # Uncomment this line to enable verbose logging + #$initParams.Add("ErrorAction", "Stop") # Uncomment this line to stop the script on any errors + + # Do not change anything below this line + + # Import the ConfigurationManager.psd1 module + if((Get-Module ConfigurationManager) -eq $null) { + Import-Module "$($ENV:SMS_ADMIN_UI_PATH)\..\ConfigurationManager.psd1" @initParams + } + + # Connect to the site's drive if it is not already present + if((Get-PSDrive -Name $SiteCode -PSProvider CMSite -ErrorAction SilentlyContinue) -eq $null) { + New-PSDrive -Name $SiteCode -PSProvider CMSite -Root $ProviderMachineName @initParams + } + + # Set the current location to be the site code. + Set-Location "$($SiteCode):\" @initParams + + #$Script:Output.Text = "inside connectoSCCM function" + }#endIf + }#endFunction +################################################################################################################## + Function SCCM-Module { + Write-Host "Inside SCCM function" -ForegroundColor Cyan + If(!(Get-PSDrive).Name -eq "sccm-drive") { + + Import-Module 'C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1' + New-PSDrive -Name SCCM-Drive -PSProvider "AdminUI.PS.Provider\CMSite" -Root "PNCRASCCM001.ccx.carecentrix.com" -Description "SCCM Site" + }#endIf + $Script:Output.Text | Get-PSDrive | ft -AutoSize | Out-String + CD sccm-drive: + }#endFunction +################################################################################################################## + Function Update-Dropdown1 { + # $Collections += $Script:Collection_DropDownBox.text + $Collections = @("Collection-Servers","Ping-Collection","Check_Uptime","Test-Service","Remotely Update Policy","Software Update Status","Test-Sccm") + $Collections | % { $Script:Combobox_Tools.Items.Add($_) } + } +################################################################################################################## + Function temp { + $Script:Output.Clear() + #$Script:Script:Output.text = $Script:Collection_DropDownBox.text | Out-String + + $Global:Collection_Name = $Script:TextBox_CollectionName.Text #$Script:TextBox_CollectionName.Text + $Global:Select_Tool = $Script:Combobox_Tools.Text + + + If ($Script:RadioButton_Window.Checked -eq $true) { $Global:Output_Type = "Window" <#; $Script:Output.Text = "Window_Radio1 Checked: $($Script:RadioButton_Window.Checked)" | Out-String #> } + ElseIf ($Script:RadioButton_GridView.Checked -eq $true) { $Global:Output_Type = "Gridview" <#; $Script:Output.Text = "Gridview_Radio2 Checked: $($Script:RadioButton_GridView.Checked)" | Out-String #> } + ElseIf ($Script:RadioButton_CSV.Checked -eq $true) { $Global:Output_Type = "Export" <#; $Script:Output.Text = "CSV_Radio3 Checked: $($Script:RadioButton_CSV.Checked)" | Out-String #> } + + + If($Global:Collection_Name -and $Global:Select_Tool) { + # If($Script:Collection_DropDownBox.text = "Tool1"){gcc} + Run-Tool + #$Script:TextBox_CollectionName.clear() + $Script:Collection_DropDownBox.text = "----Select Collection----" + #Clear-Variables + }#endIf + Else { #$T = { Write-Host "You must enter Collection Name ............!!" -ForegroundColor Red } + $Script:Output.SelectionColor = 'red' + $Script:Output.Text = "You must select 'Tool' and enter Collection Name............!!" + } + + Run-Defaults + }#endFunction + + + + +################################################################################################################## + Function Run-Tool { + + Switch($Global:Select_Tool) { + Collection-Servers { Collection-Servers; Write-Host "Tool Selected: $Global:Select_Tool" } + Ping-Collection { Ping_Collection } + Check_Uptime { Check_Uptime } + Test-Service { Test-Service } + Test-SCCM { SCCM-Module } + #"Remotely Update Policy" { $Script:Output.Text = Invoke-Expression $Location\Tool-Remotely-Restart-SCCMSyncCycle.ps1 | ft -AutoSize | Out-String } + "Remotely Update Policy" { $Script:Output.Text = Invoke-Expression $Location\Tool-Remotely-Restart-SCCMSyncCycle.ps1 | ft -AutoSize | Out-String } + "Software Update Status" { $Script:Output.Text = & "$Location\Tool-Get-SCCMSoftwareUpdateStatus.ps1" -Dep_ID 16778048 | ft -AutoSize | Out-String} + }#endSwitch + #Clear-Variables + }#endFunction +################################################################################################################## + Function Run-Defaults { + #$Script:TextBox_CollectionName.Text = "Nabil - Test Collection" + $Script:RadioButton_Window.Checked = $true + + <# + If(!$Location) { + $Location = Split-Path $MyInvocation.MyCommand.Path -Parent + } + #> + } +################################################################################################################## + Function xClear-Variables { + $Global:Collection_Name = "" + $Global:Select_Tool = "" + $Global:Output_Type = "" + + $Script:ALL_Patch_Servers = @() + } +################################################################################################################## + Function Display-Results { + #Param($Global:Output_Type,$Final_Result) + Write-Host "DisplayType: $($Global:Output_Type)" + Switch ($Global:Output_Type){ + + Window { $Script:Output.Text = $Script:ALL_Patch_Servers | Out-String} + Gridview { $Script:ALL_Patch_Servers | Out-GridView } + Export { $Script:ALL_Patch_Servers | Export-Csv -Path $Location\Results.csv -NoTypeInformation; ii $Location\Results.csv } + + }#endSwitch + + } +############################################################################################################################################################# + Function Collection-Servers { + #Param($Coll_Name) + + Write-Host "Collection:$Global:Collection_Name" + $Script:ALL_Patch_Servers = @() + + ConnectTo-SCCM + #SCCM-Module + #CD sccm-drive: + $Script:DeviceCollection_MemberCount = Get-CMDeviceCollection -Name $Global:Collection_Name | select Name,MemberCount + $Script:DeviceCollection_ServerNames = Get-CMCollectionMember -CollectionName $Global:Collection_Name | select Name,IsClient #| Export-Csv "E:\SCCM-Files\SCCM-Scripts\Files\$Global:Collection_Name.csv" -NoTypeInformation + #$ServerName = $DeviceCollection_ServerNames.Name + #Set-Location c: + + #$Script:Temp = Get-CMCollectionMember -CollectionName $Global:Collection_Name #| select Name,IsClient + + $Script:DeviceCollection_ServerNames | % { + $Obj = New-Object -TypeName PSObject + $Obj | Add-Member -MemberType NoteProperty -Name Server -Value $_.Name + $Obj | Add-Member -MemberType NoteProperty -Name ClientInstalled -Value $_.IsClient + $Obj | Add-Member -MemberType NoteProperty -Name CollectionName -Value $Global:Collection_Name + #$Obj | Add-Member -MemberType NoteProperty -Name CollectionMemberCount -Value {(Get-CMCollectionMember -Name $Global:Collection_Name).MemberCount} + + $Obj + $Script:ALL_Patch_Servers += $Obj + + }#end% + + # $Script:Output.Text = $Script:ALL_Patch_Servers | Out-String + Display-Results #-Final_Result $Script:ALL_Patch_Servers + Write-Host "$Script:ALL_Patch_Servers" + $Script:ALL_Patch_Servers | Export-Csv $Location\Current-Collection-Servers.csv -NoTypeInformation + + }#endFunction +############################################################################################################################################################# + Function Ping_Collection { + + $Ping_Result = @() + $NotResponding = @() + $Responding = @() + + ConnectTo-SCCM + #SCCM-Module + #CD sccm-drive: + $Script:DeviceCollection_ServerNames1 = Get-CMCollectionMember -CollectionName $Global:Collection_Name | select Name + #Set-Location c: + + Write-Host "Total Server Count: $($Script:ALL_Patch_Servers.count)" -ForegroundColor Green + Write-Host "" + + ############ + # $Script:Output.Text = "CollectionName: $($Global:Collection_Name) ------ hello " + ############ + $Script:DeviceCollection_ServerNames1.Name | % { + $Server = $_ + $Obj = New-Object -TypeName PSObject + + If (Test-Connection $Server -Count 1 -ErrorAction SilentlyContinue ) { + #Write-Host "Responding:---- $_ " -ForegroundColor Green + #$Script:Output.AppendText("Responding: $_") + + $Obj | Add-Member -MemberType NoteProperty -Name Server -Value $Server + $Obj | Add-Member -MemberType NoteProperty -Name Responding -Value "Yes" + $Ping_Result += $Obj + $Responding += $Server + }#endIf + + Else { + $Obj | Add-Member -MemberType NoteProperty -Name Server -Value $Server + $Obj | Add-Member -MemberType NoteProperty -Name Responding -Value "No!" + $Ping_Result += $Obj + $NotResponding += $Server + } + }#end% + $Script:Output.Text = $Ping_Result | ft -AutoSize | Out-String + + write-host "-------------------------------------------------------" + Write-host "$($Responding.count) / $($DeviceCollection_ServerNames1.count) -- Responding" -foregroundcolor Green + Write-host "$($NotResponding.count) / $($DeviceCollection_ServerNames1.count) -- NOT Responding" -foregroundcolor Red + + #Write-Host "Servers NOT Responding: $NotResponding " -ForegroundColor Red + + }#endFunction +############################################################################################################################################################# + Function Check_Uptime { + ConnectTo-SCCM + $Script:DeviceCollection_ServerNames1 = Get-CMCollectionMember -CollectionName $Global:Collection_Name | select Name + $Script:Output.Text = $Script:DeviceCollection_ServerNames1.name | % { gwmi win32_operatingsystem -ComputerName $_ -ErrorAction SilentlyContinue | select @{n="Server";e={$_.PSComputername}},@{n="LastReboot";e={$_.Converttodatetime($_.LastBootUpTime)}}} | sort LastBootup -descending | Out-String + + } + +############################################################################################################################################################# + Function Deployment-List { + Param($Deployment_History) + # SCCM-Module + $Global:Deployments = Get-CMDeployment | ? { $_.deploymenttime -gt ((Get-Date).AddDays(-"$Deployment_History")) } + + #$T | select ApplicationName,CollectionName,DeploymentTime,AssignmentID,SoftwareName | % { $Deployment_DropDownBox.Items.Add($_) } + $i = 0 + $Q = "" #@() + + $Global:Deployments.ApplicationName | % { $Script:Deployment_DropDownBox.Items.Add($_)} + <# + foreach ($D in $Deployments) { + $Q = $D.ApplicationName + "-------------------------------------------------------" + $D.CollectionName + + $Deployment_DropDownBox.Items.Add($Q) + $i++ + } + #> + + #$T.ApplicationName | % { $Deployment_DropDownBox.Items.Add($_) } + + }#endFunction +############################################################################################################################################################# + Function Deployed-to-Collections { + $T = $Global:Deployments | ? { $_.ApplicationName -eq "$($Script:Deployment_DropDownBox.text)" } | Select -ExpandProperty CollectionName + $Script:Collection_DropDownBox.Items.Clear() + $T | % { $Script:Collection_DropDownBox.Items.Add("$_")} + } + +############################################################################################################################################################# + Function Test-Service { + $T = Get-Service + $Script:Output.Text = $T | ft -AutoSize | Out-String + } +################################################################################################################## + +################################################################################################################## + # --End User Generated Script-- + #---------------------------------------------- + #region Generated Events + #---------------------------------------------- + + $Form_StateCorrection_Load= + { + #Correct the initial state of the form to prevent the .Net maximized form issue + $form1.WindowState = $InitialFormWindowState + } + + $Form_Cleanup_FormClosed= + { + #Remove all event handlers from the controls + try + { + $form1.remove_Load($form1_Load) + $form1.remove_Load($Form_StateCorrection_Load) + $form1.remove_FormClosed($Form_Cleanup_FormClosed) + + #$PanelEventLogs_Events.remove_Paint($PanelEventLogs_Events_Paint) + #$PanelEventLogs_Filter.remove_Paint($PanelEventLogs_Filter_Paint) + + $Text_Elogs_DaysBack.remove_TextChanged($Text_Elogs_DaysBack_TextChanged) + $Text_ELogs_ServerName.remove_TextChanged($Text_ELogs_ServerName_TextChanged) + $Text_ELogs_EventID.remove_TextChanged($Text_ELogs_EventID_TextChanged) + + $Script:Output.remove_TextChanged($Output_TextChanged) + $Script:Collection_DropDownBox.remove_SelectedIndexChanged($Script:Collection_DropDownBox_SelectedIndexChanged) + $Script:Deployment_DropDownBox.remove_SelectedIndexChanged($Script:Deployment_DropDownBox_SelectedIndexChanged) + $Script:Combobox_Tools.remove_SelectedIndexChanged($Script:Combobox_Tools_SelectedIndexChanged) + $Script:RadioButton_Window.remove_SelectedIndexChanged($Script:RadioButton_Window_SelectedIndexChanged) + $Script:RadioButton_GridView.remove_SelectedIndexChanged($Script:RadioButton_GridView_SelectedIndexChanged) + $Script:RadioButton_CSV.remove_SelectedIndexChanged($Script:RadioButton_CSV_SelectedIndexChanged) + $Button_Go.remove_Click($Button_Go_Click) + + } + catch { Out-Null <# Prevent PSScriptAnalyzer warning #> } + } + + + #$PanelEventLogs_Events_Paint=[System.Windows.Forms.PaintEventHandler]{ <#Event Argument: $_ = [System.Windows.Forms.PaintEventArgs]#> } + #$PanelEventLogs_Filter_Paint=[System.Windows.Forms.PaintEventHandler]{ } + + $Text_ELogs_ServerName_TextChanged={} + $Text_Elogs_DaysBack_TextChanged={} + + #endregion Generated Events + + #---------------------------------------------- + #region Generated Form Code + #---------------------------------------------- + # + # form1 + # + #$form1.Controls.Add($PanelEventLogs_Events) + #$form1.Controls.Add($PanelEventLogs_Filter) + + $form1.Controls.Add($Output) + $form1.Controls.Add($Script:Collection_DropDownBox) + $form1.Controls.Add($Script:Deployment_DropDownBox) + $form1.Controls.Add($Script:Combobox_Tools) + $form1.Controls.Add($GroupBox) + $form1.Controls.Add($GroupBox_Info) + $form1.controls.Add($Script:RadioButton_Window) + $form1.controls.Add($Script:RadioButton_GridView) + $form1.Controls.Add($Script:RadioButton_CSV) + $form1.Controls.Add($Button_Go) + $form1.Controls.Add($Script:TextBox_CollectionName) + $form1.Controls.Add($label_CollectionName) + $form1.Controls.Add($label_CollectionName_Value) + $form1.Controls.Add($label_DeploymentName) + $form1.Controls.Add($label_DeploymentTime) + $form1.Controls.Add($label_DeviceCount) + + + $form1.AutoScaleDimensions = '6, 13' + $form1.AutoScaleMode = 'Font' + $form1.ClientSize = '1000, 800' + $form1.Name = 'form1' + $form1.Text = 'Form' + $form1.add_Load($form1_Load) + #endregion Generated Form Code + + #---------------------------------------------- +<# + $PanelEventLogs_Events.Controls.Add($Text_ELogs_ServerName) + $PanelEventLogs_Events.Controls.Add($Button_ELogs_Connect) + $PanelEventLogs_Events.Controls.Add($Button_ELogs_View) + $PanelEventLogs_Events.Controls.Add($Combobox_EventLogs_LogsList) + $PanelEventLogs_Events.Controls.Add($VCenterUserPassword) + $PanelEventLogs_Events.Controls.Add($CheckBoxUseWindowsLogin) + $PanelEventLogs_Events.Controls.Add($labelVCenterUserName) + $PanelEventLogs_Events.Controls.Add($labelVCenterPassword) + $PanelEventLogs_Events.Controls.Add($Script:Collection_DropDownBox) + $PanelEventLogs_Events.BackColor = '153,153,153' + $PanelEventLogs_Events.Location = '6, 6' + $PanelEventLogs_Events.Name = 'panelEventLogs_Events' + $PanelEventLogs_Events.Size = '598, 56' + $PanelEventLogs_Events.TabIndex = 0 + $PanelEventLogs_Events.add_Paint($PanelEventLogs_Events_Paint) + + $PanelEventLogs_Filter.Controls.Add($Combobox_ELogsFilter_Level) + $PanelEventLogs_Filter.Controls.Add($Text_ELogs_EventID) + $PanelEventLogs_Filter.Controls.Add($Text_Elogs_DaysBack) + $PanelEventLogs_Filter.Controls.Add($label_ELogs_Level) + $PanelEventLogs_Filter.Controls.Add($label_ELogs_EventID) + $PanelEventLogs_Filter.Controls.Add($label_ELogs_DaysBack) + $PanelEventLogs_Filter.BackColor = '255,255,212' + $PanelEventLogs_Filter.Location = '6, 62' + $PanelEventLogs_Filter.Name = 'PanelEventLogs_Filter' + $PanelEventLogs_Filter.Size = '598, 56' + $PanelEventLogs_Filter.BorderStyle = 'FixedSingle' + $PanelEventLogs_Filter.TabIndex = 0 + $PanelEventLogs_Filter.add_Paint($PanelEventLogs_Filter_Paint) +#> + # + # $Text_ELogs_ServerName + <# + $Text_ELogs_ServerName.Location = '8, 26' + $Text_ELogs_ServerName.Name = '$Text_ELogs_ServerName' + $Text_ELogs_ServerName.Size = '100, 20' + $Text_ELogs_ServerName.text = "l2012" + $Text_ELogs_ServerName.TabIndex = 6 + $Text_ELogs_ServerName.add_TextChanged($Text_ELogs_ServerName_TextChanged) + # + # + # Text_ELogs_EventID + # + $Text_ELogs_EventID.Location = '115, 26' + $Text_ELogs_EventID.Name = 'Text_ELogs_EventID' + $Text_ELogs_EventID.Size = '40, 20' + $Text_ELogs_EventID.TabIndex = 7 + $Text_ELogs_EventID.add_TextChanged($Text_ELogs_EventID_TextChanged) + # + # Text_Elogs_DaysBack + # + $Text_Elogs_DaysBack.Location = '175, 26' + $Text_Elogs_DaysBack.Name = 'Text_Elogs_DaysBack' + $Text_Elogs_DaysBack.Size = '40, 20' + $Text_Elogs_DaysBack.TabIndex = 7 + $Text_Elogs_DaysBack.add_TextChanged($Text_Elogs_DaysBack_TextChanged) + #> + # Output + # + $Output.Location = '10, 250' + $Output.Multiline = $True + $Output.Name = 'Output' + $Output.ScrollBars = 'both' + $Output.Size = '965, 500' + $Output.Font = 'Consolas, 8.25pt' + $Output.WordWrap = $False + $Output.TabIndex = 5 + $Output.add_TextChanged($Output_TextChanged) + # + # ComboboxServiceStartMode + # + $Script:Collection_DropDownBox.FormattingEnabled = $True + $Script:Collection_DropDownBox.Location = '20, 80' + $Script:Collection_DropDownBox.Name = 'Script:Collection_DropDownBox' + $Script:Collection_DropDownBox.Size = '180, 20' + $Script:Collection_DropDownBox.TabIndex = 2 + $Script:Collection_DropDownBox.Text = '--Deployed to Collections--' + $Script:Collection_DropDownBox.add_SelectedIndexChanged($Script:Collection_DropDownBox_SelectedIndexChanged) + # + $Script:Deployment_DropDownBox.Location = '20,30' + #$Script:Deployment_DropDownBox.Size = New-Object System.Drawing.Size(580,50) + $Script:Deployment_DropDownBox.Size = '580,50' + #$Script:Deployment_DropDownBox.DropDownHeight = 200 + $Script:Deployment_DropDownBox.text = "----Select Deployment----" + #$Script:Deployment_DropDownBox.Visible = $false + $Script:Deployment_DropDownBox.add_SelectedIndexChanged($Script:Deployment_DropDownBox_SelectedIndexChanged) + # + #$Script:Combobox_Tools.Size = New-Object System.Drawing.Size(180,20) + #$Script:Combobox_Tools.DropDownHeight = 200 + $Script:Combobox_Tools.text = "----Select Tool----!" + $Script:Combobox_Tools.Location = '20,170' + $Script:Combobox_Tools.Size = '180,10' + $Script:Combobox_Tools.add_SelectedIndexChanged($Script:Combobox_Tools_SelectedIndexChanged) + # + $groupBox.Location = '270,70' + $groupBox.size = New-Object System.Drawing.Size(150,90) + $groupBox.text = "Select Output:" + + + $GroupBox.Controls.Add($Script:RadioButton_Window) + $GroupBox.Controls.Add($Script:RadioButton_GridView) + $GroupBox.Controls.Add($Script:RadioButton_CSV) + # + $GroupBox_Info.Location = '670,25' + $GroupBox_Info.Size = '300,200' + $GroupBox_Info.Text = "Deployment Info" + ############ + $GroupBox_Info.Controls.Add($label_CollectionName) + $GroupBox_Info.Controls.Add($label_CollectionName_Value) + $GroupBox_Info.Controls.Add($label_DeploymentName) + $GroupBox_Info.Controls.Add($label_DeploymentTime) + $GroupBox_Info.Controls.Add($label_DeviceCount) + ############ + $label_CollectionName.AutoSize = $True + $label_CollectionName.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + #$label_CollectionName.ForeColor = 'DarkGreen' + #$label_CollectionName.TextAlign = 'MiddleRight' + $label_CollectionName.Location = '20,25' + $label_CollectionName.Name = 'Collection_Name' + $label_CollectionName.Size = '41, 13' + #$label_CollectionName.TabIndex = 6 + $label_CollectionName.Text = 'Collection Name:' + #$label_CollectionName.add_Click($label_CollectionName_Click) + ############ + $label_CollectionName_Value.AutoSize = $True + $label_CollectionName_Value.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_CollectionName_Value.ForeColor = 'DarkGreen' + #$label_CollectionName_Value.TextAlign = 'MiddleRight' + $label_CollectionName_Value.Location = '130,25' + $label_CollectionName_Value.Name = 'Collection_Name_Value' + $label_CollectionName_Value.Size = '41, 13' + #$label_CollectionName_Value.TabIndex = 6 + $label_CollectionName_Value.Text = '_' + #$label_CollectionName_Value.add_Click($label_CollectionName_Value_Click) + + ############ + $label_DeploymentName.AutoSize = $True + $label_DeploymentName.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_DeploymentName.ForeColor = 'DarkGreen' + #$label_DeploymentName.TextAlign = 'MiddleRight' + $label_DeploymentName.Location = '20,45' + $label_DeploymentName.Name = 'Deployment_Name' + $label_DeploymentName.Size = '41, 13' + #$label_DeploymentName.TabIndex = 6 + $label_DeploymentName.Text = 'Deployment Name:' + #$label_DeploymentName.add_Click($label_DeploymentName_Click) + ############ + $label_DeploymentTime.AutoSize = $True + $label_DeploymentTime.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_DeploymentTime.ForeColor = 'DarkGreen' + #$label_DeploymentTime.TextAlign = 'MiddleRight' + $label_DeploymentTime.Location = '20,65' + $label_DeploymentTime.Name = 'Deployment_Time' + $label_DeploymentTime.Size = '41, 13' + #$label_DeploymentTime.TabIndex = 6 + $label_DeploymentTime.Text = 'Collection Name:' + #$label_DeploymentTime.add_Click($label_CollectionName_Click) + ############ + $label_DeviceCount.AutoSize = $True + $label_DeviceCount.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_DeviceCount.ForeColor = 'DarkGreen' + #$label_DeviceCount.TextAlign = 'MiddleRight' + $label_DeviceCount.Location = '20,85' + $label_DeviceCount.Name = 'Device_Count' + $label_DeviceCount.Size = '41, 13' + #$label_DeviceCount.TabIndex = 6 + $label_DeviceCount.Text = 'Device Count:' + #$label_DeviceCount.add_Click($label_DeviceCount_Click) + ############ + $Script:RadioButton_Window.Location = new-object System.Drawing.Point(15,15) + $Script:RadioButton_Window.size = New-Object System.Drawing.Size(130,20) + $Script:RadioButton_Window.Checked = $true + $Script:RadioButton_Window.Text = "Window" + #$Script:RadioButton_Window. + # + $Script:RadioButton_GridView.Location = new-object System.Drawing.Point(15,35) + $Script:RadioButton_GridView.size = New-Object System.Drawing.Size(80,20) + $Script:RadioButton_GridView.Checked = $False + $Script:RadioButton_GridView.Text = "GridView" + # + $Script:RadioButton_CSV.Location = new-object System.Drawing.Point(15,55) + $Script:RadioButton_CSV.size = New-Object System.Drawing.Size(80,20) + $Script:RadioButton_CSV.Checked = $False + $Script:RadioButton_CSV.Text = "CSV" + # + $Button_Go.Location = New-Object System.Drawing.Size(450,75) + $Button_Go.Size = New-Object System.Drawing.Size(110,80) + $Button_Go.Text = "Go" + #$Button_Go.Add_Click({temp}) + $Button_Go.Add_Click($Button_Go_Click) + # + $Script:TextBox_CollectionName.Left = 20; + $Script:TextBox_CollectionName.Top = 130; + $Script:TextBox_CollectionName.width = 200; + $Script:TextBox_CollectionName.Text = "Nabil - Test Collection" + # + ############################################################################ + Update-Dropdown1 + ConnectTo-SCCM + Deployment-List -Deployment_History 10 + $Script:Output.Text = "helloooooooo" + #cd c: + + + ############################################################################ + +#Save the initial state of the form + $InitialFormWindowState = $form1.WindowState + #Init the OnLoad event to correct the initial state of the form + $form1.add_Load($Form_StateCorrection_Load) + #Clean up the control events + $form1.add_FormClosed($Form_Cleanup_FormClosed) + #Show the Form + return $form1.ShowDialog() + +} #End Function + +#Call the form +Show-Form-Template_psf | Out-Null diff --git a/dump/SCCM-Tool/NA-Tool-GUI-7x.ps1 b/dump/SCCM-Tool/NA-Tool-GUI-7x.ps1 new file mode 100644 index 0000000..fb86d0d --- /dev/null +++ b/dump/SCCM-Tool/NA-Tool-GUI-7x.ps1 @@ -0,0 +1,770 @@ +#------------------------------------------------------------------------ +# Source File Information (DO NOT MODIFY) +# Source ID: 676f8db7-35c7-452d-b353-a4b40f26243a +# Source File: Form-Template.psf +#------------------------------------------------------------------------ +#region File Recovery Data (DO NOT MODIFY) +<#RecoveryData: +RAUAAB+LCAAAAAAABAC9VNtKwzAYvhd8h5Dr2oPd3AZtYXTuxtNwQ72TrP07o2lSknSzPr3p2g1x +QkHGKJSk+Q7/KQ0eIRFrkNWEaILMQlHBQ3xpezg6P0MoeJB0RTlhU8rgnuQQTYXMLxaQF4xosAuV +Bc4BpmEu3yHRSFcFhHheKQ25/Ux5KjbKrkWat4X+OrLQUxtKz3brx0JxyXQpIeRQakmYhWblktHk +BqqF+AAeLgcD0k/6V97I74E7HGHETSghzoyeh1HyRlkqDQ7HgmspmGoSNIHOpChA6qoljEst5glh +MKE58DoIA72ykOcHzg7aRb0TKWBTKq47OTGjwPWcfhnCwDU+/nDYSaqrjKNtap3YBXxqvG3bIfR6 +bbxb3K0gaav5Wq8DZ3vaNNNputlsxkpBbooPaqfTfqmiXCVCMro8QgMDZ6/626UZmVN4HH0sux3r +m3gaI0k2lK/+4+X6WT8bZJ6X9l3ik26vl5ydJKdYSDi+0X7bjHzg/PxrRt9OzyrdRAUAAA==#> +#endregion + +<# + .NOTES + -------------------------------------------------------------------------------- + Code generated by: SAPIEN Technologies, Inc., PowerShell Studio 2017 v5.4.141 + Generated on: 8/29/2017 11:53 AM + Generated by: Haidey2 + -------------------------------------------------------------------------------- + .DESCRIPTION + GUI script generated by PowerShell Studio 2017 +#> + + +#---------------------------------------------- +#region Application Functions +#---------------------------------------------- + +#endregion Application Functions + +#---------------------------------------------- +# Generated Form Function +#---------------------------------------------- +function Show-Form-Template_psf { + + #---------------------------------------------- + #region Import the Assemblies + #---------------------------------------------- + [void][reflection.assembly]::Load('System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') + [void][reflection.assembly]::Load('System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') + [void][reflection.assembly]::Load('System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') + #endregion Import Assemblies + + #---------------------------------------------- + #region Generated Form Objects + #---------------------------------------------- + [System.Windows.Forms.Application]::EnableVisualStyles() + $form1 = New-Object 'System.Windows.Forms.Form' + $InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState' + + + $Script:Output = New-Object System.Windows.Forms.TextBox + $Script:Collection_DropDownBox = New-Object System.Windows.Forms.ComboBox + $Script:Deployment_DropDownBox = New-Object System.Windows.Forms.ComboBox + $Script:Combobox_Tools = New-Object System.Windows.Forms.ComboBox + + $GroupBox = New-Object System.Windows.Forms.GroupBox + $GroupBox_Info = New-Object System.Windows.Forms.GroupBox + + $Script:RadioButton_Window = New-Object System.Windows.Forms.RadioButton + $Script:RadioButton_GridView = New-Object System.Windows.Forms.RadioButton + $Script:RadioButton_CSV = New-Object System.Windows.Forms.RadioButton + $Button_Go = New-Object System.Windows.Forms.Button + $Script:TextBox_CollectionName = New-Object “System.Windows.Forms.TextBox” + + #$PanelEventLogs_Events = New-Object 'System.Windows.Forms.Panel' + #$PanelEventLogs_Filter = New-Object 'System.Windows.Forms.Panel' + + + #$Text_ELogs_ServerName = New-Object 'System.Windows.Forms.TextBox' + #$Text_ELogs_EventID = New-Object 'System.Windows.Forms.TextBox' + #$Text_Elogs_DaysBack = New-Object 'System.Windows.Forms.TextBox' + + $label_CollectionName = New-Object 'System.Windows.Forms.Label' + $label_CollectionName_Value = New-Object 'System.Windows.Forms.Label' + $label_DeploymentName = New-Object 'System.Windows.Forms.Label' + $label_DeploymentName_Value = New-Object 'System.Windows.Forms.Label' + $label_DeploymentTime = New-Object 'System.Windows.Forms.Label' + $label_DeploymentTime_Value = New-Object 'System.Windows.Forms.Label' + $label_DeviceCount = New-Object 'System.Windows.Forms.Label' + $label_DeviceCount_Value = New-Object 'System.Windows.Forms.Label' + + $Button_ELogs_Connect = New-Object 'System.Windows.Forms.Button' + + + + +# $Location = Split-Path $MyInvocation.MyCommand.Path -Parent + + $Script:ALL_Patch_Servers = @() + $Script:Responding = @() + $Script:NotResponding = @() + $Global:Collection_Name = "" + $Global:Select_Tool + $Global:Output_Type = "" + $Global:Deployments = "" + + #endregion Generated Form Objects + + #---------------------------------------------- + # User Generated Script + #---------------------------------------------- + + $form1_Load={ + #TODO: Initialize Form Controls here + + } + + $Script:Collection_DropDownBox_SelectedIndexChanged={ + + $Script:Output.Text = $Script:Collection_DropDownBox.Text + $T = Get-CMDeviceCollection -Name $Script:Collection_DropDownBox.text | select Name,MemberCount + + $label_CollectionName_Value.Text = $T.MemberCount + + } + + $Script:Deployment_DropDownBox_SelectedIndexChanged={ + Reset-Forms -Form_Selection 1 + Deployed-to-Collections + $Script:Output.Text = $Script:Deployment_DropDownBox.Text + } + + $Script:Combobox_Tools_SelectedIndexChanged= { + $Script:Output.Text = $Script:Combobox_Tools.Text + + + } + + $Button_Go_Click = { + temp + #SCCM-Module + # $Global:Collection_Name = $Script:TextBox_CollectionName.Text #$Script:TextBox_CollectionName.Text + # $Global:Select_Tool = $Script:Combobox_Tools.Text + + + #$Output.Text = "$Global:Collection_Name --- $Global:Select_Tool " | Out-String + #$Output.Text = | Out-String + } + + +################################################################################################################## + Function ConnectTo-SCCM { + + If(!(Get-PSDrive).Name -ne "CCX") { + # + # Press 'F5' to run this script. Running this script will load the ConfigurationManager + # module for Windows PowerShell and will connect to the site. + # + # This script was auto-generated at '2/18/2021 10:12:39 AM'. + + # Uncomment the line below if running in an environment where script signing is + # required. + #Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process + + # Site configuration + $SiteCode = "CCX" # Site code + $ProviderMachineName = "PNCRASCCM001.ccx.carecentrix.com" # SMS Provider machine name + + # Customizations + $initParams = @{} + #$initParams.Add("Verbose", $true) # Uncomment this line to enable verbose logging + #$initParams.Add("ErrorAction", "Stop") # Uncomment this line to stop the script on any errors + + # Do not change anything below this line + + # Import the ConfigurationManager.psd1 module + if((Get-Module ConfigurationManager) -eq $null) { + Import-Module "$($ENV:SMS_ADMIN_UI_PATH)\..\ConfigurationManager.psd1" @initParams + } + + # Connect to the site's drive if it is not already present + if((Get-PSDrive -Name $SiteCode -PSProvider CMSite -ErrorAction SilentlyContinue) -eq $null) { + New-PSDrive -Name $SiteCode -PSProvider CMSite -Root $ProviderMachineName @initParams + } + + # Set the current location to be the site code. + Set-Location "$($SiteCode):\" @initParams + + #$Script:Output.Text = "inside connectoSCCM function" + }#endIf + }#endFunction +################################################################################################################## + Function SCCM-Module { + Write-Host "Inside SCCM function" -ForegroundColor Cyan + If(!(Get-PSDrive).Name -eq "sccm-drive") { + + Import-Module 'C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1' + New-PSDrive -Name SCCM-Drive -PSProvider "AdminUI.PS.Provider\CMSite" -Root "PNCRASCCM001.ccx.carecentrix.com" -Description "SCCM Site" + }#endIf + $Script:Output.Text | Get-PSDrive | ft -AutoSize | Out-String + CD sccm-drive: + }#endFunction +################################################################################################################## + Function Update-Dropdown1 { + # $Collections += $Script:Collection_DropDownBox.text + $Collections = @("Collection-Servers","Ping-Collection","Check_Uptime","Test-Service","Remotely Update Policy","Software Update Status","Test-Sccm") + $Collections | % { $Script:Combobox_Tools.Items.Add($_) } + } +################################################################################################################## + Function Reset-Forms { + Param($Form_Selection) + + Switch ($Form_Selection) { + 1 { $Collection_DropDownBox.Items.Clear(); $Collection_DropDownBox.Text = "--Deployed to Collections--" } + 2 {} + + } + + } +################################################################################################################## + Function temp { + $Script:Output.Clear() + #$Script:Script:Output.text = $Script:Collection_DropDownBox.text | Out-String + + #$Global:Collection_Name = $Script:TextBox_CollectionName.Text #$Script:TextBox_CollectionName.Text + $Global:Collection_Name = $Script:Collection_DropDownBox.Text + $Global:Select_Tool = $Script:Combobox_Tools.Text + + + If ($Script:RadioButton_Window.Checked -eq $true) { $Global:Output_Type = "Window" <#; $Script:Output.Text = "Window_Radio1 Checked: $($Script:RadioButton_Window.Checked)" | Out-String #> } + ElseIf ($Script:RadioButton_GridView.Checked -eq $true) { $Global:Output_Type = "Gridview" <#; $Script:Output.Text = "Gridview_Radio2 Checked: $($Script:RadioButton_GridView.Checked)" | Out-String #> } + ElseIf ($Script:RadioButton_CSV.Checked -eq $true) { $Global:Output_Type = "Export" <#; $Script:Output.Text = "CSV_Radio3 Checked: $($Script:RadioButton_CSV.Checked)" | Out-String #> } + + + If($Global:Collection_Name -and $Global:Select_Tool) { + # If($Script:Collection_DropDownBox.text = "Tool1"){gcc} + Run-Tool + #$Script:TextBox_CollectionName.clear() + $Script:Collection_DropDownBox.text = "----Select Collection----" + #Clear-Variables + }#endIf + Else { #$T = { Write-Host "You must enter Collection Name ............!!" -ForegroundColor Red } + $Script:Output.SelectionColor = 'red' + $Script:Output.Text = "You must select 'Tool' and enter Collection Name............!!" + } + + Run-Defaults + }#endFunction +################################################################################################################## + Function Run-Tool { + + Switch($Global:Select_Tool) { + Collection-Servers { Collection-Servers; Write-Host "Tool Selected: $Global:Select_Tool" } + Ping-Collection { Ping_Collection } + Check_Uptime { Check_Uptime } + Test-Service { Test-Service } + Test-SCCM { SCCM-Module } + #"Remotely Update Policy" { $Script:Output.Text = Invoke-Expression $Location\Tool-Remotely-Restart-SCCMSyncCycle.ps1 | ft -AutoSize | Out-String } + "Remotely Update Policy" { $Script:Output.Text = Invoke-Expression $Location\Tool-Remotely-Restart-SCCMSyncCycle.ps1 | ft -AutoSize | Out-String } + "Software Update Status" { $Script:Output.Text = & "$Location\Tool-Get-SCCMSoftwareUpdateStatus.ps1" -Dep_ID 16778048 | ft -AutoSize | Out-String} + }#endSwitch + #Clear-Variables + }#endFunction +################################################################################################################## + Function Run-Defaults { + #$Script:TextBox_CollectionName.Text = "Nabil - Test Collection" + $Script:RadioButton_Window.Checked = $true + + <# + If(!$Location) { + $Location = Split-Path $MyInvocation.MyCommand.Path -Parent + } + #> + } +################################################################################################################## + Function xClear-Variables { + $Global:Collection_Name = "" + $Global:Select_Tool = "" + $Global:Output_Type = "" + + $Script:ALL_Patch_Servers = @() + } +################################################################################################################## + Function Display-Results { + #Param($Global:Output_Type,$Final_Result) + Write-Host "DisplayType: $($Global:Output_Type)" + Switch ($Global:Output_Type){ + + Window { $Script:Output.Text = $Script:ALL_Patch_Servers | Out-String} + Gridview { $Script:ALL_Patch_Servers | Out-GridView } + Export { $Script:ALL_Patch_Servers | Export-Csv -Path $Location\Results.csv -NoTypeInformation; ii $Location\Results.csv } + + }#endSwitch + + } +############################################################################################################################################################# + Function Collection-Servers { + #Param($Coll_Name) + + Write-Host "Collection:$Global:Collection_Name" + $Script:ALL_Patch_Servers = @() + + ConnectTo-SCCM + #SCCM-Module + #CD sccm-drive: + $Script:DeviceCollection_MemberCount = Get-CMDeviceCollection -Name $Global:Collection_Name | select Name,MemberCount + $Script:DeviceCollection_ServerNames = Get-CMCollectionMember -CollectionName $Global:Collection_Name | select Name,IsClient #| Export-Csv "E:\SCCM-Files\SCCM-Scripts\Files\$Global:Collection_Name.csv" -NoTypeInformation + #$ServerName = $DeviceCollection_ServerNames.Name + #Set-Location c: + + #$Script:Temp = Get-CMCollectionMember -CollectionName $Global:Collection_Name #| select Name,IsClient + + $Script:DeviceCollection_ServerNames | % { + $Obj = New-Object -TypeName PSObject + $Obj | Add-Member -MemberType NoteProperty -Name Server -Value $_.Name + $Obj | Add-Member -MemberType NoteProperty -Name ClientInstalled -Value $_.IsClient + $Obj | Add-Member -MemberType NoteProperty -Name CollectionName -Value $Global:Collection_Name + #$Obj | Add-Member -MemberType NoteProperty -Name CollectionMemberCount -Value {(Get-CMCollectionMember -Name $Global:Collection_Name).MemberCount} + + $Obj + $Script:ALL_Patch_Servers += $Obj + + }#end% + + # $Script:Output.Text = $Script:ALL_Patch_Servers | Out-String + Display-Results #-Final_Result $Script:ALL_Patch_Servers + Write-Host "$Script:ALL_Patch_Servers" + $Script:ALL_Patch_Servers | Export-Csv $Location\Current-Collection-Servers.csv -NoTypeInformation + + }#endFunction +############################################################################################################################################################# + Function Ping_Collection { + + $Ping_Result = @() + $NotResponding = @() + $Responding = @() + + ConnectTo-SCCM + #SCCM-Module + #CD sccm-drive: + $Script:DeviceCollection_ServerNames1 = Get-CMCollectionMember -CollectionName $Global:Collection_Name | select Name + #Set-Location c: + + Write-Host "Total Server Count: $($Script:ALL_Patch_Servers.count)" -ForegroundColor Green + Write-Host "" + + ############ + # $Script:Output.Text = "CollectionName: $($Global:Collection_Name) ------ hello " + ############ + $Script:DeviceCollection_ServerNames1.Name | % { + $Server = $_ + $Obj = New-Object -TypeName PSObject + + If (Test-Connection $Server -Count 1 -ErrorAction SilentlyContinue ) { + #Write-Host "Responding:---- $_ " -ForegroundColor Green + #$Script:Output.AppendText("Responding: $_") + + $Obj | Add-Member -MemberType NoteProperty -Name Server -Value $Server + $Obj | Add-Member -MemberType NoteProperty -Name Responding -Value "Yes" + $Ping_Result += $Obj + $Responding += $Server + }#endIf + + Else { + $Obj | Add-Member -MemberType NoteProperty -Name Server -Value $Server + $Obj | Add-Member -MemberType NoteProperty -Name Responding -Value "No!" + $Ping_Result += $Obj + $NotResponding += $Server + } + }#end% + $Script:Output.Text = $Ping_Result | ft -AutoSize | Out-String + + write-host "-------------------------------------------------------" + Write-host "$($Responding.count) / $($DeviceCollection_ServerNames1.count) -- Responding" -foregroundcolor Green + Write-host "$($NotResponding.count) / $($DeviceCollection_ServerNames1.count) -- NOT Responding" -foregroundcolor Red + + #Write-Host "Servers NOT Responding: $NotResponding " -ForegroundColor Red + + }#endFunction +############################################################################################################################################################# + Function Check_Uptime { + ConnectTo-SCCM + $Script:DeviceCollection_ServerNames1 = Get-CMCollectionMember -CollectionName $Global:Collection_Name | select Name + $Script:Output.Text = $Script:DeviceCollection_ServerNames1.name | % { gwmi win32_operatingsystem -ComputerName $_ -ErrorAction SilentlyContinue | select @{n="Server";e={$_.PSComputername}},@{n="LastReboot";e={$_.Converttodatetime($_.LastBootUpTime)}}} | sort LastBootup -descending | Out-String + + } + +############################################################################################################################################################# + Function Deployment-List { + Param($Deployment_History) + # SCCM-Module + $Global:Deployments = Get-CMDeployment | ? { $_.deploymenttime -gt ((Get-Date).AddDays(-"$Deployment_History")) } + + #$T | select ApplicationName,CollectionName,DeploymentTime,AssignmentID,SoftwareName | % { $Deployment_DropDownBox.Items.Add($_) } + $i = 0 + $Q = "" #@() + + $Global:Deployments.ApplicationName | % { $Script:Deployment_DropDownBox.Items.Add($_)} + <# + foreach ($D in $Deployments) { + $Q = $D.ApplicationName + "-------------------------------------------------------" + $D.CollectionName + + $Deployment_DropDownBox.Items.Add($Q) + $i++ + } + #> + + #$T.ApplicationName | % { $Deployment_DropDownBox.Items.Add($_) } + + }#endFunction +############################################################################################################################################################# + Function Deployed-to-Collections { + $T = $Global:Deployments | ? { $_.ApplicationName -eq "$($Script:Deployment_DropDownBox.text)" } | Select -ExpandProperty CollectionName + $Script:Collection_DropDownBox.Items.Clear() + $T | % { $Script:Collection_DropDownBox.Items.Add("$_")} + } + +############################################################################################################################################################# + Function Test-Service { + $T = Get-Service + $Script:Output.Text = $T | ft -AutoSize | Out-String + } +################################################################################################################## + +################################################################################################################## + # --End User Generated Script-- + #---------------------------------------------- + #region Generated Events + #---------------------------------------------- + + $Form_StateCorrection_Load= + { + #Correct the initial state of the form to prevent the .Net maximized form issue + $form1.WindowState = $InitialFormWindowState + } + + $Form_Cleanup_FormClosed= + { + #Remove all event handlers from the controls + try + { + $form1.remove_Load($form1_Load) + $form1.remove_Load($Form_StateCorrection_Load) + $form1.remove_FormClosed($Form_Cleanup_FormClosed) + + #$PanelEventLogs_Events.remove_Paint($PanelEventLogs_Events_Paint) + #$PanelEventLogs_Filter.remove_Paint($PanelEventLogs_Filter_Paint) + + $Text_Elogs_DaysBack.remove_TextChanged($Text_Elogs_DaysBack_TextChanged) + $Text_ELogs_ServerName.remove_TextChanged($Text_ELogs_ServerName_TextChanged) + $Text_ELogs_EventID.remove_TextChanged($Text_ELogs_EventID_TextChanged) + + $Script:Output.remove_TextChanged($Output_TextChanged) + $Script:Collection_DropDownBox.remove_SelectedIndexChanged($Script:Collection_DropDownBox_SelectedIndexChanged) + $Script:Deployment_DropDownBox.remove_SelectedIndexChanged($Script:Deployment_DropDownBox_SelectedIndexChanged) + $Script:Combobox_Tools.remove_SelectedIndexChanged($Script:Combobox_Tools_SelectedIndexChanged) + $Script:RadioButton_Window.remove_SelectedIndexChanged($Script:RadioButton_Window_SelectedIndexChanged) + $Script:RadioButton_GridView.remove_SelectedIndexChanged($Script:RadioButton_GridView_SelectedIndexChanged) + $Script:RadioButton_CSV.remove_SelectedIndexChanged($Script:RadioButton_CSV_SelectedIndexChanged) + $Button_Go.remove_Click($Button_Go_Click) + + } + catch { Out-Null <# Prevent PSScriptAnalyzer warning #> } + } + + + #$PanelEventLogs_Events_Paint=[System.Windows.Forms.PaintEventHandler]{ <#Event Argument: $_ = [System.Windows.Forms.PaintEventArgs]#> } + #$PanelEventLogs_Filter_Paint=[System.Windows.Forms.PaintEventHandler]{ } + + $Text_ELogs_ServerName_TextChanged={} + $Text_Elogs_DaysBack_TextChanged={} + + #endregion Generated Events + + #---------------------------------------------- + #region Generated Form Code + #---------------------------------------------- + # + # form1 + # + #$form1.Controls.Add($PanelEventLogs_Events) + #$form1.Controls.Add($PanelEventLogs_Filter) + + $form1.Controls.Add($Output) + $form1.Controls.Add($Script:Collection_DropDownBox) + $form1.Controls.Add($Script:Deployment_DropDownBox) + $form1.Controls.Add($Script:Combobox_Tools) + $form1.Controls.Add($GroupBox) + $form1.Controls.Add($GroupBox_Info) + $form1.controls.Add($Script:RadioButton_Window) + $form1.controls.Add($Script:RadioButton_GridView) + $form1.Controls.Add($Script:RadioButton_CSV) + $form1.Controls.Add($Button_Go) + $form1.Controls.Add($Script:TextBox_CollectionName) + $form1.Controls.Add($label_CollectionName) + $form1.Controls.Add($label_CollectionName_Value) + $form1.Controls.Add($label_DeploymentName) + $form1.controls.Add($label_DeploymentName_Value) + $form1.Controls.Add($label_DeploymentTime) + $form1.Controls.Add($label_DeploymentTime_Value) + $form1.Controls.Add($label_DeviceCount) + $form1.Controls.Add($label_DeviceCount_Value) + + + $form1.AutoScaleDimensions = '6, 13' + $form1.AutoScaleMode = 'Font' + $form1.ClientSize = '1000, 800' + $form1.Name = 'form1' + $form1.Text = 'Form' + $form1.add_Load($form1_Load) + #endregion Generated Form Code + + #---------------------------------------------- +<# + $PanelEventLogs_Events.Controls.Add($Text_ELogs_ServerName) + $PanelEventLogs_Events.Controls.Add($Button_ELogs_Connect) + $PanelEventLogs_Events.Controls.Add($Button_ELogs_View) + $PanelEventLogs_Events.Controls.Add($Combobox_EventLogs_LogsList) + $PanelEventLogs_Events.Controls.Add($VCenterUserPassword) + $PanelEventLogs_Events.Controls.Add($CheckBoxUseWindowsLogin) + $PanelEventLogs_Events.Controls.Add($labelVCenterUserName) + $PanelEventLogs_Events.Controls.Add($labelVCenterPassword) + $PanelEventLogs_Events.Controls.Add($Script:Collection_DropDownBox) + $PanelEventLogs_Events.BackColor = '153,153,153' + $PanelEventLogs_Events.Location = '6, 6' + $PanelEventLogs_Events.Name = 'panelEventLogs_Events' + $PanelEventLogs_Events.Size = '598, 56' + $PanelEventLogs_Events.TabIndex = 0 + $PanelEventLogs_Events.add_Paint($PanelEventLogs_Events_Paint) + + $PanelEventLogs_Filter.Controls.Add($Combobox_ELogsFilter_Level) + $PanelEventLogs_Filter.Controls.Add($Text_ELogs_EventID) + $PanelEventLogs_Filter.Controls.Add($Text_Elogs_DaysBack) + $PanelEventLogs_Filter.Controls.Add($label_ELogs_Level) + $PanelEventLogs_Filter.Controls.Add($label_ELogs_EventID) + $PanelEventLogs_Filter.Controls.Add($label_ELogs_DaysBack) + $PanelEventLogs_Filter.BackColor = '255,255,212' + $PanelEventLogs_Filter.Location = '6, 62' + $PanelEventLogs_Filter.Name = 'PanelEventLogs_Filter' + $PanelEventLogs_Filter.Size = '598, 56' + $PanelEventLogs_Filter.BorderStyle = 'FixedSingle' + $PanelEventLogs_Filter.TabIndex = 0 + $PanelEventLogs_Filter.add_Paint($PanelEventLogs_Filter_Paint) +#> + # + # $Text_ELogs_ServerName + <# + $Text_ELogs_ServerName.Location = '8, 26' + $Text_ELogs_ServerName.Name = '$Text_ELogs_ServerName' + $Text_ELogs_ServerName.Size = '100, 20' + $Text_ELogs_ServerName.text = "l2012" + $Text_ELogs_ServerName.TabIndex = 6 + $Text_ELogs_ServerName.add_TextChanged($Text_ELogs_ServerName_TextChanged) + # + # + # Text_ELogs_EventID + # + $Text_ELogs_EventID.Location = '115, 26' + $Text_ELogs_EventID.Name = 'Text_ELogs_EventID' + $Text_ELogs_EventID.Size = '40, 20' + $Text_ELogs_EventID.TabIndex = 7 + $Text_ELogs_EventID.add_TextChanged($Text_ELogs_EventID_TextChanged) + # + # Text_Elogs_DaysBack + # + $Text_Elogs_DaysBack.Location = '175, 26' + $Text_Elogs_DaysBack.Name = 'Text_Elogs_DaysBack' + $Text_Elogs_DaysBack.Size = '40, 20' + $Text_Elogs_DaysBack.TabIndex = 7 + $Text_Elogs_DaysBack.add_TextChanged($Text_Elogs_DaysBack_TextChanged) + #> + # Output + # + $Output.Location = '10, 250' + $Output.Multiline = $True + $Output.Name = 'Output' + $Output.ScrollBars = 'both' + $Output.Size = '965, 500' + $Output.Font = 'Consolas, 8.25pt' + $Output.WordWrap = $False + $Output.TabIndex = 5 + $Output.add_TextChanged($Output_TextChanged) + # + # ComboboxServiceStartMode + # + $Script:Collection_DropDownBox.FormattingEnabled = $True + $Script:Collection_DropDownBox.Location = '20, 80' + $Script:Collection_DropDownBox.Name = 'Script:Collection_DropDownBox' + $Script:Collection_DropDownBox.Size = '180, 20' + $Script:Collection_DropDownBox.TabIndex = 2 + $Script:Collection_DropDownBox.Text = '--Deployed to Collections--' + $Script:Collection_DropDownBox.add_SelectedIndexChanged($Script:Collection_DropDownBox_SelectedIndexChanged) + # + $Script:Deployment_DropDownBox.Location = '20,30' + #$Script:Deployment_DropDownBox.Size = New-Object System.Drawing.Size(580,50) + $Script:Deployment_DropDownBox.Size = '580,50' + #$Script:Deployment_DropDownBox.DropDownHeight = 200 + $Script:Deployment_DropDownBox.text = "----Select Deployment----" + #$Script:Deployment_DropDownBox.Visible = $false + $Script:Deployment_DropDownBox.add_SelectedIndexChanged($Script:Deployment_DropDownBox_SelectedIndexChanged) + # + #$Script:Combobox_Tools.Size = New-Object System.Drawing.Size(180,20) + #$Script:Combobox_Tools.DropDownHeight = 200 + $Script:Combobox_Tools.text = "----Select Tool----!" + $Script:Combobox_Tools.Location = '20,170' + $Script:Combobox_Tools.Size = '180,10' + $Script:Combobox_Tools.add_SelectedIndexChanged($Script:Combobox_Tools_SelectedIndexChanged) + # + $groupBox.Location = '270,70' + $groupBox.size = New-Object System.Drawing.Size(150,90) + $groupBox.text = "Select Output:" + + + $GroupBox.Controls.Add($Script:RadioButton_Window) + $GroupBox.Controls.Add($Script:RadioButton_GridView) + $GroupBox.Controls.Add($Script:RadioButton_CSV) + # + $GroupBox_Info.Location = '670,25' + $GroupBox_Info.Size = '300,200' + $GroupBox_Info.Text = "Deployment Info" + ############ + $GroupBox_Info.Controls.Add($label_CollectionName) + $GroupBox_Info.Controls.Add($label_CollectionName_Value) + $GroupBox_Info.Controls.Add($label_DeploymentName) + $GroupBox_Info.Controls.Add($label_DeploymentName_Value) + $GroupBox_Info.Controls.Add($label_DeploymentTime) + $GroupBox_Info.Controls.Add($label_DeploymentTime_Value) + $GroupBox_Info.Controls.Add($label_DeviceCount) + $GroupBox_Info.Controls.Add($label_DeviceCount_Value) + ############ + $label_CollectionName.AutoSize = $True + $label_CollectionName.Font = 'Microsoft Sans Serif, 9.0pt' #, style=Bold' + #$label_CollectionName.ForeColor = 'DarkGreen' + #$label_CollectionName.TextAlign = 'MiddleRight' + $label_CollectionName.Location = '20,25' + $label_CollectionName.Name = 'Collection_Name' + $label_CollectionName.Size = '41, 13' + #$label_CollectionName.TabIndex = 6 + $label_CollectionName.Text = 'Collection Name:' + #$label_CollectionName.add_Click($label_CollectionName_Click) + + ############ Value ############### + $label_CollectionName_Value.AutoSize = $True + $label_CollectionName_Value.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_CollectionName_Value.ForeColor = 'DarkGreen' + #$label_CollectionName_Value.TextAlign = 'MiddleRight' + $label_CollectionName_Value.Location = '140,25' + $label_CollectionName_Value.Name = 'Collection_Name_Value' + $label_CollectionName_Value.Size = '41, 13' + #$label_CollectionName_Value.TabIndex = 6 + $label_CollectionName_Value.Text = '_' + #$label_CollectionName_Value.add_Click($label_CollectionName_Value_Click) + + ############ + $label_DeploymentName.AutoSize = $True + $label_DeploymentName.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_DeploymentName.ForeColor = 'DarkGreen' + #$label_DeploymentName.TextAlign = 'MiddleRight' + $label_DeploymentName.Location = '20,45' + $label_DeploymentName.Name = 'Deployment_Name' + $label_DeploymentName.Size = '41, 13' + #$label_DeploymentName.TabIndex = 6 + $label_DeploymentName.Text = 'Deployment Name:' + #$label_DeploymentName.add_Click($label_DeploymentName_Click) + + ############ Value ############ + $label_DeploymentName_Value.AutoSize = $True + $label_DeploymentName_Value.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_DeploymentName_Value.ForeColor = 'DarkGreen' + #$label_DeploymentName_Value.TextAlign = 'MiddleRight' + $label_DeploymentName_Value.Location = '140,45' + $label_DeploymentName_Value.Name = 'Deployment_Name_Value' + $label_DeploymentName_Value.Size = '41, 13' + #$label_DeploymentName_Value.TabIndex = 6 + $label_DeploymentName_Value.Text = '_' + #$label_DeploymentName_Value.add_Click($label_DeploymentName_Value_Click) + + ############# + $label_DeploymentTime.AutoSize = $True + $label_DeploymentTime.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_DeploymentTime.ForeColor = 'DarkGreen' + #$label_DeploymentTime.TextAlign = 'MiddleRight' + $label_DeploymentTime.Location = '20,65' + $label_DeploymentTime.Name = 'Deployment_Time' + $label_DeploymentTime.Size = '41, 13' + #$label_DeploymentTime.TabIndex = 6 + $label_DeploymentTime.Text = 'Deployment Time:' + #$label_DeploymentTime.add_Click($label_CollectionName_Click) + + ############ Value ############ + $label_DeploymentTime_Value.AutoSize = $True + $label_DeploymentTime_Value.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_DeploymentTime_Value.ForeColor = 'DarkGreen' + #$label_DeploymentTime_Value.TextAlign = 'MiddleRight' + $label_DeploymentTime_Value.Location = '140,65' + $label_DeploymentTime_Value.Name = 'Deployment_Time_Value' + $label_DeploymentTime_Value.Size = '41, 13' + #$label_DeploymentTime_Value.TabIndex = 6 + $label_DeploymentTime_Value.Text = '_' + #$label_DeploymentTime_Value.add_Click($label_DeploymentTime_Value_Click) + + ########### + $label_DeviceCount.AutoSize = $True + $label_DeviceCount.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_DeviceCount.ForeColor = 'DarkGreen' + #$label_DeviceCount.TextAlign = 'MiddleRight' + $label_DeviceCount.Location = '20,85' + $label_DeviceCount.Name = 'Device_Count' + $label_DeviceCount.Size = '41, 13' + #$label_DeviceCount.TabIndex = 6 + $label_DeviceCount.Text = 'Device Count' + #$label_DeviceCount.add_Click($label_DeviceCount_Click) + + ############ Value ############ + $label_DeviceCount_Value.AutoSize = $True + $label_DeviceCount_Value.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_DeviceCount_Value.ForeColor = 'DarkGreen' + #$label_DeviceCount_Value.TextAlign = 'MiddleRight' + $label_DeviceCount_Value.Location = '140,85' + $label_DeviceCount_Value.Name = 'Device_Count_Value' + $label_DeviceCount_Value.Size = '41, 13' + #$label_DeviceCount_Value.TabIndex = 6 + $label_DeviceCount_Value.Text = '_' + #$label_DeviceCount_Value.add_Click($label_DeviceCount_Value_Click) + ############ + $Script:RadioButton_Window.Location = new-object System.Drawing.Point(15,15) + $Script:RadioButton_Window.size = New-Object System.Drawing.Size(130,20) + $Script:RadioButton_Window.Checked = $true + $Script:RadioButton_Window.Text = "Window" + #$Script:RadioButton_Window. + # + $Script:RadioButton_GridView.Location = new-object System.Drawing.Point(15,35) + $Script:RadioButton_GridView.size = New-Object System.Drawing.Size(80,20) + $Script:RadioButton_GridView.Checked = $False + $Script:RadioButton_GridView.Text = "GridView" + # + $Script:RadioButton_CSV.Location = new-object System.Drawing.Point(15,55) + $Script:RadioButton_CSV.size = New-Object System.Drawing.Size(80,20) + $Script:RadioButton_CSV.Checked = $False + $Script:RadioButton_CSV.Text = "CSV" + # + $Button_Go.Location = New-Object System.Drawing.Size(450,75) + $Button_Go.Size = New-Object System.Drawing.Size(110,80) + $Button_Go.Text = "Go" + #$Button_Go.Add_Click({temp}) + $Button_Go.Add_Click($Button_Go_Click) + # + $Script:TextBox_CollectionName.Left = 20; + $Script:TextBox_CollectionName.Top = 130; + $Script:TextBox_CollectionName.width = 200; + $Script:TextBox_CollectionName.Text = "Nabil - Test Collection" + # + ############################################################################ + Update-Dropdown1 + ConnectTo-SCCM + Deployment-List -Deployment_History 10 + $Script:Output.Text = "helloooooooo" + #cd c: + + + ############################################################################ + +#Save the initial state of the form + $InitialFormWindowState = $form1.WindowState + #Init the OnLoad event to correct the initial state of the form + $form1.add_Load($Form_StateCorrection_Load) + #Clean up the control events + $form1.add_FormClosed($Form_Cleanup_FormClosed) + #Show the Form + return $form1.ShowDialog() + +} #End Function + +#Call the form +Show-Form-Template_psf | Out-Null diff --git a/dump/SCCM-Tool/NA-Tool-GUI-8x.ps1 b/dump/SCCM-Tool/NA-Tool-GUI-8x.ps1 new file mode 100644 index 0000000..138b6fc --- /dev/null +++ b/dump/SCCM-Tool/NA-Tool-GUI-8x.ps1 @@ -0,0 +1,782 @@ +#------------------------------------------------------------------------ +# Source File Information (DO NOT MODIFY) +# Source ID: 676f8db7-35c7-452d-b353-a4b40f26243a +# Source File: Form-Template.psf +#------------------------------------------------------------------------ +#region File Recovery Data (DO NOT MODIFY) +<#RecoveryData: +RAUAAB+LCAAAAAAABAC9VNtKwzAYvhd8h5Dr2oPd3AZtYXTuxtNwQ72TrP07o2lSknSzPr3p2g1x +QkHGKJSk+Q7/KQ0eIRFrkNWEaILMQlHBQ3xpezg6P0MoeJB0RTlhU8rgnuQQTYXMLxaQF4xosAuV +Bc4BpmEu3yHRSFcFhHheKQ25/Ux5KjbKrkWat4X+OrLQUxtKz3brx0JxyXQpIeRQakmYhWblktHk +BqqF+AAeLgcD0k/6V97I74E7HGHETSghzoyeh1HyRlkqDQ7HgmspmGoSNIHOpChA6qoljEst5glh +MKE58DoIA72ykOcHzg7aRb0TKWBTKq47OTGjwPWcfhnCwDU+/nDYSaqrjKNtap3YBXxqvG3bIfR6 +bbxb3K0gaav5Wq8DZ3vaNNNputlsxkpBbooPaqfTfqmiXCVCMro8QgMDZ6/626UZmVN4HH0sux3r +m3gaI0k2lK/+4+X6WT8bZJ6X9l3ik26vl5ydJKdYSDi+0X7bjHzg/PxrRt9OzyrdRAUAAA==#> +#endregion + +<# + .NOTES + -------------------------------------------------------------------------------- + Code generated by: SAPIEN Technologies, Inc., PowerShell Studio 2017 v5.4.141 + Generated on: 8/29/2017 11:53 AM + Generated by: Haidey2 + -------------------------------------------------------------------------------- + .DESCRIPTION + GUI script generated by PowerShell Studio 2017 +#> + + +#---------------------------------------------- +#region Application Functions +#---------------------------------------------- + +#endregion Application Functions + +#---------------------------------------------- +# Generated Form Function +#---------------------------------------------- +function Show-Form-Template_psf { + + #---------------------------------------------- + #region Import the Assemblies + #---------------------------------------------- + [void][reflection.assembly]::Load('System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') + [void][reflection.assembly]::Load('System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') + [void][reflection.assembly]::Load('System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') + #endregion Import Assemblies + + #---------------------------------------------- + #region Generated Form Objects + #---------------------------------------------- + [System.Windows.Forms.Application]::EnableVisualStyles() + $form1 = New-Object 'System.Windows.Forms.Form' + $InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState' + + + $Script:Output = New-Object System.Windows.Forms.TextBox + $Script:Collection_DropDownBox = New-Object System.Windows.Forms.ComboBox + $Script:Deployment_DropDownBox = New-Object System.Windows.Forms.ComboBox + $Script:Combobox_Tools = New-Object System.Windows.Forms.ComboBox + + $GroupBox = New-Object System.Windows.Forms.GroupBox + $GroupBox_Info = New-Object System.Windows.Forms.GroupBox + + $Script:RadioButton_Window = New-Object System.Windows.Forms.RadioButton + $Script:RadioButton_GridView = New-Object System.Windows.Forms.RadioButton + $Script:RadioButton_CSV = New-Object System.Windows.Forms.RadioButton + $Button_Go = New-Object System.Windows.Forms.Button + $Script:TextBox_CollectionName = New-Object “System.Windows.Forms.TextBox” + + #$PanelEventLogs_Events = New-Object 'System.Windows.Forms.Panel' + #$PanelEventLogs_Filter = New-Object 'System.Windows.Forms.Panel' + + + #$Text_ELogs_ServerName = New-Object 'System.Windows.Forms.TextBox' + #$Text_ELogs_EventID = New-Object 'System.Windows.Forms.TextBox' + #$Text_Elogs_DaysBack = New-Object 'System.Windows.Forms.TextBox' + + $label_CollectionName = New-Object 'System.Windows.Forms.Label' + $label_CollectionName_Value = New-Object 'System.Windows.Forms.Label' + $label_DeploymentName = New-Object 'System.Windows.Forms.Label' + $label_DeploymentName_Value = New-Object 'System.Windows.Forms.Label' + $label_DeploymentTime = New-Object 'System.Windows.Forms.Label' + $label_DeploymentTime_Value = New-Object 'System.Windows.Forms.Label' + $label_DeviceCount = New-Object 'System.Windows.Forms.Label' + $label_DeviceCount_Value = New-Object 'System.Windows.Forms.Label' + + $Button_ELogs_Connect = New-Object 'System.Windows.Forms.Button' + + + + +# $Location = Split-Path $MyInvocation.MyCommand.Path -Parent + + $Script:ALL_Patch_Servers = @() + $Script:Responding = @() + $Script:NotResponding = @() + $Global:DeviceCollection_ServerNames1 = "" + + $Global:Collection_Name = "" + $Global:Select_Tool + $Global:Output_Type = "" + $Global:Deployments = "" + + #endregion Generated Form Objects + + #---------------------------------------------- + # User Generated Script + #---------------------------------------------- + + $form1_Load={ + #TODO: Initialize Form Controls here + + } + + $Script:Collection_DropDownBox_SelectedIndexChanged={ + + $Script:Output.Text = $Script:Collection_DropDownBox.Text + $T = Get-CMDeviceCollection -Name $Script:Collection_DropDownBox.text | select Name,MemberCount + + $label_DeviceCount_Value.Text = $T.MemberCount + + } + + $Script:Deployment_DropDownBox_SelectedIndexChanged={ + Reset-Forms -Form_Selection 1 + Deployed-to-Collections + $Script:Output.Text = $Script:Deployment_DropDownBox.Text + } + + $Script:Combobox_Tools_SelectedIndexChanged= { + $Script:Output.Text = $Script:Combobox_Tools.Text + + + } + + $Button_Go_Click = { + temp + #SCCM-Module + # $Global:Collection_Name = $Script:TextBox_CollectionName.Text #$Script:TextBox_CollectionName.Text + # $Global:Select_Tool = $Script:Combobox_Tools.Text + + + #$Output.Text = "$Global:Collection_Name --- $Global:Select_Tool " | Out-String + #$Output.Text = | Out-String + } + + +################################################################################################################## + Function ConnectTo-SCCM { + + If(!(Get-PSDrive).Name -ne "CCX") { + # + # Press 'F5' to run this script. Running this script will load the ConfigurationManager + # module for Windows PowerShell and will connect to the site. + # + # This script was auto-generated at '2/18/2021 10:12:39 AM'. + + # Uncomment the line below if running in an environment where script signing is + # required. + #Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process + + # Site configuration + $SiteCode = "CCX" # Site code + $ProviderMachineName = "PNCRASCCM001.ccx.carecentrix.com" # SMS Provider machine name + + # Customizations + $initParams = @{} + #$initParams.Add("Verbose", $true) # Uncomment this line to enable verbose logging + #$initParams.Add("ErrorAction", "Stop") # Uncomment this line to stop the script on any errors + + # Do not change anything below this line + + # Import the ConfigurationManager.psd1 module + if((Get-Module ConfigurationManager) -eq $null) { + Import-Module "$($ENV:SMS_ADMIN_UI_PATH)\..\ConfigurationManager.psd1" @initParams + } + + # Connect to the site's drive if it is not already present + if((Get-PSDrive -Name $SiteCode -PSProvider CMSite -ErrorAction SilentlyContinue) -eq $null) { + New-PSDrive -Name $SiteCode -PSProvider CMSite -Root $ProviderMachineName @initParams + } + + # Set the current location to be the site code. + Set-Location "$($SiteCode):\" @initParams + + #$Script:Output.Text = "inside connectoSCCM function" + }#endIf + }#endFunction +################################################################################################################## + Function SCCM-Module { + Write-Host "Inside SCCM function" -ForegroundColor Cyan + If(!(Get-PSDrive).Name -eq "sccm-drive") { + + Import-Module 'C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1' + New-PSDrive -Name SCCM-Drive -PSProvider "AdminUI.PS.Provider\CMSite" -Root "PNCRASCCM001.ccx.carecentrix.com" -Description "SCCM Site" + }#endIf + $Script:Output.Text | Get-PSDrive | ft -AutoSize | Out-String + CD sccm-drive: + }#endFunction +################################################################################################################## + Function Update-Dropdown1 { + # $Collections += $Script:Collection_DropDownBox.text + $Collections = @("Collection-Servers","Ping-Collection","Check_Uptime","Test-Service","Remotely Update Policy","Software Update Status","Test-Sccm") + $Collections | % { $Script:Combobox_Tools.Items.Add($_) } + } +################################################################################################################## + Function Reset-Forms { + Param($Form_Selection) + + Switch ($Form_Selection) { + 1 { $Collection_DropDownBox.Items.Clear(); $Collection_DropDownBox.Text = "--Deployed to Collections--" } + 2 {} + + } + + } +################################################################################################################## + Function temp { + $Script:Output.Clear() + #$Script:Script:Output.text = $Script:Collection_DropDownBox.text | Out-String + + #$Global:Collection_Name = $Script:TextBox_CollectionName.Text #$Script:TextBox_CollectionName.Text + $Global:Collection_Name = $Script:Collection_DropDownBox.Text + $Global:Select_Tool = $Script:Combobox_Tools.Text + + + If ($Script:RadioButton_Window.Checked -eq $true) { $Global:Output_Type = "Window" <#; $Script:Output.Text = "Window_Radio1 Checked: $($Script:RadioButton_Window.Checked)" | Out-String #> } + ElseIf ($Script:RadioButton_GridView.Checked -eq $true) { $Global:Output_Type = "Gridview" <#; $Script:Output.Text = "Gridview_Radio2 Checked: $($Script:RadioButton_GridView.Checked)" | Out-String #> } + ElseIf ($Script:RadioButton_CSV.Checked -eq $true) { $Global:Output_Type = "Export" <#; $Script:Output.Text = "CSV_Radio3 Checked: $($Script:RadioButton_CSV.Checked)" | Out-String #> } + + + If($Global:Collection_Name -and $Global:Select_Tool) { + # If($Script:Collection_DropDownBox.text = "Tool1"){gcc} + Run-Tool + #$Script:TextBox_CollectionName.clear() + $Script:Collection_DropDownBox.text = "----Select Collection----" + #Clear-Variables + }#endIf + Else { #$T = { Write-Host "You must enter Collection Name ............!!" -ForegroundColor Red } + $Script:Output.SelectionColor = 'red' + $Script:Output.Text = "You must select 'Tool' and enter Collection Name............!!" + } + + Run-Defaults + }#endFunction +################################################################################################################## + Function Run-Tool { + + Switch($Global:Select_Tool) { + Collection-Servers { Collection-Servers; Write-Host "Tool Selected: $Global:Select_Tool" } + Ping-Collection { Ping_Collection } + Check_Uptime { Check_Uptime } + Test-Service { Test-Service } + Test-SCCM { SCCM-Module } + #"Remotely Update Policy" { $Script:Output.Text = Invoke-Expression $Location\Tool-Remotely-Restart-SCCMSyncCycle.ps1 | ft -AutoSize | Out-String } + "Remotely Update Policy" { $Script:Output.Text = Invoke-Expression $Location\Tool-Remotely-Restart-SCCMSyncCycle.ps1 | ft -AutoSize | Out-String } + "Software Update Status" { $Script:Output.Text = & "$Location\Tool-Get-SCCMSoftwareUpdateStatus.ps1" -Dep_ID 16778048 | ft -AutoSize | Out-String} + }#endSwitch + #Clear-Variables + }#endFunction +################################################################################################################## + Function Run-Defaults { + #$Script:TextBox_CollectionName.Text = "Nabil - Test Collection" + $Script:RadioButton_Window.Checked = $true + + <# + If(!$Location) { + $Location = Split-Path $MyInvocation.MyCommand.Path -Parent + } + #> + } +################################################################################################################## + Function xClear-Variables { + $Global:Collection_Name = "" + $Global:Select_Tool = "" + $Global:Output_Type = "" + + $Script:ALL_Patch_Servers = @() + } +################################################################################################################## + Function Display-Results { + #Param($Global:Output_Type,$Final_Result) + Write-Host "DisplayType: $($Global:Output_Type)" + Switch ($Global:Output_Type){ + + Window { $Script:Output.Text = $Script:ALL_Patch_Servers | Out-String} + Gridview { $Script:ALL_Patch_Servers | Out-GridView } + Export { $Script:ALL_Patch_Servers | Export-Csv -Path $Location\Results.csv -NoTypeInformation; ii $Location\Results.csv } + + }#endSwitch + + } +############################################################################################################################################################# + Function Collection-Servers { + #Param($Coll_Name) + + Write-Host "Collection:$Global:Collection_Name" + $Script:ALL_Patch_Servers = @() + + ConnectTo-SCCM + #SCCM-Module + #CD sccm-drive: + $Script:DeviceCollection_MemberCount = Get-CMDeviceCollection -Name $Global:Collection_Name | select Name,MemberCount + $Script:DeviceCollection_ServerNames = Collection-Members #Get-CMCollectionMember -CollectionName $Global:Collection_Name | select Name,IsClient #| Export-Csv "E:\SCCM-Files\SCCM-Scripts\Files\$Global:Collection_Name.csv" -NoTypeInformation + #$ServerName = $DeviceCollection_ServerNames.Name + #Set-Location c: + + #$Script:Temp = Get-CMCollectionMember -CollectionName $Global:Collection_Name #| select Name,IsClient + + $Script:DeviceCollection_ServerNames | % { + $Obj = New-Object -TypeName PSObject + $Obj | Add-Member -MemberType NoteProperty -Name Server -Value $_.Name + $Obj | Add-Member -MemberType NoteProperty -Name ClientInstalled -Value $_.IsClient + $Obj | Add-Member -MemberType NoteProperty -Name CollectionName -Value $Global:Collection_Name + #$Obj | Add-Member -MemberType NoteProperty -Name CollectionMemberCount -Value {(Get-CMCollectionMember -Name $Global:Collection_Name).MemberCount} + + $Obj + $Script:ALL_Patch_Servers += $Obj + + }#end% + + # $Script:Output.Text = $Script:ALL_Patch_Servers | Out-String + Display-Results #-Final_Result $Script:ALL_Patch_Servers + Write-Host "$Script:ALL_Patch_Servers" + # $Script:ALL_Patch_Servers | Export-Csv $Location\Current-Collection-Servers.csv -NoTypeInformation + + }#endFunction +############################################################################################################################################################# + Function Collection-Members { + Get-CMCollectionMember -CollectionName $Global:Collection_Name | select Name,IsClient + + } + +############################################################################################################################################################# + Function Ping_Collection { + + $Ping_Result = @() + $NotResponding = @() + $Responding = @() + + ConnectTo-SCCM + #SCCM-Module + #CD sccm-drive: + $Global:DeviceCollection_ServerNames1 = Collection-Members #Get-CMCollectionMember -CollectionName $Global:Collection_Name | select Name + #Set-Location c: + + Write-Host "Total Server Count: $($Global:DeviceCollection_ServerNames1.count)" -ForegroundColor Green + Write-Host "" + + ############ + # $Script:Output.Text = "CollectionName: $($Global:Collection_Name) ------ hello " + ############ + $Global:DeviceCollection_ServerNames1.Name | % { + $Server = $_ + $Obj = New-Object -TypeName PSObject + $Count = $Global:DeviceCollection_ServerNames1.count + $Script:Output.Text = "Checking: $Server ----- Servers left: $($Count--) Please Wait !!!" | Out-String + + If (Test-Connection $Server -Count 1 -ErrorAction SilentlyContinue ) { + #Write-Host "Responding:---- $_ " -ForegroundColor Green + #$Script:Output.AppendText("Responding: $_") + + $Obj | Add-Member -MemberType NoteProperty -Name Server -Value $Server + $Obj | Add-Member -MemberType NoteProperty -Name Responding -Value "Yes" + $Ping_Result += $Obj + $Responding += $Server + # $Script:Output.text += $Obj | Out-String + }#endIf + + Else { + $Obj | Add-Member -MemberType NoteProperty -Name Server -Value $Server + $Obj | Add-Member -MemberType NoteProperty -Name Responding -Value "No!" + $Ping_Result += $Obj + $NotResponding += $Server + # $Script:Output.text += $Obj | Out-String + } + }#end% + $Script:Output.Text = $Ping_Result | ft -AutoSize | Out-String + + write-host "-------------------------------------------------------" + Write-host "$($Responding.count) / $($DeviceCollection_ServerNames1.count) -- Responding" -foregroundcolor Green + Write-host "$($NotResponding.count) / $($DeviceCollection_ServerNames1.count) -- NOT Responding" -foregroundcolor Red + + #Write-Host "Servers NOT Responding: $NotResponding " -ForegroundColor Red + + }#endFunction +############################################################################################################################################################# + Function Check_Uptime { + ConnectTo-SCCM + $Global:DeviceCollection_ServerNames1 = Get-CMCollectionMember -CollectionName $Global:Collection_Name | select Name + $Script:Output.Text = $Global:DeviceCollection_ServerNames1.name | % { gwmi win32_operatingsystem -ComputerName $_ -ErrorAction SilentlyContinue | select @{n="Server";e={$_.PSComputername}},@{n="LastReboot";e={$_.Converttodatetime($_.LastBootUpTime)}}} | sort LastBootup -descending | Out-String + + } + +############################################################################################################################################################# + Function Deployment-List { + Param($Deployment_History) + # SCCM-Module + $Global:Deployments = Get-CMDeployment | ? { $_.deploymenttime -gt ((Get-Date).AddDays(-"$Deployment_History")) } + + #$T | select ApplicationName,CollectionName,DeploymentTime,AssignmentID,SoftwareName | % { $Deployment_DropDownBox.Items.Add($_) } + $i = 0 + $Q = "" #@() + + $Global:Deployments.ApplicationName | % { $Script:Deployment_DropDownBox.Items.Add($_)} + <# + foreach ($D in $Deployments) { + $Q = $D.ApplicationName + "-------------------------------------------------------" + $D.CollectionName + + $Deployment_DropDownBox.Items.Add($Q) + $i++ + } + #> + + #$T.ApplicationName | % { $Deployment_DropDownBox.Items.Add($_) } + + }#endFunction +############################################################################################################################################################# + Function Deployed-to-Collections { + $T = $Global:Deployments | ? { $_.ApplicationName -eq "$($Script:Deployment_DropDownBox.text)" } | Select -ExpandProperty CollectionName + $Script:Collection_DropDownBox.Items.Clear() + $T | % { $Script:Collection_DropDownBox.Items.Add("$_")} + } + +############################################################################################################################################################# + Function Test-Service { + $T = Get-Service + $Script:Output.Text = $T | ft -AutoSize | Out-String + } +################################################################################################################## + +################################################################################################################## + # --End User Generated Script-- + #---------------------------------------------- + #region Generated Events + #---------------------------------------------- + + $Form_StateCorrection_Load= + { + #Correct the initial state of the form to prevent the .Net maximized form issue + $form1.WindowState = $InitialFormWindowState + } + + $Form_Cleanup_FormClosed= + { + #Remove all event handlers from the controls + try + { + $form1.remove_Load($form1_Load) + $form1.remove_Load($Form_StateCorrection_Load) + $form1.remove_FormClosed($Form_Cleanup_FormClosed) + + #$PanelEventLogs_Events.remove_Paint($PanelEventLogs_Events_Paint) + #$PanelEventLogs_Filter.remove_Paint($PanelEventLogs_Filter_Paint) + + $Text_Elogs_DaysBack.remove_TextChanged($Text_Elogs_DaysBack_TextChanged) + $Text_ELogs_ServerName.remove_TextChanged($Text_ELogs_ServerName_TextChanged) + $Text_ELogs_EventID.remove_TextChanged($Text_ELogs_EventID_TextChanged) + + $Script:Output.remove_TextChanged($Output_TextChanged) + $Script:Collection_DropDownBox.remove_SelectedIndexChanged($Script:Collection_DropDownBox_SelectedIndexChanged) + $Script:Deployment_DropDownBox.remove_SelectedIndexChanged($Script:Deployment_DropDownBox_SelectedIndexChanged) + $Script:Combobox_Tools.remove_SelectedIndexChanged($Script:Combobox_Tools_SelectedIndexChanged) + $Script:RadioButton_Window.remove_SelectedIndexChanged($Script:RadioButton_Window_SelectedIndexChanged) + $Script:RadioButton_GridView.remove_SelectedIndexChanged($Script:RadioButton_GridView_SelectedIndexChanged) + $Script:RadioButton_CSV.remove_SelectedIndexChanged($Script:RadioButton_CSV_SelectedIndexChanged) + $Button_Go.remove_Click($Button_Go_Click) + + } + catch { Out-Null <# Prevent PSScriptAnalyzer warning #> } + } + + + #$PanelEventLogs_Events_Paint=[System.Windows.Forms.PaintEventHandler]{ <#Event Argument: $_ = [System.Windows.Forms.PaintEventArgs]#> } + #$PanelEventLogs_Filter_Paint=[System.Windows.Forms.PaintEventHandler]{ } + + $Text_ELogs_ServerName_TextChanged={} + $Text_Elogs_DaysBack_TextChanged={} + + #endregion Generated Events + + #---------------------------------------------- + #region Generated Form Code + #---------------------------------------------- + # + # form1 + # + #$form1.Controls.Add($PanelEventLogs_Events) + #$form1.Controls.Add($PanelEventLogs_Filter) + + $form1.Controls.Add($Output) + $form1.Controls.Add($Script:Collection_DropDownBox) + $form1.Controls.Add($Script:Deployment_DropDownBox) + $form1.Controls.Add($Script:Combobox_Tools) + $form1.Controls.Add($GroupBox) + $form1.Controls.Add($GroupBox_Info) + $form1.controls.Add($Script:RadioButton_Window) + $form1.controls.Add($Script:RadioButton_GridView) + $form1.Controls.Add($Script:RadioButton_CSV) + $form1.Controls.Add($Button_Go) + $form1.Controls.Add($Script:TextBox_CollectionName) + $form1.Controls.Add($label_CollectionName) + $form1.Controls.Add($label_CollectionName_Value) + $form1.Controls.Add($label_DeploymentName) + $form1.controls.Add($label_DeploymentName_Value) + $form1.Controls.Add($label_DeploymentTime) + $form1.Controls.Add($label_DeploymentTime_Value) + $form1.Controls.Add($label_DeviceCount) + $form1.Controls.Add($label_DeviceCount_Value) + + + $form1.AutoScaleDimensions = '6, 13' + $form1.AutoScaleMode = 'Font' + $form1.ClientSize = '1000, 800' + $form1.Name = 'form1' + $form1.Text = 'Form' + $form1.add_Load($form1_Load) + #endregion Generated Form Code + + #---------------------------------------------- +<# + $PanelEventLogs_Events.Controls.Add($Text_ELogs_ServerName) + $PanelEventLogs_Events.Controls.Add($Button_ELogs_Connect) + $PanelEventLogs_Events.Controls.Add($Button_ELogs_View) + $PanelEventLogs_Events.Controls.Add($Combobox_EventLogs_LogsList) + $PanelEventLogs_Events.Controls.Add($VCenterUserPassword) + $PanelEventLogs_Events.Controls.Add($CheckBoxUseWindowsLogin) + $PanelEventLogs_Events.Controls.Add($labelVCenterUserName) + $PanelEventLogs_Events.Controls.Add($labelVCenterPassword) + $PanelEventLogs_Events.Controls.Add($Script:Collection_DropDownBox) + $PanelEventLogs_Events.BackColor = '153,153,153' + $PanelEventLogs_Events.Location = '6, 6' + $PanelEventLogs_Events.Name = 'panelEventLogs_Events' + $PanelEventLogs_Events.Size = '598, 56' + $PanelEventLogs_Events.TabIndex = 0 + $PanelEventLogs_Events.add_Paint($PanelEventLogs_Events_Paint) + + $PanelEventLogs_Filter.Controls.Add($Combobox_ELogsFilter_Level) + $PanelEventLogs_Filter.Controls.Add($Text_ELogs_EventID) + $PanelEventLogs_Filter.Controls.Add($Text_Elogs_DaysBack) + $PanelEventLogs_Filter.Controls.Add($label_ELogs_Level) + $PanelEventLogs_Filter.Controls.Add($label_ELogs_EventID) + $PanelEventLogs_Filter.Controls.Add($label_ELogs_DaysBack) + $PanelEventLogs_Filter.BackColor = '255,255,212' + $PanelEventLogs_Filter.Location = '6, 62' + $PanelEventLogs_Filter.Name = 'PanelEventLogs_Filter' + $PanelEventLogs_Filter.Size = '598, 56' + $PanelEventLogs_Filter.BorderStyle = 'FixedSingle' + $PanelEventLogs_Filter.TabIndex = 0 + $PanelEventLogs_Filter.add_Paint($PanelEventLogs_Filter_Paint) +#> + # + # $Text_ELogs_ServerName + <# + $Text_ELogs_ServerName.Location = '8, 26' + $Text_ELogs_ServerName.Name = '$Text_ELogs_ServerName' + $Text_ELogs_ServerName.Size = '100, 20' + $Text_ELogs_ServerName.text = "l2012" + $Text_ELogs_ServerName.TabIndex = 6 + $Text_ELogs_ServerName.add_TextChanged($Text_ELogs_ServerName_TextChanged) + # + # + # Text_ELogs_EventID + # + $Text_ELogs_EventID.Location = '115, 26' + $Text_ELogs_EventID.Name = 'Text_ELogs_EventID' + $Text_ELogs_EventID.Size = '40, 20' + $Text_ELogs_EventID.TabIndex = 7 + $Text_ELogs_EventID.add_TextChanged($Text_ELogs_EventID_TextChanged) + # + # Text_Elogs_DaysBack + # + $Text_Elogs_DaysBack.Location = '175, 26' + $Text_Elogs_DaysBack.Name = 'Text_Elogs_DaysBack' + $Text_Elogs_DaysBack.Size = '40, 20' + $Text_Elogs_DaysBack.TabIndex = 7 + $Text_Elogs_DaysBack.add_TextChanged($Text_Elogs_DaysBack_TextChanged) + #> + # Output + # + $Output.Location = '10, 250' + $Output.Multiline = $True + $Output.Name = 'Output' + $Output.ScrollBars = 'both' + $Output.Size = '965, 500' + $Output.Font = 'Consolas, 8.25pt' + $Output.WordWrap = $False + $Output.TabIndex = 5 + $Output.add_TextChanged($Output_TextChanged) + # + # ComboboxServiceStartMode + # + $Script:Collection_DropDownBox.FormattingEnabled = $True + $Script:Collection_DropDownBox.Location = '20, 80' + $Script:Collection_DropDownBox.Name = 'Script:Collection_DropDownBox' + $Script:Collection_DropDownBox.Size = '180, 20' + $Script:Collection_DropDownBox.TabIndex = 2 + $Script:Collection_DropDownBox.Text = '--Deployed to Collections--' + $Script:Collection_DropDownBox.add_SelectedIndexChanged($Script:Collection_DropDownBox_SelectedIndexChanged) + # + $Script:Deployment_DropDownBox.Location = '20,30' + #$Script:Deployment_DropDownBox.Size = New-Object System.Drawing.Size(580,50) + $Script:Deployment_DropDownBox.Size = '580,50' + #$Script:Deployment_DropDownBox.DropDownHeight = 200 + $Script:Deployment_DropDownBox.text = "----Select Deployment----" + #$Script:Deployment_DropDownBox.Visible = $false + $Script:Deployment_DropDownBox.add_SelectedIndexChanged($Script:Deployment_DropDownBox_SelectedIndexChanged) + # + #$Script:Combobox_Tools.Size = New-Object System.Drawing.Size(180,20) + #$Script:Combobox_Tools.DropDownHeight = 200 + $Script:Combobox_Tools.text = "----Select Tool----!" + $Script:Combobox_Tools.Location = '20,170' + $Script:Combobox_Tools.Size = '180,10' + $Script:Combobox_Tools.add_SelectedIndexChanged($Script:Combobox_Tools_SelectedIndexChanged) + # + $groupBox.Location = '270,70' + $groupBox.size = New-Object System.Drawing.Size(150,90) + $groupBox.text = "Select Output:" + + + $GroupBox.Controls.Add($Script:RadioButton_Window) + $GroupBox.Controls.Add($Script:RadioButton_GridView) + $GroupBox.Controls.Add($Script:RadioButton_CSV) + # + $GroupBox_Info.Location = '670,25' + $GroupBox_Info.Size = '300,200' + $GroupBox_Info.Text = "Deployment Info" + ############ + $GroupBox_Info.Controls.Add($label_CollectionName) + $GroupBox_Info.Controls.Add($label_CollectionName_Value) + $GroupBox_Info.Controls.Add($label_DeploymentName) + $GroupBox_Info.Controls.Add($label_DeploymentName_Value) + $GroupBox_Info.Controls.Add($label_DeploymentTime) + $GroupBox_Info.Controls.Add($label_DeploymentTime_Value) + $GroupBox_Info.Controls.Add($label_DeviceCount) + $GroupBox_Info.Controls.Add($label_DeviceCount_Value) + ############ + $label_CollectionName.AutoSize = $True + $label_CollectionName.Font = 'Microsoft Sans Serif, 9.0pt' #, style=Bold' + #$label_CollectionName.ForeColor = 'DarkGreen' + #$label_CollectionName.TextAlign = 'MiddleRight' + $label_CollectionName.Location = '20,25' + $label_CollectionName.Name = 'Collection_Name' + $label_CollectionName.Size = '41, 13' + #$label_CollectionName.TabIndex = 6 + $label_CollectionName.Text = 'Collection Name:' + #$label_CollectionName.add_Click($label_CollectionName_Click) + + ############ Value ############### + $label_CollectionName_Value.AutoSize = $True + $label_CollectionName_Value.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_CollectionName_Value.ForeColor = 'DarkGreen' + #$label_CollectionName_Value.TextAlign = 'MiddleRight' + $label_CollectionName_Value.Location = '140,25' + $label_CollectionName_Value.Name = 'Collection_Name_Value' + $label_CollectionName_Value.Size = '41, 13' + #$label_CollectionName_Value.TabIndex = 6 + $label_CollectionName_Value.Text = '_' + #$label_CollectionName_Value.add_Click($label_CollectionName_Value_Click) + + ############ + $label_DeploymentName.AutoSize = $True + $label_DeploymentName.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_DeploymentName.ForeColor = 'DarkGreen' + #$label_DeploymentName.TextAlign = 'MiddleRight' + $label_DeploymentName.Location = '20,45' + $label_DeploymentName.Name = 'Deployment_Name' + $label_DeploymentName.Size = '41, 13' + #$label_DeploymentName.TabIndex = 6 + $label_DeploymentName.Text = 'Deployment Name:' + #$label_DeploymentName.add_Click($label_DeploymentName_Click) + + ############ Value ############ + $label_DeploymentName_Value.AutoSize = $True + $label_DeploymentName_Value.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_DeploymentName_Value.ForeColor = 'DarkGreen' + #$label_DeploymentName_Value.TextAlign = 'MiddleRight' + $label_DeploymentName_Value.Location = '140,45' + $label_DeploymentName_Value.Name = 'Deployment_Name_Value' + $label_DeploymentName_Value.Size = '41, 13' + #$label_DeploymentName_Value.TabIndex = 6 + $label_DeploymentName_Value.Text = '_' + #$label_DeploymentName_Value.add_Click($label_DeploymentName_Value_Click) + + ############# + $label_DeploymentTime.AutoSize = $True + $label_DeploymentTime.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_DeploymentTime.ForeColor = 'DarkGreen' + #$label_DeploymentTime.TextAlign = 'MiddleRight' + $label_DeploymentTime.Location = '20,65' + $label_DeploymentTime.Name = 'Deployment_Time' + $label_DeploymentTime.Size = '41, 13' + #$label_DeploymentTime.TabIndex = 6 + $label_DeploymentTime.Text = 'Deployment Time:' + #$label_DeploymentTime.add_Click($label_CollectionName_Click) + + ############ Value ############ + $label_DeploymentTime_Value.AutoSize = $True + $label_DeploymentTime_Value.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_DeploymentTime_Value.ForeColor = 'DarkGreen' + #$label_DeploymentTime_Value.TextAlign = 'MiddleRight' + $label_DeploymentTime_Value.Location = '140,65' + $label_DeploymentTime_Value.Name = 'Deployment_Time_Value' + $label_DeploymentTime_Value.Size = '41, 13' + #$label_DeploymentTime_Value.TabIndex = 6 + $label_DeploymentTime_Value.Text = '_' + #$label_DeploymentTime_Value.add_Click($label_DeploymentTime_Value_Click) + + ########### + $label_DeviceCount.AutoSize = $True + $label_DeviceCount.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_DeviceCount.ForeColor = 'DarkGreen' + #$label_DeviceCount.TextAlign = 'MiddleRight' + $label_DeviceCount.Location = '20,85' + $label_DeviceCount.Name = 'Device_Count' + $label_DeviceCount.Size = '41, 13' + #$label_DeviceCount.TabIndex = 6 + $label_DeviceCount.Text = 'Device Count' + #$label_DeviceCount.add_Click($label_DeviceCount_Click) + + ############ Value ############ + $label_DeviceCount_Value.AutoSize = $True + $label_DeviceCount_Value.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_DeviceCount_Value.ForeColor = 'DarkGreen' + #$label_DeviceCount_Value.TextAlign = 'MiddleRight' + $label_DeviceCount_Value.Location = '140,85' + $label_DeviceCount_Value.Name = 'Device_Count_Value' + $label_DeviceCount_Value.Size = '41, 13' + #$label_DeviceCount_Value.TabIndex = 6 + $label_DeviceCount_Value.Text = '_' + #$label_DeviceCount_Value.add_Click($label_DeviceCount_Value_Click) + ############ + $Script:RadioButton_Window.Location = new-object System.Drawing.Point(15,15) + $Script:RadioButton_Window.size = New-Object System.Drawing.Size(130,20) + $Script:RadioButton_Window.Checked = $true + $Script:RadioButton_Window.Text = "Window" + #$Script:RadioButton_Window. + # + $Script:RadioButton_GridView.Location = new-object System.Drawing.Point(15,35) + $Script:RadioButton_GridView.size = New-Object System.Drawing.Size(80,20) + $Script:RadioButton_GridView.Checked = $False + $Script:RadioButton_GridView.Text = "GridView" + # + $Script:RadioButton_CSV.Location = new-object System.Drawing.Point(15,55) + $Script:RadioButton_CSV.size = New-Object System.Drawing.Size(80,20) + $Script:RadioButton_CSV.Checked = $False + $Script:RadioButton_CSV.Text = "CSV" + # + $Button_Go.Location = New-Object System.Drawing.Size(450,75) + $Button_Go.Size = New-Object System.Drawing.Size(110,80) + $Button_Go.Text = "Go" + #$Button_Go.Add_Click({temp}) + $Button_Go.Add_Click($Button_Go_Click) + # + $Script:TextBox_CollectionName.Left = 20; + $Script:TextBox_CollectionName.Top = 130; + $Script:TextBox_CollectionName.width = 200; + $Script:TextBox_CollectionName.Text = "Nabil - Test Collection" + # + ############################################################################ + Update-Dropdown1 + ConnectTo-SCCM + Deployment-List -Deployment_History 10 + $Script:Output.Text = "helloooooooo" + #cd c: + + + ############################################################################ + +#Save the initial state of the form + $InitialFormWindowState = $form1.WindowState + #Init the OnLoad event to correct the initial state of the form + $form1.add_Load($Form_StateCorrection_Load) + #Clean up the control events + $form1.add_FormClosed($Form_Cleanup_FormClosed) + #Show the Form + return $form1.ShowDialog() + +} #End Function + +#Call the form +Show-Form-Template_psf | Out-Null diff --git a/dump/SCCM-Tool/NA-Tool-GUI-9x.ps1 b/dump/SCCM-Tool/NA-Tool-GUI-9x.ps1 new file mode 100644 index 0000000..4c2910f --- /dev/null +++ b/dump/SCCM-Tool/NA-Tool-GUI-9x.ps1 @@ -0,0 +1,847 @@ +#------------------------------------------------------------------------ +# Source File Information (DO NOT MODIFY) +# Source ID: 676f8db7-35c7-452d-b353-a4b40f26243a +# Source File: Form-Template.psf +#------------------------------------------------------------------------ +#region File Recovery Data (DO NOT MODIFY) +<#RecoveryData: +RAUAAB+LCAAAAAAABAC9VNtKwzAYvhd8h5Dr2oPd3AZtYXTuxtNwQ72TrP07o2lSknSzPr3p2g1x +QkHGKJSk+Q7/KQ0eIRFrkNWEaILMQlHBQ3xpezg6P0MoeJB0RTlhU8rgnuQQTYXMLxaQF4xosAuV +Bc4BpmEu3yHRSFcFhHheKQ25/Ux5KjbKrkWat4X+OrLQUxtKz3brx0JxyXQpIeRQakmYhWblktHk +BqqF+AAeLgcD0k/6V97I74E7HGHETSghzoyeh1HyRlkqDQ7HgmspmGoSNIHOpChA6qoljEst5glh +MKE58DoIA72ykOcHzg7aRb0TKWBTKq47OTGjwPWcfhnCwDU+/nDYSaqrjKNtap3YBXxqvG3bIfR6 +bbxb3K0gaav5Wq8DZ3vaNNNputlsxkpBbooPaqfTfqmiXCVCMro8QgMDZ6/626UZmVN4HH0sux3r +m3gaI0k2lK/+4+X6WT8bZJ6X9l3ik26vl5ydJKdYSDi+0X7bjHzg/PxrRt9OzyrdRAUAAA==#> +#endregion + +<# + .NOTES + -------------------------------------------------------------------------------- + Code generated by: SAPIEN Technologies, Inc., PowerShell Studio 2017 v5.4.141 + Generated on: 8/29/2017 11:53 AM + Generated by: Haidey2 + -------------------------------------------------------------------------------- + .DESCRIPTION + GUI script generated by PowerShell Studio 2017 +#> + + +#---------------------------------------------- +#region Application Functions +#---------------------------------------------- + +#endregion Application Functions + +#---------------------------------------------- +# Generated Form Function +#---------------------------------------------- +function Show-Form-Template_psf { + + #---------------------------------------------- + #region Import the Assemblies + #---------------------------------------------- + [void][reflection.assembly]::Load('System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') + [void][reflection.assembly]::Load('System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') + [void][reflection.assembly]::Load('System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') + #endregion Import Assemblies + + #---------------------------------------------- + #region Generated Form Objects + #---------------------------------------------- + [System.Windows.Forms.Application]::EnableVisualStyles() + $form1 = New-Object 'System.Windows.Forms.Form' + $InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState' + + + $Script:Output = New-Object System.Windows.Forms.TextBox + + $Script:Output_Left = New-Object System.Windows.Forms.TextBox + $Script:Output_Right = New-Object System.Windows.Forms.TextBox + + $Script:Collection_DropDownBox = New-Object System.Windows.Forms.ComboBox + $Script:Deployment_DropDownBox = New-Object System.Windows.Forms.ComboBox + $Script:Combobox_Tools = New-Object System.Windows.Forms.ComboBox + + $GroupBox = New-Object System.Windows.Forms.GroupBox + $GroupBox_Info = New-Object System.Windows.Forms.GroupBox + + $Script:RadioButton_Window = New-Object System.Windows.Forms.RadioButton + $Script:RadioButton_GridView = New-Object System.Windows.Forms.RadioButton + $Script:RadioButton_CSV = New-Object System.Windows.Forms.RadioButton + $Button_Go = New-Object System.Windows.Forms.Button + $Script:TextBox_CollectionName = New-Object “System.Windows.Forms.TextBox” + + #$PanelEventLogs_Events = New-Object 'System.Windows.Forms.Panel' + #$PanelEventLogs_Filter = New-Object 'System.Windows.Forms.Panel' + + + #$Text_ELogs_ServerName = New-Object 'System.Windows.Forms.TextBox' + #$Text_ELogs_EventID = New-Object 'System.Windows.Forms.TextBox' + #$Text_Elogs_DaysBack = New-Object 'System.Windows.Forms.TextBox' + + $label_CollectionName = New-Object 'System.Windows.Forms.Label' + $label_CollectionName_Value = New-Object 'System.Windows.Forms.Label' + $label_DeploymentName = New-Object 'System.Windows.Forms.Label' + $label_DeploymentName_Value = New-Object 'System.Windows.Forms.Label' + $label_DeploymentTime = New-Object 'System.Windows.Forms.Label' + $label_DeploymentTime_Value = New-Object 'System.Windows.Forms.Label' + $label_DeviceCount = New-Object 'System.Windows.Forms.Label' + $label_DeviceCount_Value = New-Object 'System.Windows.Forms.Label' + + $Button_ELogs_Connect = New-Object 'System.Windows.Forms.Button' + + + + +# $Location = Split-Path $MyInvocation.MyCommand.Path -Parent + + $Script:ALL_Patch_Servers = @() + $Script:Responding = @() + $Script:NotResponding = @() + $Global:DeviceCollection_ServerNames1 = "" + + $Global:Collection_Name = "" + $Global:Select_Tool + $Global:Output_Type = "" + $Global:Deployments = "" + + #endregion Generated Form Objects + + #---------------------------------------------- + # User Generated Script + #---------------------------------------------- + + $form1_Load={ + #TODO: Initialize Form Controls here + + } + + $Script:Collection_DropDownBox_SelectedIndexChanged={ + + $Script:Output.Text = $Script:Collection_DropDownBox.Text + $T = Get-CMDeviceCollection -Name $Script:Collection_DropDownBox.text | select Name,MemberCount + + $label_DeviceCount_Value.Text = $T.MemberCount + + } + + $Script:Deployment_DropDownBox_SelectedIndexChanged={ + Reset-Forms -Form_Selection 1 + Deployed-to-Collections + $Script:Output.Text = $Script:Deployment_DropDownBox.Text + } + + $Script:Combobox_Tools_SelectedIndexChanged= { + $Script:Output.Text = $Script:Combobox_Tools.Text + + + } + + $Button_Go_Click = { + temp + #SCCM-Module + # $Global:Collection_Name = $Script:TextBox_CollectionName.Text #$Script:TextBox_CollectionName.Text + # $Global:Select_Tool = $Script:Combobox_Tools.Text + + + #$Output.Text = "$Global:Collection_Name --- $Global:Select_Tool " | Out-String + #$Output.Text = | Out-String + } + + +################################################################################################################## + Function ConnectTo-SCCM { + + If(!(Get-PSDrive).Name -ne "CCX") { + # + # Press 'F5' to run this script. Running this script will load the ConfigurationManager + # module for Windows PowerShell and will connect to the site. + # + # This script was auto-generated at '2/18/2021 10:12:39 AM'. + + # Uncomment the line below if running in an environment where script signing is + # required. + #Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process + + # Site configuration + $SiteCode = "CCX" # Site code + $ProviderMachineName = "PNCRASCCM001.ccx.carecentrix.com" # SMS Provider machine name + + # Customizations + $initParams = @{} + #$initParams.Add("Verbose", $true) # Uncomment this line to enable verbose logging + #$initParams.Add("ErrorAction", "Stop") # Uncomment this line to stop the script on any errors + + # Do not change anything below this line + + # Import the ConfigurationManager.psd1 module + if((Get-Module ConfigurationManager) -eq $null) { + Import-Module "$($ENV:SMS_ADMIN_UI_PATH)\..\ConfigurationManager.psd1" @initParams + } + + # Connect to the site's drive if it is not already present + if((Get-PSDrive -Name $SiteCode -PSProvider CMSite -ErrorAction SilentlyContinue) -eq $null) { + New-PSDrive -Name $SiteCode -PSProvider CMSite -Root $ProviderMachineName @initParams + } + + # Set the current location to be the site code. + Set-Location "$($SiteCode):\" @initParams + + #$Script:Output.Text = "inside connectoSCCM function" + }#endIf + }#endFunction +################################################################################################################## + Function SCCM-Module { + Write-Host "Inside SCCM function" -ForegroundColor Cyan + If(!(Get-PSDrive).Name -eq "sccm-drive") { + + Import-Module 'C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1' + New-PSDrive -Name SCCM-Drive -PSProvider "AdminUI.PS.Provider\CMSite" -Root "PNCRASCCM001.ccx.carecentrix.com" -Description "SCCM Site" + }#endIf + $Script:Output.Text | Get-PSDrive | ft -AutoSize | Out-String + CD sccm-drive: + }#endFunction +################################################################################################################## + Function Update-Dropdown1 { + # $Collections += $Script:Collection_DropDownBox.text + $Collections = @("Collection-Servers","Ping-Collection","Check_Uptime","Test-Service","Remotely Update Policy","Software Update Status","Test-Sccm") + $Collections | % { $Script:Combobox_Tools.Items.Add($_) } + } +################################################################################################################## + Function Reset-Forms { + Param($Form_Selection) + + Switch ($Form_Selection) { + 1 { $Collection_DropDownBox.Items.Clear(); $Collection_DropDownBox.Text = "--Deployed to Collections--" } + 2 {} + + } + + } +################################################################################################################## + Function temp { + $Script:Output.Clear() + $Script:Output_Left.Clear() + $Script:Output_Right.Clear() + #$Script:Script:Output.text = $Script:Collection_DropDownBox.text | Out-String + + #$Global:Collection_Name = $Script:TextBox_CollectionName.Text #$Script:TextBox_CollectionName.Text + $Global:Collection_Name = $Script:Collection_DropDownBox.Text + $Global:Select_Tool = $Script:Combobox_Tools.Text + + + If ($Script:RadioButton_Window.Checked -eq $true) { $Global:Output_Type = "Window" <#; $Script:Output.Text = "Window_Radio1 Checked: $($Script:RadioButton_Window.Checked)" | Out-String #> } + ElseIf ($Script:RadioButton_GridView.Checked -eq $true) { $Global:Output_Type = "Gridview" <#; $Script:Output.Text = "Gridview_Radio2 Checked: $($Script:RadioButton_GridView.Checked)" | Out-String #> } + ElseIf ($Script:RadioButton_CSV.Checked -eq $true) { $Global:Output_Type = "Export" <#; $Script:Output.Text = "CSV_Radio3 Checked: $($Script:RadioButton_CSV.Checked)" | Out-String #> } + + + If($Global:Collection_Name -and $Global:Select_Tool) { + # If($Script:Collection_DropDownBox.text = "Tool1"){gcc} + Run-Tool + #$Script:TextBox_CollectionName.clear() + $Script:Collection_DropDownBox.text = "----Select Collection----" + #Clear-Variables + }#endIf + Else { #$T = { Write-Host "You must enter Collection Name ............!!" -ForegroundColor Red } + $Script:Output.SelectionColor = 'red' + $Script:Output.Text = "You must select 'Tool' and enter Collection Name............!!" + } + + Run-Defaults + }#endFunction +################################################################################################################## + Function Run-Tool { + + Switch($Global:Select_Tool) { + Collection-Servers { Collection-Servers; Write-Host "Tool Selected: $Global:Select_Tool" } + Ping-Collection { Ping_Collection } + Check_Uptime { Check_Uptime } + Test-Service { Test-Service } + Test-SCCM { SCCM-Module } + #"Remotely Update Policy" { $Script:Output.Text = Invoke-Expression $Location\Tool-Remotely-Restart-SCCMSyncCycle.ps1 | ft -AutoSize | Out-String } + "Remotely Update Policy" { $Script:Output.Text = Invoke-Expression $Location\Tool-Remotely-Restart-SCCMSyncCycle.ps1 | ft -AutoSize | Out-String } + "Software Update Status" { $Script:Output.Text = & "$Location\Tool-Get-SCCMSoftwareUpdateStatus.ps1" -Dep_ID 16778048 | ft -AutoSize | Out-String} + }#endSwitch + #Clear-Variables + }#endFunction +################################################################################################################## + Function Run-Defaults { + #$Script:TextBox_CollectionName.Text = "Nabil - Test Collection" + $Script:RadioButton_Window.Checked = $true + + <# + If(!$Location) { + $Location = Split-Path $MyInvocation.MyCommand.Path -Parent + } + #> + } +################################################################################################################## + Function xClear-Variables { + $Global:Collection_Name = "" + $Global:Select_Tool = "" + $Global:Output_Type = "" + + $Script:ALL_Patch_Servers = @() + } +################################################################################################################## + Function Display-Results { + #Param($Global:Output_Type,$Final_Result) + Write-Host "DisplayType: $($Global:Output_Type)" + Switch ($Global:Output_Type){ + + Window { $Script:Output.Text = $Script:ALL_Patch_Servers | Out-String} + Gridview { $Script:ALL_Patch_Servers | Out-GridView } + Export { $Script:ALL_Patch_Servers | Export-Csv -Path $Location\Results.csv -NoTypeInformation; ii $Location\Results.csv } + + }#endSwitch + + } +############################################################################################################################################################# + Function Collection-Servers { + #Param($Coll_Name) + + Write-Host "Collection:$Global:Collection_Name" + $Script:ALL_Patch_Servers = @() + + ConnectTo-SCCM + NA-Set-Stage -Select_Stage OutputStage2 + #SCCM-Module + #CD sccm-drive: + $Script:DeviceCollection_MemberCount = Get-CMDeviceCollection -Name $Global:Collection_Name | select Name,MemberCount + $Script:DeviceCollection_ServerNames = Collection-Members #Get-CMCollectionMember -CollectionName $Global:Collection_Name | select Name,IsClient #| Export-Csv "E:\SCCM-Files\SCCM-Scripts\Files\$Global:Collection_Name.csv" -NoTypeInformation + #$ServerName = $DeviceCollection_ServerNames.Name + #Set-Location c: + + #$Script:Temp = Get-CMCollectionMember -CollectionName $Global:Collection_Name #| select Name,IsClient + + $Script:DeviceCollection_ServerNames | % { + $Obj = New-Object -TypeName PSObject + $Obj | Add-Member -MemberType NoteProperty -Name Server -Value $_.Name + $Obj | Add-Member -MemberType NoteProperty -Name ClientInstalled -Value $_.IsClient + $Obj | Add-Member -MemberType NoteProperty -Name CollectionName -Value $Global:Collection_Name + #$Obj | Add-Member -MemberType NoteProperty -Name CollectionMemberCount -Value {(Get-CMCollectionMember -Name $Global:Collection_Name).MemberCount} + + $Obj + $Script:ALL_Patch_Servers += $Obj + + }#end% + + # $Script:Output.Text = $Script:ALL_Patch_Servers | Out-String + Display-Results #-Final_Result $Script:ALL_Patch_Servers + Write-Host "$Script:ALL_Patch_Servers" + # $Script:ALL_Patch_Servers | Export-Csv $Location\Current-Collection-Servers.csv -NoTypeInformation + + }#endFunction +############################################################################################################################################################# + Function Collection-Members { + Get-CMCollectionMember -CollectionName $Global:Collection_Name | select Name,IsClient + + } + +############################################################################################################################################################# + Function NA-Set-Stage { + Param($Select_Stage) + Switch($Select_Stage) { + OutputStage1 { $Script:Output.Visible = $false + $Script:Output_Left.Visible = $True + $Script:Output_Right.Visible = $True + Write-Host "output-stage1" -ForegroundColor Yellow + } + OutputStage2 { $Script:Output.Visible = $True + $Script:Output_Left.Visible = $false + $Script:Output_Right.Visible = $false + } + test { $Script:Output.Text = "inside na set stage function"} + }#endSwitch + $Script:Output.Text = "outside switch inside na set stage function - param: $Select_Stage" + + + + }#endFunction +############################################################################################################################################################# + + Function Ping_Collection { + + $Ping_Result = @() + $NotResponding = @() + $Responding = @() + + ConnectTo-SCCM + + NA-Set-Stage -Select_Stage OutputStage1 + #$Script:Output.Visible = $false + #$Script:Output_Left.Visible = $True + #$Script:Output_Right.Visible = $True + + + $Global:DeviceCollection_ServerNames1 = Collection-Members #Get-CMCollectionMember -CollectionName $Global:Collection_Name | select Name + #Set-Location c: + + Write-Host "Total Server Count: $($Global:DeviceCollection_ServerNames1.count)" -ForegroundColor Green + Write-Host "" + + ############ + # $Script:Output.Text = "CollectionName: $($Global:Collection_Name) ------ hello " + ############ + $Global:DeviceCollection_ServerNames1.Name | % { + $Server = $_ + $Obj = New-Object -TypeName PSObject + $Count = $Global:DeviceCollection_ServerNames1.count + #$Script:Output.Text = "Checking: $Server ----- Servers left: $($Count--) Please Wait !!!" | Out-String + + If (Test-Connection $Server -Count 1 -ErrorAction SilentlyContinue ) { + #Write-Host "Responding:---- $_ " -ForegroundColor Green + #$Script:Output.AppendText("Responding: $_") + + $Obj | Add-Member -MemberType NoteProperty -Name Server -Value $Server + $Obj | Add-Member -MemberType NoteProperty -Name Responding -Value "Yes" + $Ping_Result += $Obj + #$Responding += $Server + $Responding += $Obj + # $Script:Output.text += $Obj | Out-String + }#endIf + + Else { + $Obj | Add-Member -MemberType NoteProperty -Name Server -Value $Server + $Obj | Add-Member -MemberType NoteProperty -Name Responding -Value "No!" + $Ping_Result += $Obj + #$NotResponding += $Server + $NotResponding += $Obj + # $Script:Output.text += $Obj | Out-String + } + }#end% + #$Script:Output.Text = $Ping_Result | ft -AutoSize | Out-String + $Script:Output_Left.Text = $Responding | Out-String + $Script:Output_Right.Text = $NotResponding | Out-String + write-host "-------------------------------------------------------" + Write-host "$($Responding.count) / $($DeviceCollection_ServerNames1.count) -- Responding" -foregroundcolor Green + Write-host "$($NotResponding.count) / $($DeviceCollection_ServerNames1.count) -- NOT Responding" -foregroundcolor Red + + #Write-Host "Servers NOT Responding: $NotResponding " -ForegroundColor Red + + }#endFunction +############################################################################################################################################################# + Function Check_Uptime { + ConnectTo-SCCM + $Global:DeviceCollection_ServerNames1 = Get-CMCollectionMember -CollectionName $Global:Collection_Name | select Name + $Script:Output.Text = $Global:DeviceCollection_ServerNames1.name | % { gwmi win32_operatingsystem -ComputerName $_ -ErrorAction SilentlyContinue | select @{n="Server";e={$_.PSComputername}},@{n="LastReboot";e={$_.Converttodatetime($_.LastBootUpTime)}}} | sort LastBootup -descending | Out-String + + } + +############################################################################################################################################################# + Function Deployment-List { + Param($Deployment_History) + # SCCM-Module + $Global:Deployments = Get-CMDeployment | ? { $_.deploymenttime -gt ((Get-Date).AddDays(-"$Deployment_History")) } + + #$T | select ApplicationName,CollectionName,DeploymentTime,AssignmentID,SoftwareName | % { $Deployment_DropDownBox.Items.Add($_) } + $i = 0 + $Q = "" #@() + + $Global:Deployments.ApplicationName | % { $Script:Deployment_DropDownBox.Items.Add($_)} + <# + foreach ($D in $Deployments) { + $Q = $D.ApplicationName + "-------------------------------------------------------" + $D.CollectionName + + $Deployment_DropDownBox.Items.Add($Q) + $i++ + } + #> + + #$T.ApplicationName | % { $Deployment_DropDownBox.Items.Add($_) } + + }#endFunction +############################################################################################################################################################# + Function Deployed-to-Collections { + $T = $Global:Deployments | ? { $_.ApplicationName -eq "$($Script:Deployment_DropDownBox.text)" } | Select -ExpandProperty CollectionName + $Script:Collection_DropDownBox.Items.Clear() + $T | % { $Script:Collection_DropDownBox.Items.Add("$_")} + } + +############################################################################################################################################################# + Function Test-Service { + + $Script:Output.Text = "test-service function" + #$T = Get-Service + #$Script:Output.Text = $T | ft -AutoSize | Out-String + } +################################################################################################################## + +################################################################################################################## + # --End User Generated Script-- + #---------------------------------------------- + #region Generated Events + #---------------------------------------------- + + $Form_StateCorrection_Load= + { + #Correct the initial state of the form to prevent the .Net maximized form issue + $form1.WindowState = $InitialFormWindowState + } + + $Form_Cleanup_FormClosed= + { + #Remove all event handlers from the controls + try + { + $form1.remove_Load($form1_Load) + $form1.remove_Load($Form_StateCorrection_Load) + $form1.remove_FormClosed($Form_Cleanup_FormClosed) + + #$PanelEventLogs_Events.remove_Paint($PanelEventLogs_Events_Paint) + #$PanelEventLogs_Filter.remove_Paint($PanelEventLogs_Filter_Paint) + + $Text_Elogs_DaysBack.remove_TextChanged($Text_Elogs_DaysBack_TextChanged) + $Text_ELogs_ServerName.remove_TextChanged($Text_ELogs_ServerName_TextChanged) + $Text_ELogs_EventID.remove_TextChanged($Text_ELogs_EventID_TextChanged) + + $Script:Output.remove_TextChanged($Output_TextChanged) + $Script:Output_Left.remove_TextChanged($Script:Output_Left_TextChanged) + $Script:Output_Right.remove_TextChanged($Script:Output_Right_TextChanged) + + $Script:Collection_DropDownBox.remove_SelectedIndexChanged($Script:Collection_DropDownBox_SelectedIndexChanged) + $Script:Deployment_DropDownBox.remove_SelectedIndexChanged($Script:Deployment_DropDownBox_SelectedIndexChanged) + $Script:Combobox_Tools.remove_SelectedIndexChanged($Script:Combobox_Tools_SelectedIndexChanged) + $Script:RadioButton_Window.remove_SelectedIndexChanged($Script:RadioButton_Window_SelectedIndexChanged) + $Script:RadioButton_GridView.remove_SelectedIndexChanged($Script:RadioButton_GridView_SelectedIndexChanged) + $Script:RadioButton_CSV.remove_SelectedIndexChanged($Script:RadioButton_CSV_SelectedIndexChanged) + $Button_Go.remove_Click($Button_Go_Click) + + } + catch { Out-Null <# Prevent PSScriptAnalyzer warning #> } + } + + + #$PanelEventLogs_Events_Paint=[System.Windows.Forms.PaintEventHandler]{ <#Event Argument: $_ = [System.Windows.Forms.PaintEventArgs]#> } + #$PanelEventLogs_Filter_Paint=[System.Windows.Forms.PaintEventHandler]{ } + + $Text_ELogs_ServerName_TextChanged={} + $Text_Elogs_DaysBack_TextChanged={} + + #endregion Generated Events + + #---------------------------------------------- + #region Generated Form Code + #---------------------------------------------- + # + # form1 + # + #$form1.Controls.Add($PanelEventLogs_Events) + #$form1.Controls.Add($PanelEventLogs_Filter) + + $form1.Controls.Add($Script:Output) + $form1.Controls.Add($Script:Output_Left) + $form1.Controls.Add($Script:Output_Right) + $form1.Controls.Add($Script:Collection_DropDownBox) + $form1.Controls.Add($Script:Deployment_DropDownBox) + $form1.Controls.Add($Script:Combobox_Tools) + $form1.Controls.Add($GroupBox) + $form1.Controls.Add($GroupBox_Info) + $form1.controls.Add($Script:RadioButton_Window) + $form1.controls.Add($Script:RadioButton_GridView) + $form1.Controls.Add($Script:RadioButton_CSV) + $form1.Controls.Add($Button_Go) + $form1.Controls.Add($Script:TextBox_CollectionName) + $form1.Controls.Add($label_CollectionName) + $form1.Controls.Add($label_CollectionName_Value) + $form1.Controls.Add($label_DeploymentName) + $form1.controls.Add($label_DeploymentName_Value) + $form1.Controls.Add($label_DeploymentTime) + $form1.Controls.Add($label_DeploymentTime_Value) + $form1.Controls.Add($label_DeviceCount) + $form1.Controls.Add($label_DeviceCount_Value) + + + $form1.AutoScaleDimensions = '6, 13' + $form1.AutoScaleMode = 'Font' + $form1.ClientSize = '1000, 800' + $form1.Name = 'form1' + $form1.Text = 'Form' + $form1.add_Load($form1_Load) + #endregion Generated Form Code + + #---------------------------------------------- +<# + $PanelEventLogs_Events.Controls.Add($Text_ELogs_ServerName) + $PanelEventLogs_Events.Controls.Add($Button_ELogs_Connect) + $PanelEventLogs_Events.Controls.Add($Button_ELogs_View) + $PanelEventLogs_Events.Controls.Add($Combobox_EventLogs_LogsList) + $PanelEventLogs_Events.Controls.Add($VCenterUserPassword) + $PanelEventLogs_Events.Controls.Add($CheckBoxUseWindowsLogin) + $PanelEventLogs_Events.Controls.Add($labelVCenterUserName) + $PanelEventLogs_Events.Controls.Add($labelVCenterPassword) + $PanelEventLogs_Events.Controls.Add($Script:Collection_DropDownBox) + $PanelEventLogs_Events.BackColor = '153,153,153' + $PanelEventLogs_Events.Location = '6, 6' + $PanelEventLogs_Events.Name = 'panelEventLogs_Events' + $PanelEventLogs_Events.Size = '598, 56' + $PanelEventLogs_Events.TabIndex = 0 + $PanelEventLogs_Events.add_Paint($PanelEventLogs_Events_Paint) + + $PanelEventLogs_Filter.Controls.Add($Combobox_ELogsFilter_Level) + $PanelEventLogs_Filter.Controls.Add($Text_ELogs_EventID) + $PanelEventLogs_Filter.Controls.Add($Text_Elogs_DaysBack) + $PanelEventLogs_Filter.Controls.Add($label_ELogs_Level) + $PanelEventLogs_Filter.Controls.Add($label_ELogs_EventID) + $PanelEventLogs_Filter.Controls.Add($label_ELogs_DaysBack) + $PanelEventLogs_Filter.BackColor = '255,255,212' + $PanelEventLogs_Filter.Location = '6, 62' + $PanelEventLogs_Filter.Name = 'PanelEventLogs_Filter' + $PanelEventLogs_Filter.Size = '598, 56' + $PanelEventLogs_Filter.BorderStyle = 'FixedSingle' + $PanelEventLogs_Filter.TabIndex = 0 + $PanelEventLogs_Filter.add_Paint($PanelEventLogs_Filter_Paint) +#> + # + # $Text_ELogs_ServerName + <# + $Text_ELogs_ServerName.Location = '8, 26' + $Text_ELogs_ServerName.Name = '$Text_ELogs_ServerName' + $Text_ELogs_ServerName.Size = '100, 20' + $Text_ELogs_ServerName.text = "l2012" + $Text_ELogs_ServerName.TabIndex = 6 + $Text_ELogs_ServerName.add_TextChanged($Text_ELogs_ServerName_TextChanged) + # + # + # Text_ELogs_EventID + # + $Text_ELogs_EventID.Location = '115, 26' + $Text_ELogs_EventID.Name = 'Text_ELogs_EventID' + $Text_ELogs_EventID.Size = '40, 20' + $Text_ELogs_EventID.TabIndex = 7 + $Text_ELogs_EventID.add_TextChanged($Text_ELogs_EventID_TextChanged) + # + # Text_Elogs_DaysBack + # + $Text_Elogs_DaysBack.Location = '175, 26' + $Text_Elogs_DaysBack.Name = 'Text_Elogs_DaysBack' + $Text_Elogs_DaysBack.Size = '40, 20' + $Text_Elogs_DaysBack.TabIndex = 7 + $Text_Elogs_DaysBack.add_TextChanged($Text_Elogs_DaysBack_TextChanged) + #> + # Output + # + $Script:Output.Location = '10, 250' + $Script:Output.Multiline = $True + $Script:Output.Name = 'Output' + $Script:Output.ScrollBars = 'both' + $Script:Output.Size = '965, 500' + $Script:Output.Font = 'Consolas, 8.25pt' + $Script:Output.WordWrap = $False + $Script:Output.TabIndex = 5 + $Script:Output.add_TextChanged($Output_TextChanged) + $Script:Output.Visible = $True + # + $Script:Output_Left.Location = '20, 250' + $Script:Output_Left.Multiline = $True + $Script:Output_Left.Name = 'Output_Left' + $Script:Output_Left.ScrollBars = 'both' + $Script:Output_Left.Size = '470, 500' + $Script:Output_Left.Font = 'Consolas, 8.25pt' + $Script:Output_Left.WordWrap = $False + #$Script:Output_Left.TabIndex = 5 + + $Script:Output_Left.add_TextChanged($Output_Left_TextChanged) + # + $Script:Output_Right.Location = '510, 250' + $Script:Output_Right.Multiline = $True + $Script:Output_Right.Name = 'Output_Right' + $Script:Output_Right.ScrollBars = 'both' + $Script:Output_Right.Size = '470, 500' + $Script:Output_Right.Font = 'Consolas, 8.25pt' + $Script:Output_Right.WordWrap = $False + #$Script:Output_Right.TabIndex = 5 + $Script:Output_Right.add_TextChanged($Output_Right_TextChanged) + # + # ComboboxServiceStartMode + # + $Script:Collection_DropDownBox.FormattingEnabled = $True + $Script:Collection_DropDownBox.Location = '20, 80' + $Script:Collection_DropDownBox.Name = 'Script:Collection_DropDownBox' + $Script:Collection_DropDownBox.Size = '180, 20' + $Script:Collection_DropDownBox.TabIndex = 2 + $Script:Collection_DropDownBox.Text = '--Deployed to Collections--' + $Script:Collection_DropDownBox.add_SelectedIndexChanged($Script:Collection_DropDownBox_SelectedIndexChanged) + # + $Script:Deployment_DropDownBox.Location = '20,30' + #$Script:Deployment_DropDownBox.Size = New-Object System.Drawing.Size(580,50) + $Script:Deployment_DropDownBox.Size = '580,50' + #$Script:Deployment_DropDownBox.DropDownHeight = 200 + $Script:Deployment_DropDownBox.text = "----Select Deployment----" + #$Script:Deployment_DropDownBox.Visible = $false + $Script:Deployment_DropDownBox.add_SelectedIndexChanged($Script:Deployment_DropDownBox_SelectedIndexChanged) + # + #$Script:Combobox_Tools.Size = New-Object System.Drawing.Size(180,20) + #$Script:Combobox_Tools.DropDownHeight = 200 + $Script:Combobox_Tools.text = "----Select Tool----!" + $Script:Combobox_Tools.Location = '20,170' + $Script:Combobox_Tools.Size = '180,10' + $Script:Combobox_Tools.add_SelectedIndexChanged($Script:Combobox_Tools_SelectedIndexChanged) + # + $groupBox.Location = '270,70' + $groupBox.size = New-Object System.Drawing.Size(150,90) + $groupBox.text = "Select Output:" + + + $GroupBox.Controls.Add($Script:RadioButton_Window) + $GroupBox.Controls.Add($Script:RadioButton_GridView) + $GroupBox.Controls.Add($Script:RadioButton_CSV) + # + $GroupBox_Info.Location = '670,25' + $GroupBox_Info.Size = '300,200' + $GroupBox_Info.Text = "Deployment Info" + ############ + $GroupBox_Info.Controls.Add($label_CollectionName) + $GroupBox_Info.Controls.Add($label_CollectionName_Value) + $GroupBox_Info.Controls.Add($label_DeploymentName) + $GroupBox_Info.Controls.Add($label_DeploymentName_Value) + $GroupBox_Info.Controls.Add($label_DeploymentTime) + $GroupBox_Info.Controls.Add($label_DeploymentTime_Value) + $GroupBox_Info.Controls.Add($label_DeviceCount) + $GroupBox_Info.Controls.Add($label_DeviceCount_Value) + ############ + $label_CollectionName.AutoSize = $True + $label_CollectionName.Font = 'Microsoft Sans Serif, 9.0pt' #, style=Bold' + #$label_CollectionName.ForeColor = 'DarkGreen' + #$label_CollectionName.TextAlign = 'MiddleRight' + $label_CollectionName.Location = '20,25' + $label_CollectionName.Name = 'Collection_Name' + $label_CollectionName.Size = '41, 13' + #$label_CollectionName.TabIndex = 6 + $label_CollectionName.Text = 'Collection Name:' + #$label_CollectionName.add_Click($label_CollectionName_Click) + + ############ Value ############### + $label_CollectionName_Value.AutoSize = $True + $label_CollectionName_Value.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_CollectionName_Value.ForeColor = 'DarkGreen' + #$label_CollectionName_Value.TextAlign = 'MiddleRight' + $label_CollectionName_Value.Location = '140,25' + $label_CollectionName_Value.Name = 'Collection_Name_Value' + $label_CollectionName_Value.Size = '41, 13' + #$label_CollectionName_Value.TabIndex = 6 + $label_CollectionName_Value.Text = '_' + #$label_CollectionName_Value.add_Click($label_CollectionName_Value_Click) + + ############ + $label_DeploymentName.AutoSize = $True + $label_DeploymentName.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_DeploymentName.ForeColor = 'DarkGreen' + #$label_DeploymentName.TextAlign = 'MiddleRight' + $label_DeploymentName.Location = '20,45' + $label_DeploymentName.Name = 'Deployment_Name' + $label_DeploymentName.Size = '41, 13' + #$label_DeploymentName.TabIndex = 6 + $label_DeploymentName.Text = 'Deployment Name:' + #$label_DeploymentName.add_Click($label_DeploymentName_Click) + + ############ Value ############ + $label_DeploymentName_Value.AutoSize = $True + $label_DeploymentName_Value.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_DeploymentName_Value.ForeColor = 'DarkGreen' + #$label_DeploymentName_Value.TextAlign = 'MiddleRight' + $label_DeploymentName_Value.Location = '140,45' + $label_DeploymentName_Value.Name = 'Deployment_Name_Value' + $label_DeploymentName_Value.Size = '41, 13' + #$label_DeploymentName_Value.TabIndex = 6 + $label_DeploymentName_Value.Text = '_' + #$label_DeploymentName_Value.add_Click($label_DeploymentName_Value_Click) + + ############# + $label_DeploymentTime.AutoSize = $True + $label_DeploymentTime.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_DeploymentTime.ForeColor = 'DarkGreen' + #$label_DeploymentTime.TextAlign = 'MiddleRight' + $label_DeploymentTime.Location = '20,65' + $label_DeploymentTime.Name = 'Deployment_Time' + $label_DeploymentTime.Size = '41, 13' + #$label_DeploymentTime.TabIndex = 6 + $label_DeploymentTime.Text = 'Deployment Time:' + #$label_DeploymentTime.add_Click($label_CollectionName_Click) + + ############ Value ############ + $label_DeploymentTime_Value.AutoSize = $True + $label_DeploymentTime_Value.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_DeploymentTime_Value.ForeColor = 'DarkGreen' + #$label_DeploymentTime_Value.TextAlign = 'MiddleRight' + $label_DeploymentTime_Value.Location = '140,65' + $label_DeploymentTime_Value.Name = 'Deployment_Time_Value' + $label_DeploymentTime_Value.Size = '41, 13' + #$label_DeploymentTime_Value.TabIndex = 6 + $label_DeploymentTime_Value.Text = '_' + #$label_DeploymentTime_Value.add_Click($label_DeploymentTime_Value_Click) + + ########### + $label_DeviceCount.AutoSize = $True + $label_DeviceCount.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_DeviceCount.ForeColor = 'DarkGreen' + #$label_DeviceCount.TextAlign = 'MiddleRight' + $label_DeviceCount.Location = '20,85' + $label_DeviceCount.Name = 'Device_Count' + $label_DeviceCount.Size = '41, 13' + #$label_DeviceCount.TabIndex = 6 + $label_DeviceCount.Text = 'Device Count' + #$label_DeviceCount.add_Click($label_DeviceCount_Click) + + ############ Value ############ + $label_DeviceCount_Value.AutoSize = $True + $label_DeviceCount_Value.Font = 'Microsoft Sans Serif, 8.50pt, style=Bold' + $label_DeviceCount_Value.ForeColor = 'DarkGreen' + #$label_DeviceCount_Value.TextAlign = 'MiddleRight' + $label_DeviceCount_Value.Location = '140,85' + $label_DeviceCount_Value.Name = 'Device_Count_Value' + $label_DeviceCount_Value.Size = '41, 13' + #$label_DeviceCount_Value.TabIndex = 6 + $label_DeviceCount_Value.Text = '_' + #$label_DeviceCount_Value.add_Click($label_DeviceCount_Value_Click) + ############ + $Script:RadioButton_Window.Location = new-object System.Drawing.Point(15,15) + $Script:RadioButton_Window.size = New-Object System.Drawing.Size(130,20) + $Script:RadioButton_Window.Checked = $true + $Script:RadioButton_Window.Text = "Window" + #$Script:RadioButton_Window. + # + $Script:RadioButton_GridView.Location = new-object System.Drawing.Point(15,35) + $Script:RadioButton_GridView.size = New-Object System.Drawing.Size(80,20) + $Script:RadioButton_GridView.Checked = $False + $Script:RadioButton_GridView.Text = "GridView" + # + $Script:RadioButton_CSV.Location = new-object System.Drawing.Point(15,55) + $Script:RadioButton_CSV.size = New-Object System.Drawing.Size(80,20) + $Script:RadioButton_CSV.Checked = $False + $Script:RadioButton_CSV.Text = "CSV" + # + $Button_Go.Location = New-Object System.Drawing.Size(450,75) + $Button_Go.Size = New-Object System.Drawing.Size(110,80) + $Button_Go.Text = "Go" + #$Button_Go.Add_Click({temp}) + $Button_Go.Add_Click($Button_Go_Click) + # + $Script:TextBox_CollectionName.Left = 20; + $Script:TextBox_CollectionName.Top = 130; + $Script:TextBox_CollectionName.width = 200; + $Script:TextBox_CollectionName.Text = "Nabil - Test Collection" + # + ############################################################################ + Update-Dropdown1 + ConnectTo-SCCM + Deployment-List -Deployment_History 10 + $Script:Output.Text = "helloooooooo" + #cd c: + + + ############################################################################ + +#Save the initial state of the form + $InitialFormWindowState = $form1.WindowState + #Init the OnLoad event to correct the initial state of the form + $form1.add_Load($Form_StateCorrection_Load) + #Clean up the control events + $form1.add_FormClosed($Form_Cleanup_FormClosed) + #Show the Form + return $form1.ShowDialog() + +} #End Function + +#Call the form +Show-Form-Template_psf | Out-Null diff --git a/dump/SCCM-Tool/Old-Versions/NA-Tool-GUI.ps1 b/dump/SCCM-Tool/Old-Versions/NA-Tool-GUI.ps1 new file mode 100644 index 0000000..e16ec00 --- /dev/null +++ b/dump/SCCM-Tool/Old-Versions/NA-Tool-GUI.ps1 @@ -0,0 +1,293 @@ +$Location = Split-Path $MyInvocation.MyCommand.Path -Parent + +$Script:ALL_Patch_Servers = @() +$Script:Responding = @() +$Script:NotResponding = @() +$Global:Collection_Name = "" +$Global:Select_Tool +$Global:Output_Type = "" + +If(!(Get-PSDrive -Name SCCM-Drive -ErrorAction SilentlyContinue)) { + Import-Module 'C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1' + New-PSDrive -Name SCCM-Drive -PSProvider "AdminUI.PS.Provider\CMSite" -Root "PNCRASCCM001.ccx.carecentrix.com" -Description "SCCM Site" +} +######################################################################################################################################################### +Function Start-Form { + + #$Global:Collection_Name = "" + #$Global:Select_Tool = "" + #$Global:Output_Type = "" + + $Temp = "" + + [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") + [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") + + $Form = New-Object System.Windows.Forms.Form + $Form.Size = New-Object System.Drawing.Size(900,500) + ############################################## + #$Form_Load={ $Script:outputBox.text = "Welcome" } + ############################################## Start functions + <# function pingInfo { + + if ($RadioButton1.Checked -eq $true) {$nrOfPings=1} + if ($RadioButton2.Checked -eq $true) {$nrOfPings=2} + if ($RadioButton3.Checked -eq $true) {$nrOfPings=3} + + $computer=$DropDownBox.SelectedItem.ToString() #populate the var with the value you selected + $pingResult=ping $wks -n $nrOfPings | fl | out-string; + $Script:outputBox.text=$pingResult + + } #end pingInfo + #> + ############################################## end functions + Function SCCM-Module { + + If(!(Get-PSDrive).Name -eq "sccm-drive") { + Import-Module 'C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1' + New-PSDrive -Name SCCM-Drive -PSProvider "AdminUI.PS.Provider\CMSite" -Root "PNCRASCCM001.ccx.carecentrix.com" -Description "SCCM Site" + }#endIf + CD sccm-drive: + }#endFunction + ############################################## + Function Run-Defaults { + $Script:textBox1.Text = "Nabil - Test Collection" + $Script:RadioButton1.Checked = $true + } + ############################################## + Function temp { + $outputBox.Clear() + #$Script:outputBox.text = $textBox1.text | Out-String + $Global:Collection_Name = $textBox1.Text + #$Global:Select_Tool = $RadioButton1.Checked + + $Global:Select_Tool = $DropDownBox.text + #$Global:Output_Type = + If ($RadioButton1.Checked -eq $true) { $Global:Output_Type = "Window"; $outputBox.Text = "Radio1 Checked: $($RadioButton1.Checked)" | Out-String } + ElseIf ($RadioButton2.Checked -eq $true) { $Global:Output_Type = "Gridview"; $outputBox.Text = "Radio2 Checked: $RadioButton2.Checked" | Out-String } + ElseIf ($RadioButton3.Checked -eq $true) { $Global:Output_Type = "Export"; $outputBox.Text = "Radio3 Checked: $RadioButton2.Checked" | Out-String } + + If($Global:Collection_Name -and $Global:Select_Tool) { + # If($DropDownBox.text = "Tool1"){gcc} + Run-Tool + $textBox1.clear() + $DropDownBox.text = "----Select Tool----" + Clear-Variables + }#endIf + Else { #$T = { Write-Host "You must enter Collection Name ............!!" -ForegroundColor Red } + $Script:outputBox.SelectionColor = 'red' + $Script:outputBox.Text = "You must select 'Tool' and enter Collection Name............!!" + } + Run-Defaults + }#endFunction + ############################################## + Function Update-Dropdown1 { + # $Collections += $textBox1.text + $Collections = @("Collection-Servers","Ping-Collection","Check_Uptime","Tool4","Tool5","Tool6","Tool7") + $Collections | % { $DropDownBox.Items.Add($_) } + } + ############################################## + Function gcc { + $Script:outputBox.text = Get-Service | Out-String + } + ############################################## + Function Clear-Variables { + $Global:Collection_Name = "" + $Global:Select_Tool = "" + $Global:Output_Type = "" + + $Script:ALL_Patch_Servers = @() + } +#region Controls + ############################################## Start group boxes + $groupBox = New-Object System.Windows.Forms.GroupBox + $groupBox.Location = New-Object System.Drawing.Size(270,20) + $groupBox.size = New-Object System.Drawing.Size(150,110) + $groupBox.text = "Select Output:" + $Form.Controls.Add($groupBox) + ############################################## end group boxes + + ############################################## Start radio buttons + $Script:RadioButton1 = New-Object System.Windows.Forms.RadioButton + $Script:RadioButton1.Location = new-object System.Drawing.Point(15,15) + $Script:RadioButton1.size = New-Object System.Drawing.Size(130,20) + $Script:RadioButton1.Checked = $true + $Script:RadioButton1.Text = "Window" + $groupBox.Controls.Add($RadioButton1) + + $Script:RadioButton2 = New-Object System.Windows.Forms.RadioButton + $Script:RadioButton2.Location = new-object System.Drawing.Point(15,35) + $Script:RadioButton2.size = New-Object System.Drawing.Size(80,20) + $Script:RadioButton2.Text = "Gridview" + $groupBox.Controls.Add($RadioButton2) + + $Script:RadioButton3 = New-Object System.Windows.Forms.RadioButton + $Script:RadioButton3.Location = new-object System.Drawing.Point(15,55) + $Script:RadioButton3.size = New-Object System.Drawing.Size(80,20) + $Script:RadioButton3.Text = "Export csv" + $groupBox.Controls.Add($RadioButton3) + + ############################################## end radio buttons + ########### Text Box ########### + ############Define text box1 for input + $Script:textBox1 = New-Object “System.Windows.Forms.TextBox”; + $Script:textBox1.Left = 20; + $Script:textBox1.Top = 30; + $Script:textBox1.width = 200; + $Script:textBox1.Text = "Nabil - Test Collection" + $Form.Controls.Add($textBox1) + ############################################## Start drop down boxes + + $Script:DropDownBox = New-Object System.Windows.Forms.ComboBox + $Script:DropDownBox.Location = New-Object System.Drawing.Size(20,80) + $Script:DropDownBox.Size = New-Object System.Drawing.Size(180,20) + $Script:DropDownBox.DropDownHeight = 200 + $Script:DropDownBox.text = "----Select Tool----" + $Form.Controls.Add($DropDownBox) + + ############################################## end drop down boxes + + <############################################## Start text fields + + $Script:outputBox = New-Object System.Windows.Forms.TextBox + $Script:outputBox.Location = New-Object System.Drawing.Size(10,150) + $Script:outputBox.Size = New-Object System.Drawing.Size(865,300) + $Script:outputBox.MultiLine = $True + + $Script:outputBox.ScrollBars = "Vertical" + $Form.Controls.Add($Script:outputBox) + ###########> + $SCRIPT:outputBox=New-Object System.Windows.Forms.RichTextBox + $outputBox.Location=New-Object System.Drawing.Size(10,150) + $outputBox.Size=New-Object System.Drawing.Size(865,300) + $outputBox.Multiline=$True + $outputBox.ReadOnly = $True + $outputBox.BackColor = [Drawing.Color]::White + $outputBox.ScrollBars = "Vertical" + $form.Controls.Add($Script:outputBox) + + + + + ############################################## end text fields + + ############################################## Start buttons + + $Button = New-Object System.Windows.Forms.Button + $Button.Location = New-Object System.Drawing.Size(450,30) + $Button.Size = New-Object System.Drawing.Size(110,80) + $Button.Text = "Go" + $Button.Add_Click({temp}) + $Form.Controls.Add($Button) +#endregion Controls + ############################################## end buttons + Update-Dropdown1 + + $Form.Add_Shown({$Form.Activate()}) + [void] $Form.ShowDialog() + +} +######################################################################################################################################################### + <# Function Input-Box { + [void][System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic') + $Global:Collection_Name = [Microsoft.VisualBasic.Interaction]::InputBox("Enter your name", "Name", "Enter Collection Name") + + } + #> +############################################################################################################################################################# + Function Display-Results { + #Param($Global:Output_Type,$Final_Result) + Write-Host "DisplayType: $($Global:Output_Type)" + Switch ($Global:Output_Type){ + + Window { $Script:outputBox.Text = $Script:ALL_Patch_Servers | Out-String} + Gridview { $Script:ALL_Patch_Servers | Out-GridView } + Export { $Script:ALL_Patch_Servers | Export-Csv -Path $Location\Results.csv -NoTypeInformation; ii $Location\Results.csv } + + }#endSwitch + + } +############################################################################################################################################################# + Function Collection-Servers { + #Param($Coll_Name) + + Write-Host "Collection:$Global:Collection_Name" + + SCCM-Module + #CD sccm-drive: + $Script:DeviceCollection_MemberCount = Get-CMDeviceCollection -Name $Global:Collection_Name | select Name,MemberCount + $Script:DeviceCollection_ServerNames = Get-CMCollectionMember -CollectionName $Global:Collection_Name | select Name,IsClient #| Export-Csv "E:\SCCM-Files\SCCM-Scripts\Files\$Global:Collection_Name.csv" -NoTypeInformation + #$ServerName = $DeviceCollection_ServerNames.Name + Set-Location c: + + #$Script:Temp = Get-CMCollectionMember -CollectionName $Global:Collection_Name #| select Name,IsClient + + $Script:DeviceCollection_ServerNames | % { + $Obj = New-Object -TypeName PSObject + $Obj | Add-Member -MemberType NoteProperty -Name Server -Value $_.Name + $Obj | Add-Member -MemberType NoteProperty -Name ClientInstalled -Value $_.IsClient + $Obj | Add-Member -MemberType NoteProperty -Name CollectionName -Value $Global:Collection_Name + #$Obj | Add-Member -MemberType NoteProperty -Name CollectionMemberCount -Value {(Get-CMCollectionMember -Name $Global:Collection_Name).MemberCount} + + $Obj + $Script:ALL_Patch_Servers += $Obj + + }#end% + + # $Script:outputBox.Text = $Script:ALL_Patch_Servers | Out-String + Display-Results #-Final_Result $Script:ALL_Patch_Servers + Write-Host "$Script:ALL_Patch_Servers" + + }#endFunction +############################################################################################################################################################# + Function Ping_Collection { + + Write-Host "Total Server Count: $($Script:ALL_Patch_Servers.count)" -ForegroundColor Green + Write-Host "" + + SCCM-Module + #CD sccm-drive: + $Script:DeviceCollection_ServerNames1 = Get-CMCollectionMember -CollectionName $Global:Collection_Name | select Name + Set-Location c: + $Script:DeviceCollection_ServerNames1.Name | % { + + If (Test-Connection $_ -Count 1 -ErrorAction SilentlyContinue ) { + #Write-Host "Responding:---- $_ " -ForegroundColor Green + $Script:outputBox.AppendText("Responding: $_") + + $Responding += $_ + + }#endIf + + Else { + $Script:outputBox.AppendText("NOT Responding: $_") + $NotResponding += $_ } + + }#end% + write-host "-------------------------------------------------------" + Write-host "$($Responding.count) / $($DeviceCollection_ServerNames1.count) -- Responding" -foregroundcolor Green + Write-host "$($NotResponding.count) / $($DeviceCollection_ServerNames1.count) -- NOT Responding" -foregroundcolor Red + + Write-Host "Servers NOT Responding: $NotResponding " -ForegroundColor Red + + }#endFunction +############################################################################################################################################################# + Function Check_Uptime { + SCCM-Module + $Script:DeviceCollection_ServerNames1 = Get-CMCollectionMember -CollectionName $Global:Collection_Name | select Name + $Script:outputBox.Text = $Script:DeviceCollection_ServerNames1.name | % { gwmi win32_operatingsystem -ComputerName $_ -ErrorAction SilentlyContinue | select @{n="Server";e={$_.PSComputername}},@{n="LastBootup";e={$_.Converttodatetime($_.LastBootUpTime)}}} | sort LastBootup -descending | Out-String + + } +############################################################################################################################################################# + Function Run-Tool { + + Switch($Global:Select_Tool) { + Collection-Servers { Collection-Servers; Write-Host "Tool Selected: $Global:Select_Tool" } + Ping-Collection { Ping_Collection } + Check_Uptime { Check_Uptime } + }#endSwitch + #Clear-Variables + }#endFunction +############################################################################################################################################################# +Start-Form + diff --git a/dump/SCCM-Tool/Old-Versions/Tool-Remotely-Restart-SCCMSyncCycle.ps1 b/dump/SCCM-Tool/Old-Versions/Tool-Remotely-Restart-SCCMSyncCycle.ps1 new file mode 100644 index 0000000..99afeb7 --- /dev/null +++ b/dump/SCCM-Tool/Old-Versions/Tool-Remotely-Restart-SCCMSyncCycle.ps1 @@ -0,0 +1,130 @@ +Function Restart-SCCMSyncCycle { +<# +.Synopsis + Remotely restarts sccm service cycles. + + +.DESCRIPTION + This function restarts all sccm policies on a remote client so that the client can immediately get any pending software updates or inventory. + + +.NOTES + Name: Restart-SCCMSyncCycle + Author: theSysadminChannel + Version: 1 + DateCreated: 2017-02-09 + + +.LINK + https://thesysadminchannel.com/remotely-restart-sccmsynccycle-using-powershell - + + +.PARAMETER ComputerName + The computer to which connectivity will be checked + + +.EXAMPLE + Restart-SCCMSyncCycle -Computername Pactest-1 + + Description: + Will restart all sccm services on a remote machine. + +.EXAMPLE + Restart-SCCMSyncCycle -ComputerName pactest-1, pactest-2, pactest-3 + + Description: + Will generate a list of installed programs on pactest-1, pactest-2 and pactest-3 + +#> + + + [CmdletBinding()] + param( + [Parameter( + ValueFromPipeline=$true, + ValueFromPipelineByPropertyName=$true, + Position=0)] + [string[]] $ComputerName = $env:COMPUTERNAME + + ) + + Foreach ($Computer in $ComputerName ) { + try { + + Write-Host "=====================================================================" + Write-Output "$Computer : Machine Policy Evaluation Cycle" + Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000022}" -ErrorAction Stop | select -ExpandProperty PSComputerName | Out-Null + + + Write-Output "$Computer : Application Deployment Evaluation Cycle" + Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000121}" | select -ExpandProperty PSComputerName | Out-Null + + + # Write-Output "$Computer : Discovery Data Collection Cycle" + # Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000003}" | select -ExpandProperty PSComputerName | Out-Null + + + # Write-Output "$Computer : File Collection Cycle" + # Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000010}" | select -ExpandProperty PSComputerName | Out-Null + + + # Write-Output "$Computer : Hardware Inventory Cycle" + # Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000001}" | select -ExpandProperty PSComputerName | Out-Null + + + Write-Output "$Computer : Machine Policy Retrieval Cycle" + Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000021}" | select -ExpandProperty PSComputerName | Out-Null + + + Write-Output "$Computer : Software Inventory Cycle" + Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000002}" | select -ExpandProperty PSComputerName | Out-Null + + + # Write-Output "$Computer : Software Metering Usage Report Cycle" + # Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000031}" | select -ExpandProperty PSComputerName | Out-Null + + + Write-Output "$Computer : Software Update Deployment Evaluation Cycle" + Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000114}" | select -ExpandProperty PSComputerName | Out-Null + + + #Write-Output "$Computer : Software Update Scan Cycle" + #Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000113}" | select -ExpandProperty PSComputerName | Out-Null + + + # Write-Output "$Computer : State Message Refresh" + # Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000111}" | select -ExpandProperty PSComputerName | Out-Null + + + #Write-Output "$Computer : User Policy Retrieval Cycle" + #Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000026}" | select -ExpandProperty PSComputerName | Out-Null + + + #Write-Output "$Computer : User Policy Evaluation Cycle" + #Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000027}" | select -ExpandProperty PSComputerName | Out-Null + + + # Write-Output "$Computer : Windows Installers Source List Update Cycle" + # Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000032}" | select -ExpandProperty PSComputerName | Out-Null + + sleep 1 + } + + catch { + Write-Host $Computer.toUpper() "is not online or Account is locked out" -ForegroundColor:Red + Write-Host + Write-Host + + } + } +} + + +# Restart-SCCMSyncCycle pver001 +# Restart-SCCMSyncCycle + +# Restart-SCCMSyncCycle $DeviceCollection_ServerNames.name + +Restart-SCCMSyncCycle w2012a,w2012b + + diff --git a/dump/SCCM-Tool/Results.csv b/dump/SCCM-Tool/Results.csv new file mode 100644 index 0000000..a295f3b --- /dev/null +++ b/dump/SCCM-Tool/Results.csv @@ -0,0 +1,3 @@ +"Server","ClientInstalled","CollectionName" +"W2012A","True","Nabil - Test Collection" +"W2012B","True","Nabil - Test Collection" diff --git a/dump/SCCM-Tool/Tool-Deployment-List.ps1 b/dump/SCCM-Tool/Tool-Deployment-List.ps1 new file mode 100644 index 0000000..34d088e --- /dev/null +++ b/dump/SCCM-Tool/Tool-Deployment-List.ps1 @@ -0,0 +1,5 @@ + $T = Get-CMDeployment | ? { $_.deploymenttime -gt ((Get-Date).AddDays(-30)) } + + + + diff --git a/dump/SCCM-Tool/Tool-Get-SCCMSoftwareUpdateStatus.ps1 b/dump/SCCM-Tool/Tool-Get-SCCMSoftwareUpdateStatus.ps1 new file mode 100644 index 0000000..2fe9358 --- /dev/null +++ b/dump/SCCM-Tool/Tool-Get-SCCMSoftwareUpdateStatus.ps1 @@ -0,0 +1,149 @@ +param($Dep_ID) + +Get-SCCMSoftwareUpdateStatus -DeploymentID $Dep_ID + +function Get-SCCMSoftwareUpdateStatus { +<# +.Synopsis + This will output the device status for the Software Update Deployments within SCCM. + For updated help and examples refer to -Online version. + + +.DESCRIPTION + This will output the device status for the Software Update Deployments within SCCM. + For updated help and examples refer to -Online version. + + +.NOTES + Name: Get-SCCMSoftwareUpdateStatus + Author: The Sysadmin Channel + Version: 1.0 + DateCreated: 2018-Nov-10 + DateUpdated: 2018-Nov-10 + +.LINK + https://thesysadminchannel.com/get-sccm-software-update-status-powershell - + + +.EXAMPLE + For updated help and examples refer to -Online version. + +#> + + [CmdletBinding()] + + param( + [Parameter()] + [switch] $DeploymentIDFromGUI, + + [Parameter(Mandatory = $false)] + [Alias('ID', 'AssignmentID')] + [string] $DeploymentID, + + [Parameter(Mandatory = $false)] + [ValidateSet('Success', 'InProgress', 'Error', 'Unknown')] + [Alias('Filter')] + [string] $Status + + + ) + + BEGIN { + $Site_Code = 'CCX' + $Site_Server = 'PNCRASCCM001' + $HasErrors = $False + + if ($Status -eq 'Success') { + $StatusType = 1 + } + + if ($Status -eq 'InProgress') { + $StatusType = 2 + } + + if ($Status -eq 'Unknown') { + $StatusType = 4 + } + + if ($Status -eq 'Error') { + $StatusType = 5 + } + + } + + PROCESS { + + try { + if ($DeploymentID -and $DeploymentIDFromGUI) { + Write-Error "Select the DeploymentIDFromGUI or DeploymentID Parameter. Not Both" + $HasErrors = $True + throw + } + + if ($DeploymentIDFromGUI) { + $ShellLocation = Get-Location + Import-Module (Join-Path $(Split-Path $env:SMS_ADMIN_UI_PATH) ConfigurationManager.psd1) + + #Checking to see if module has been imported. If not abort. + if (Get-Module ConfigurationManager) { + Set-Location "$($Site_Code):\" + $DeploymentID = Get-CMSoftwareUpdateDeployment | select AssignmentID, AssignmentName | Out-GridView -OutputMode Single -Title "Select a Deployment and Click OK" | Select -ExpandProperty AssignmentID + Set-Location $ShellLocation + } else { + Write-Error "The SCCM Module wasn't imported successfully. Aborting." + $HasErrors = $True + throw + } + } + + if ($DeploymentID) { + $DeploymentNameWithID = Get-WMIObject -ComputerName $Site_Server -Namespace root\sms\site_$Site_Code -class SMS_SUMDeploymentAssetDetails -Filter "AssignmentID = $DeploymentID" | select AssignmentID, AssignmentName + $DeploymentName = $DeploymentNameWithID.AssignmentName | select -Unique + } else { + Write-Error "A Deployment ID was not specified. Aborting." + $HasErrors = $True + throw + } + + if ($Status) { + $Output = Get-WMIObject -ComputerName $Site_Server -Namespace root\sms\site_$Site_Code -class SMS_SUMDeploymentAssetDetails -Filter "AssignmentID = $DeploymentID and StatusType = $StatusType" | ` + select DeviceName, CollectionName, @{Name = 'StatusTime'; Expression = {$_.ConvertToDateTime($_.StatusTime) }}, @{Name = 'Status' ; Expression = {if ($_.StatusType -eq 1) {'Success'} elseif ($_.StatusType -eq 2) {'InProgress'} elseif ($_.StatusType -eq 5) {'Error'} elseif ($_.StatusType -eq 4) {'Unknown'} }} + + } else { + $Output = Get-WMIObject -ComputerName $Site_Server -Namespace root\sms\site_$Site_Code -class SMS_SUMDeploymentAssetDetails -Filter "AssignmentID = $DeploymentID" | ` + select DeviceName, CollectionName, @{Name = 'StatusTime'; Expression = {$_.ConvertToDateTime($_.StatusTime) }}, @{Name = 'Status' ; Expression = {if ($_.StatusType -eq 1) {'Success'} elseif ($_.StatusType -eq 2) {'InProgress'} elseif ($_.StatusType -eq 5) {'Error'} elseif ($_.StatusType -eq 4) {'Unknown'} }} + } + + if (-not $Output) { + Write-Error "A Deployment with ID: $($DeploymentID) is not valid. Aborting" + $HasErrors = $True + throw + + } + + } catch { + + + } finally { + if (($HasErrors -eq $false) -and ($Output)) { + Write-Output "" + Write-Output "Deployment Name: $DeploymentName" + Write-Output "Deployment ID: $DeploymentID" + Write-Output "" + Write-Output $Output | Sort-Object Status + } + } + } + + END {} + +} + + + + +# $T = Get-SCCMSoftwareUpdateStatus -DeploymentID 16778048 + +# Get-SCCMSoftwareUpdateStatus -DeploymentIDFromGUI | ? { $_.Assignmentname -like "dsfsdfsd" } + +# Get-SCCMSoftwareUpdateStatus -DeploymentIDFromGUI diff --git a/dump/SCCM-Tool/Tool-Remotely Restart-SCCMSyncCycle.ps1 b/dump/SCCM-Tool/Tool-Remotely Restart-SCCMSyncCycle.ps1 new file mode 100644 index 0000000..104155c --- /dev/null +++ b/dump/SCCM-Tool/Tool-Remotely Restart-SCCMSyncCycle.ps1 @@ -0,0 +1,132 @@ +$Location1 = Split-Path $MyInvocation.MyCommand.Path -Parent + +Function Restart-SCCMSyncCycle { +<# +.Synopsis + Remotely restarts sccm service cycles. + + +.DESCRIPTION + This function restarts all sccm policies on a remote client so that the client can immediately get any pending software updates or inventory. + + +.NOTES + Name: Restart-SCCMSyncCycle + Author: theSysadminChannel + Version: 1 + DateCreated: 2017-02-09 + + +.LINK + https://thesysadminchannel.com/remotely-restart-sccmsynccycle-using-powershell - + + +.PARAMETER ComputerName + The computer to which connectivity will be checked + + +.EXAMPLE + Restart-SCCMSyncCycle -Computername Pactest-1 + + Description: + Will restart all sccm services on a remote machine. + +.EXAMPLE + Restart-SCCMSyncCycle -ComputerName pactest-1, pactest-2, pactest-3 + + Description: + Will generate a list of installed programs on pactest-1, pactest-2 and pactest-3 + +#> + + + [CmdletBinding()] + param( + [Parameter( + ValueFromPipeline=$true, + ValueFromPipelineByPropertyName=$true, + Position=0)] + [string[]] $ComputerName = $env:COMPUTERNAME + + ) + + Foreach ($Computer in $ComputerName ) { + try { + + Write-Host "=====================================================================" + Write-Output "$Computer : Machine Policy Evaluation Cycle" + Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000022}" -ErrorAction Stop | select -ExpandProperty PSComputerName | Out-Null + + + Write-Output "$Computer : Application Deployment Evaluation Cycle" + Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000121}" | select -ExpandProperty PSComputerName | Out-Null + + + # Write-Output "$Computer : Discovery Data Collection Cycle" + # Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000003}" | select -ExpandProperty PSComputerName | Out-Null + + + # Write-Output "$Computer : File Collection Cycle" + # Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000010}" | select -ExpandProperty PSComputerName | Out-Null + + + # Write-Output "$Computer : Hardware Inventory Cycle" + # Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000001}" | select -ExpandProperty PSComputerName | Out-Null + + + Write-Output "$Computer : Machine Policy Retrieval Cycle" + Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000021}" | select -ExpandProperty PSComputerName | Out-Null + + + Write-Output "$Computer : Software Inventory Cycle" + Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000002}" | select -ExpandProperty PSComputerName | Out-Null + + + # Write-Output "$Computer : Software Metering Usage Report Cycle" + # Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000031}" | select -ExpandProperty PSComputerName | Out-Null + + + Write-Output "$Computer : Software Update Deployment Evaluation Cycle" + Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000114}" | select -ExpandProperty PSComputerName | Out-Null + + + #Write-Output "$Computer : Software Update Scan Cycle" + #Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000113}" | select -ExpandProperty PSComputerName | Out-Null + + + # Write-Output "$Computer : State Message Refresh" + # Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000111}" | select -ExpandProperty PSComputerName | Out-Null + + + #Write-Output "$Computer : User Policy Retrieval Cycle" + #Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000026}" | select -ExpandProperty PSComputerName | Out-Null + + + #Write-Output "$Computer : User Policy Evaluation Cycle" + #Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000027}" | select -ExpandProperty PSComputerName | Out-Null + + + # Write-Output "$Computer : Windows Installers Source List Update Cycle" + # Invoke-WMIMethod -ComputerName $Computer -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000032}" | select -ExpandProperty PSComputerName | Out-Null + + sleep 1 + } + + catch { + Write-Host $Computer.toUpper() "is not online or Account is locked out" -ForegroundColor:Red + Write-Host + Write-Host + + } + } +} + + +# Restart-SCCMSyncCycle pver001 +# Restart-SCCMSyncCycle + +# Restart-SCCMSyncCycle $DeviceCollection_ServerNames.name +$Collection_Servers = Import-Csv $Location1\Current-Collection-Servers.csv +Restart-SCCMSyncCycle w2012a,w2012b $Collection_Servers.Server + + diff --git a/dump/SCCM-Tool/test1.ps1 b/dump/SCCM-Tool/test1.ps1 new file mode 100644 index 0000000..7b9d9b8 --- /dev/null +++ b/dump/SCCM-Tool/test1.ps1 @@ -0,0 +1,26 @@ +$NotResponding = @() +$Ping_Result = @() + $Script:DeviceCollection_ServerNames1.Name | % { + $Server = $_ + $Obj = New-Object -TypeName PSObject + + If (Test-Connection $Server -Count 1 -ErrorAction SilentlyContinue ) { + #Write-Host "Responding:---- $_ " -ForegroundColor Green + #$Script:Output.AppendText("Responding: $_") + + $Obj | Add-Member -MemberType NoteProperty -Name Server -Value $Server + $Obj | Add-Member -MemberType NoteProperty -Name Responding -Value "Yes" + $Ping_Result += $Obj + + }#endIf + + Else { + + $NotResponding += $Server + $Obj | Add-Member -MemberType NoteProperty -Name Server -Value $Server + $Obj | Add-Member -MemberType NoteProperty -Name Responding -Value "No!" + $Ping_Result += $Obj + } + }#end% + $Ping_Result + $NotResponding \ No newline at end of file diff --git a/dump/SCCM-Troubleshooting/Updates-Not-Synchronizing.txt b/dump/SCCM-Troubleshooting/Updates-Not-Synchronizing.txt new file mode 100644 index 0000000..cff2008 --- /dev/null +++ b/dump/SCCM-Troubleshooting/Updates-Not-Synchronizing.txt @@ -0,0 +1,19 @@ +https://www.windows-noob.com/forums/topic/7522-wsus-sync-sccm-error/ + + deselecting all classifications in SUP (SCCM: Administration/Site/Primary Site/ (Configure Site Components/Softwar Update Point/Classifications/)) + Manual Sync in SUP + + + +1) unselect all Classifications in SUP +2) Perform wsusutil reset +3) Perform sync +4) Re add the Classifications. + + + +"wsusutil reset" in WSUS (C:\Program Files\Update Services\Tools) + selecting classification in SUP + Manual Sync in SUP + +log: c:\Program Files\Microsoft Configuration Manager\LOgs\wsyncmgr.log \ No newline at end of file diff --git a/dump/SCCM-WID-ReIndex-Script.txt b/dump/SCCM-WID-ReIndex-Script.txt new file mode 100644 index 0000000..0a0dfb9 --- /dev/null +++ b/dump/SCCM-WID-ReIndex-Script.txt @@ -0,0 +1,127 @@ +/****************************************************************************** +This sample T-SQL script performs basic maintenance tasks on SUSDB +1. Identifies indexes that are fragmented and defragments them. For certain + tables, a fill-factor is set in order to improve insert performance. + Based on MSDN sample at http://msdn2.microsoft.com/en-us/library/ms188917.aspx + and tailored for SUSDB requirements +2. Updates potentially out-of-date table statistics. +******************************************************************************/ + +USE SUSDB; +GO +SET NOCOUNT ON; + +-- Rebuild or reorganize indexes based on their fragmentation levels +DECLARE @work_to_do TABLE ( + objectid int + , indexid int + , pagedensity float + , fragmentation float + , numrows int +) + +DECLARE @objectid int; +DECLARE @indexid int; +DECLARE @schemaname nvarchar(130); +DECLARE @objectname nvarchar(130); +DECLARE @indexname nvarchar(130); +DECLARE @numrows int +DECLARE @density float; +DECLARE @fragmentation float; +DECLARE @command nvarchar(4000); +DECLARE @fillfactorset bit +DECLARE @numpages int + +-- Select indexes that need to be defragmented based on the following +-- * Page density is low +-- * External fragmentation is high in relation to index size +PRINT 'Estimating fragmentation: Begin. ' + convert(nvarchar, getdate(), 121) +INSERT @work_to_do +SELECT + f.object_id + , index_id + , avg_page_space_used_in_percent + , avg_fragmentation_in_percent + , record_count +FROM + sys.dm_db_index_physical_stats (DB_ID(), NULL, NULL , NULL, 'SAMPLED') AS f +WHERE + (f.avg_page_space_used_in_percent < 85.0 and f.avg_page_space_used_in_percent/100.0 * page_count < page_count - 1) + or (f.page_count > 50 and f.avg_fragmentation_in_percent > 15.0) + or (f.page_count > 10 and f.avg_fragmentation_in_percent > 80.0) + +PRINT 'Number of indexes to rebuild: ' + cast(@@ROWCOUNT as nvarchar(20)) + +PRINT 'Estimating fragmentation: End. ' + convert(nvarchar, getdate(), 121) + +SELECT @numpages = sum(ps.used_page_count) +FROM + @work_to_do AS fi + INNER JOIN sys.indexes AS i ON fi.objectid = i.object_id and fi.indexid = i.index_id + INNER JOIN sys.dm_db_partition_stats AS ps on i.object_id = ps.object_id and i.index_id = ps.index_id + +-- Declare the cursor for the list of indexes to be processed. +DECLARE curIndexes CURSOR FOR SELECT * FROM @work_to_do + +-- Open the cursor. +OPEN curIndexes + +-- Loop through the indexes +WHILE (1=1) +BEGIN + FETCH NEXT FROM curIndexes + INTO @objectid, @indexid, @density, @fragmentation, @numrows; + IF @@FETCH_STATUS < 0 BREAK; + + SELECT + @objectname = QUOTENAME(o.name) + , @schemaname = QUOTENAME(s.name) + FROM + sys.objects AS o + INNER JOIN sys.schemas as s ON s.schema_id = o.schema_id + WHERE + o.object_id = @objectid; + + SELECT + @indexname = QUOTENAME(name) + , @fillfactorset = CASE fill_factor WHEN 0 THEN 0 ELSE 1 END + FROM + sys.indexes + WHERE + object_id = @objectid AND index_id = @indexid; + + IF ((@density BETWEEN 75.0 AND 85.0) AND @fillfactorset = 1) OR (@fragmentation < 30.0) + SET @command = N'ALTER INDEX ' + @indexname + N' ON ' + @schemaname + N'.' + @objectname + N' REORGANIZE'; + ELSE IF @numrows >= 5000 AND @fillfactorset = 0 + SET @command = N'ALTER INDEX ' + @indexname + N' ON ' + @schemaname + N'.' + @objectname + N' REBUILD WITH (FILLFACTOR = 90)'; + ELSE + SET @command = N'ALTER INDEX ' + @indexname + N' ON ' + @schemaname + N'.' + @objectname + N' REBUILD'; + PRINT convert(nvarchar, getdate(), 121) + N' Executing: ' + @command; + EXEC (@command); + PRINT convert(nvarchar, getdate(), 121) + N' Done.'; +END + +-- Close and deallocate the cursor. +CLOSE curIndexes; +DEALLOCATE curIndexes; + + +IF EXISTS (SELECT * FROM @work_to_do) +BEGIN + PRINT 'Estimated number of pages in fragmented indexes: ' + cast(@numpages as nvarchar(20)) + SELECT @numpages = @numpages - sum(ps.used_page_count) + FROM + @work_to_do AS fi + INNER JOIN sys.indexes AS i ON fi.objectid = i.object_id and fi.indexid = i.index_id + INNER JOIN sys.dm_db_partition_stats AS ps on i.object_id = ps.object_id and i.index_id = ps.index_id + + PRINT 'Estimated number of pages freed: ' + cast(@numpages as nvarchar(20)) +END +GO + + +--Update all statistics +PRINT 'Updating all statistics.' + convert(nvarchar, getdate(), 121) +EXEC sp_updatestats +PRINT 'Done updating statistics.' + convert(nvarchar, getdate(), 121) +GO \ No newline at end of file diff --git a/dump/SCCM-WID-to-SQL.txt b/dump/SCCM-WID-to-SQL.txt new file mode 100644 index 0000000..34df026 --- /dev/null +++ b/dump/SCCM-WID-to-SQL.txt @@ -0,0 +1,24 @@ +Total Updates in WID: 7280 + + +1. Stop-Service WsusService (Validate in Services) +2. Stop Website: WSUS Administration +3. Stop WsusPool +4. Open WID in SSMS(open as Administrator) - Connect to WID Instance: \\.\pipe\MICROSOFT\tsql\query\ +5. Detach 'SUSDB' - Choose 'Drop Connections' +6. Copy (SUSDB.mdf & SUSDB_log.ldf ) from the following location to a location in SQL Server (E:\): + - C:\Windows\WID\Data +*********************************************************************** +** Done by SQL Team - CAB ** +7. From SQL Server - Attach SUSDB.mdf +*********************************************************************** + +*********************************************************************** +8. Run the ReIndex Script on SUSDB on SQL Server + https://gallery.technet.microsoft.com/scriptcenter/6f8cde49-5c52-4abd-9820-f1d270ddea61 +9. Goto IIS: Start WsusPool / 'WSUS Administration' Website0 +10. Start-Service WsusService +11. Remove-WindowsFeature -name UpdateServices-WidDB +12. Add-WindowsFeature -name UpdateServices-DB +13. Run WsusUtil.exe to point to SQL database: CD "C:\Program Files\Update Services\Tools" +14. .\WsusUtil.exe postinstall SQL_INSTANCE_NAME="PSQL027.ccx.carecentrix.com" CONTENT_DIR="E:\WSUS" diff --git a/dump/Server-Last-Patched.ps1 b/dump/Server-Last-Patched.ps1 new file mode 100644 index 0000000..734577f --- /dev/null +++ b/dump/Server-Last-Patched.ps1 @@ -0,0 +1,45 @@ +$Location = Split-Path $MyInvocation.MyCommand.Path -Parent +$Final_Last_Patched_Report = @() +$Date_Today = Get-Date -UFormat %m-%d-%Y + +$Collection_Name = "9PM - Production Patching" +$Collection_Servers = Import-Csv "$Location\Files\$Collection_Name.csv" + +$Collection_Servers.Name | % { + #Write-Host "Checking: $_" -ForeGround Green + $HF = Get-HotFix -ComputerName $_ | sort installedon -Descending | Select -First 1 + + $Obj = New-Object -TypeName PSObject + $Obj | Add-Member -MemberType NoteProperty -Name Server -Value $_ + $Obj | Add-Member -MemberType NoteProperty -Name InstalledOn -Value $HF.InstalledOn + $Obj | Add-Member -MemberType NoteProperty -Name LastHF -Value $HF.HotFixID + $Obj | Add-Member -MemberType NoteProperty -Name InstalledBy -Value $HF.InstalledBy + $Obj | Add-Member -MemberType NoteProperty -Name Description -Value $HF.Description + $Obj + $Final_Last_Patched_Report += $Obj +}#end% + + $Final_Last_Patched_Report #| Export-Csv H:\Scripts\Patching\Server-Last-Patched\Server-Last-Patched-$Date_Today.csv -NoTypeInformation + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dump/Software-Inventory.ps1 b/dump/Software-Inventory.ps1 new file mode 100644 index 0000000..e5b9229 --- /dev/null +++ b/dump/Software-Inventory.ps1 @@ -0,0 +1,39 @@ +# $My_List = Import-Csv "\\ccx\shares\Users\Serverless\NNAZMAT\temp\Legacy-Servers.csv" +$Report = @() +$T = @() +$Failed_Connection = @() +$Failed_Invoke = @() +$My_List | % { $Temp = $_ + + If(Test-Connection $Temp.Machine -Count 1 -ErrorAction SilentlyContinue) { + + If(Invoke-Command $Temp.Machine -ErrorAction SilentlyContinue { $env:COMPUTERNAME }) { + + $T2 = Invoke-Command $Temp.Machine { Get-ItemProperty "HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*" | + ? { $_.DisplayName -notlike "Security*" -and $_.DisplayName -notlike "Update*" -and $_.DisplayName -notlike "Hotfix*" -and $_.DisplayName -notlike "Microsoft Visual C++*" -and $_.DisplayName -notlike ""} | + Select-Object displayname, displayversion, publisher, installdate } + + $T2 | % { + $Obj = New-Object -TypeName PSObject + $Obj | Add-Member -MemberType NoteProperty -Name Machine -Value $Temp.Machine + $Obj | Add-Member -MemberType NoteProperty -Name OS -Value $Temp.OS + $Obj | Add-Member -MemberType NoteProperty -Name DisplayName -Value $_.DisplayName + $Obj | Add-Member -MemberType NoteProperty -Name DisplayVersion -Value $_.DisplayVersion + $Obj | Add-Member -MemberType NoteProperty -Name Publisher -Value $_.Publisher + $Obj | Add-Member -MemberType NoteProperty -Name InstallDate -Value $_.InstallDate + $Obj + $Report += $Obj + + + + }#$end% + }#endIfinvoke + Else { $Failed_Invoke += $Temp.Machine } + }#endIf + + Else { $Failed_Connection += $Temp.Machine } + + }#end% + + + diff --git a/dump/Software-Update-Group-Patches.ps1 b/dump/Software-Update-Group-Patches.ps1 new file mode 100644 index 0000000..f9d495f --- /dev/null +++ b/dump/Software-Update-Group-Patches.ps1 @@ -0,0 +1,45 @@ + <# + $SUG = "Server 2008 Required Updates", + "Server 2008 R2 Requred Patches", + "Server 2016 Required Patches", + "Server 2019 Required Patches", + "Server 2012 R2 Required Patches" + +#$P | select LocalizedDisplayName,Updates + +#$P = Get-CMSoftwareUpdateGroup | ? { $_.LocalizedDisplayName -eq "Server 2008 R2 Requred Patches" } +$P | select LocalizedDisplayName, @{n="Updates";e={$_.Updates | Out-String}} | ft -Wrap + +#> + + + + + +$info = @() + +ForEach ($item in $SUG) +{ + # Write-host "Processing Software Update Group" $item + + forEach ($item1 in (Get-CMSoftwareUpdate -Fast -UpdateGroupName $item)) + { + $object = New-Object -TypeName PSObject + $object | Add-Member -MemberType NoteProperty -Name UpdateGroup -Value $item + $object | Add-Member -MemberType NoteProperty -Name ArticleID -Value $item1.ArticleID + $object | Add-Member -MemberType NoteProperty -Name BulletinID -Value $item1.BulletinID + $object | Add-Member -MemberType NoteProperty -Name Title -Value $item1.LocalizedDisplayName + $info += $object + $object + } +} + + +#$Title = "Total assigned software updates in " + $item.LocalizedDisplayName + " = " + $info.count +#$info | Out-GridView -Title "$Title" + + + + +#Get-CMSoftwareUpdate -Fast -UpdateGroupName "Server 2008 Required Updates" + diff --git a/dump/Software-Update-Group-PatchesX.ps1 b/dump/Software-Update-Group-PatchesX.ps1 new file mode 100644 index 0000000..6fc54ea --- /dev/null +++ b/dump/Software-Update-Group-PatchesX.ps1 @@ -0,0 +1,86 @@ +# https://www.verboon.info/2013/09/list-configmgr-software-update-group-members-with-powershell/ + + +<# +.Synopsis + Lists assigned software updates in a configuration manager 2012 software update group +.DESCRIPTION + Lists all assigned software updates in a configuration manager 2012 software update group that is selected + from the list of available update groups or provided as a command line option +.EXAMPLE + Get-UpdateGroupcontent.ps1 +.EXAMPLE + Get-UpdateGroupcontent.ps1 -UpdateGroup "Win7x64_12_11_15" + + +#> + +[CmdletBinding()] + + +param( + + + # Software Update Group + [Parameter(Mandatory = $false, ValueFromPipeline=$true)] + [String] $UpdateGroup + ) + + +$SiteCode = "POC" + +Function Get-UpdateGroupcontent +{ + + +# Check that youre not running X64 +if ([Environment]::Is64BitProcess -eq $True) + { Throw "Need to run at a X86 PowershellPrompt" + } + +# Load ConfigMgr module if it isn't loaded already +if (-not(Get-Module -name ConfigurationManager)) { + Import-Module ($Env:SMS_ADMIN_UI_PATH.Substring(0,$Env:SMS_ADMIN_UI_PATH.Length-5) + '\ConfigurationManager.psd1') + } + +# Change to site + Push-Location + Set-Location ${SiteCode}: + + +#Set-CMQueryResultMaximum -Maximum 5000 + + +if ($UpdateGroup.Length -eq 0) { + $UpdateGroup = Get-CMSoftwareUpdateGroup | Select-Object LocalizedDisplayName | Out-GridView -Title "Select the Software Update Group " -PassThru + } +Else + { + $UpdateGroup = Get-CMSoftwareUpdateGroup | Where-Object {$_.LocalizedDisplayName -like "$($UpdateGroup)"} | Select-Object LocalizedDisplayName +} + +$info = @() + +ForEach ($item in $UpdateGroup) +{ + Write-host "Processing Software Update Group" $($item.LocalizedDisplayName) + forEach ($item1 in (Get-CMSoftwareUpdate -UpdateGroupName $($item.LocalizedDisplayName))) + { + $object = New-Object -TypeName PSObject + #$object | Add-Member -MemberType NoteProperty -Name UpdateGroup -Value $item.LocalizedDisplayName + $object | Add-Member -MemberType NoteProperty -Name ArticleID -Value $item1.ArticleID + $object | Add-Member -MemberType NoteProperty -Name BulletinID -Value $item1.BulletinID + $object | Add-Member -MemberType NoteProperty -Name Title -Value $item1.LocalizedDisplayName + $info += $object + } +} + + +$Title = "Total assigned software updates in " + $item.LocalizedDisplayName + " = " + $info.count +$info | Out-GridView -Title "$Title" +} + + +# -----------------------------------------------------------------------------------------------------* +# Get the list of software updates in the selected update group +Get-UpdateGroupcontent \ No newline at end of file diff --git a/dump/SupersededUpdates.csv b/dump/SupersededUpdates.csv new file mode 100644 index 0000000..46a1294 Binary files /dev/null and b/dump/SupersededUpdates.csv differ diff --git a/dump/SupersededUpdatesBackup.csv b/dump/SupersededUpdatesBackup.csv new file mode 100644 index 0000000..5811d59 Binary files /dev/null and b/dump/SupersededUpdatesBackup.csv differ diff --git a/dump/TechNet LogLauncher.website b/dump/TechNet LogLauncher.website new file mode 100644 index 0000000..bf13242 --- /dev/null +++ b/dump/TechNet LogLauncher.website @@ -0,0 +1,13 @@ +[{000214A0-0000-0000-C000-000000000046}] +Prop3=19,11 +Prop4=31,TechNet LogLauncher +[InternetShortcut] +IDList= +URL=https://gallery.technet.microsoft.com/LogLauncher-61ba5c99 +IconFile=https://i1.gallery.technet.s-msft.com/GlobalResources/images/Technet/favicon.ico +IconIndex=1 +[{A7AF692E-098D-4C08-A225-D433CA835ED0}] +Prop5=3,0 +Prop9=19,0 +[{9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3}] +Prop5=8,Microsoft.Website.B4BD2547.99B248A2 diff --git a/dump/Testing RPC Connectivity.URL b/dump/Testing RPC Connectivity.URL new file mode 100644 index 0000000..3008305 --- /dev/null +++ b/dump/Testing RPC Connectivity.URL @@ -0,0 +1,6 @@ +[InternetShortcut] +URL=https://gallery.technet.microsoft.com/systemcenter/Testing-RPC-Connectivity-e0ab4901 +IDList= +HotKey=0 +IconFile=C:\Users\nnazmat\AppData\Local\Mozilla\Firefox\Profiles\20v5hisb.default-release\shortcutCache\THlrAH+ISyziQ0QQaPftXQ==.ico +IconIndex=0 diff --git a/dump/WSUS_Scripts/0-new-WSUS-PendingReboot.ps1 b/dump/WSUS_Scripts/0-new-WSUS-PendingReboot.ps1 new file mode 100644 index 0000000..72ff8eb --- /dev/null +++ b/dump/WSUS_Scripts/0-new-WSUS-PendingReboot.ps1 @@ -0,0 +1,47 @@ +#import correct file +#Uncomment Restart-Computer +$Dte = Get-Date -UFormat %m-%d-%Y +######################################################################################### +#$WSUSGroup = gc H:\Scripts\Patching\_Group-Config-File\Config-WSUS-Group.txt +$WSUSGroup = "Tier0" + +$Current_Month = (Get-Date -UFormat %B) +$Current_Year = (Get-Date -UFormat %Y) + #$WSUSGroup = Read-Host "Enter Target Group Name" +$Folder = "E:\WSUS_Scripts\Patching-Day\$Current_Month-$Current_Year" +$Group_Folder = "$Folder\$WSUSGroup-$Current_Month-PENDING-Reboot" +$Pending_Reboot_File_Name = "$Group_Folder\$WSUSGroup-PENDING-Reboots-$Current_Month" + + + +#If(!(Test-Path E:\WSUS_Scripts\Patching-Day\$Current_Month-$Current_Year\$WSUSGroup-$Current_Month-Patching)) { New-Item -Path "E:\WSUS_Scripts\Patching-Day" -ItemType Directory -Name $WSUSGroup-$Current_Month-Patching } + +######################################################################################### +#$Server_Reboot_Before_Patching = Import-Csv "E:\WSUS_Scripts\Patching-Day\$Current_Month-$Current_Year\$Group_Folder\$Pending_Reboot_File_Name.csv" | ? { $_.RebootPending -eq "True" } | select computer +#$Server_Reboot_Before_Patching | Export-Csv "E:\WSUS_Scripts\Patching-Day\$Current_Month-$Current_Year\$Group_Folder\$WSUSGroup-Servers-Rebooting-Before-Patching-$Dte.csv" -NoTypeInformation + +$Server_Reboot_Before_Patching = Import-Csv "$Pending_Reboot_File_Name.csv" | ? { $_.RebootPending -eq "True" } | select computer +Write-Host "$WSUSGroup - Server Count: $($Server_Reboot_Before_Patching.count)" -ForegroundColor Yellow + +$Server_Reboot_Before_Patching.Computer | % { + #Write-EventLog -LogName System -Source "Powershell-WSUS-Reboot-Before-Patching" -EntryType Information -EventId 7893 -Message "Reboot-Before-Patching-Remote" -ErrorAction SilentlyContinue + #Invoke-Command $_ -ErrorAction SilentlyContinue { + # New-EventLog -LogName System -Source "Reboot-Before-Patching" -ErrorAction SilentlyContinue + # Write-EventLog -LogName System -Source "Reboot-Before-Patching" -EntryType Information -EventId 7893 -Message "Reboot-Before-Patching-Invoke" -ErrorAction SilentlyContinue + #}#endInvoke + Write-Host "Rebooting --- $_" + xRestart-Computer $_ -Force -Verbose +}#end% + +############################################################################################################################## +<# + +$Server_Reboot_Before_Patching.computer | % { $T = Test-Connection -ComputerName $_ -Count 1 -ErrorAction SilentlyContinue + If($T) { Write-Host "Server $_ -- Responding" -ForegroundColor Green } Else { Write-Host "Server $_ -- Not Responding" -ForegroundColor Red } +} + + + $Server_Reboot_Before_Patching.computer | % { gwmi win32_operatingsystem -ComputerName $_ | select @{n="Server";e={$_.PSComputername}},@{n="LastBootup";e={$_.Converttodatetime($_.LastBootUpTime)}}} + +#> + diff --git a/dump/WSUS_Scripts/1-new-January-Patch-WSUSGroup-4.ps1 b/dump/WSUS_Scripts/1-new-January-Patch-WSUSGroup-4.ps1 new file mode 100644 index 0000000..d4ac48d --- /dev/null +++ b/dump/WSUS_Scripts/1-new-January-Patch-WSUSGroup-4.ps1 @@ -0,0 +1,102 @@ +################################################################################################################################# +If(Test-Path E:\WSUS_Scripts\Lock_Script.txt) { + Write-Host "The Script is locked for protection. If you are not running it by mistake - Delete the file (E:\WSUS_Scripts\Lock_Script.txt) and run the Script again" -ForegroundColor Yellow + Break +} +Else { New-Item -Path E:\WSUS_Scripts -Name Lock_Script.txt -ItemType File } +################################################################################################################################# + +Get-Job | Remove-Job + +#$Location = Split-Path $MyInvocation.MyCommand.Path -Parent +############################################################ +#$WSUSGroup = gc H:\Scripts\Patching\_Group-Config-File\Config-WSUS-Group.txt +$Current_Month = (Get-Date -UFormat %B) +$Current_Year = (Get-Date -UFormat %Y) +############################################################ +$Dte = Get-Date -UFormat %m-%d-%Y +$Collect_Jobs = @() +$Patch_Job = @() +$Failed_Jobs = @() +$Receive_Jobs = @() + +$servers = "" +$WSUSGroup = "xxx" #Read-Host "Enter Target Group Name" + +If(!(Test-Path E:\WSUS_Scripts\Patching-Day\$Current_Month-$Current_Year\$WSUSGroup-$Current_Month-Patching)) { New-Item -Path "E:\WSUS_Scripts\Patching-Day\$Current_Month-$Current_Year" -ItemType Directory -Name $WSUSGroup-$Current_Month-Patching } + +#$servers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select -ExpandProperty Fulldomainname +$Group_Folder = "$WSUSGroup-$Current_Month-Patching" +$Group_Folder_Location = "E:\WSUS_Scripts\Patching-Day\$Current_Month-$Current_Year\$Group_Folder" + +#$Servers_Reboot_Only = Import-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\CCXQ1-November-Prep-Files\Manual-$WSUSGroup-OperatingSystems-$Current_Month.csv +#$servers = Import-Csv E:\WSUS_Scripts\Patching-Day\$Current_Month-$Current_Year\$WSUSGroup.csv | select -ExpandProperty "Server Name" +$servers = Import-Csv $Group_Folder_Location\$WSUSGroup.csv | select -ExpandProperty "Computer" + +####$servers = $servers | ? { $_ -notin $Servers_Reboot_Only.FullDomainName } + +#$servers | Out-File $Location\Patching-Day\$Current_Month-2019\$Group_Folder\$WSUSGroup-Patching-Today-$Dte.txt +$servers | Out-File $Group_Folder_Location\$WSUSGroup-Patching-Today-Backup-$Dte.txt + +xxxForeach ($server in $servers) { + + #New-EventLog -LogName Application -Source "Patching-Started" -ErrorAction SilentlyContinue -ComputerName $server -verbose + #New-EventLog -LogName Application -Source "Patching-Finished" -ErrorAction SilentlyContinue -ComputerName $server -verbose + #New-EventLog -LogName System -Source "Reboot-After-Patching" -ErrorAction SilentlyContinue -ComputerName $server -verbose + #Write-EventLog -LogName Application -Source "Patching-Started" -EntryType Information -EventId 7890 -Message "Server Patching Started with Powershell - Remote" -ComputerName $server -ErrorAction SilentlyContinue -verbose + + $Patch_Job += xxxStart-Job -ScriptBlock { Param($server) WindowsUpdate\Install-WindowsUpdate -ComputerName $server } -Name "$WSUSGroup-#$server#-Patching" -ArgumentList $server + + #Invoke-Command $server -ErrorAction SilentlyContinue { + # New-EventLog -LogName Application -Source "Patching-Started" -ErrorAction SilentlyContinue -verbose + # New-EventLog -LogName Application -Source "Patching-Finished" -ErrorAction SilentlyContinue -verbose + # New-EventLog -LogName System -Source "Reboot-After-Patching" -ErrorAction SilentlyContinue -verbose + # Write-EventLog -LogName Application -Source "Patching-Started" -EntryType Information -EventId 7890 -Message "Server Patching Started with Powershell - Invoke" -verbose + # }#endInvoke + +}#endForeach + + + +#$Patch_Job | Export-Csv $Location\Patching-Day\$Current_Month-2019\$Group_Folder\$WSUSGroup-Patching-Jobs-$Dte.csv -NoTypeInformation +$Patch_Job | Export-Csv $Group_Folder_Location\$WSUSGroup-Patching-Jobs-Backup-$Dte.csv -NoTypeInformation + +#$Collect_Jobs = Get-Job | Export-Csv $Location\Patching-Day\$Current_Month-2019\$Group_Folder\$WSUSGroup-Collect-Patching-Jobs-$Dte.csv -NoTypeInformation +$Collect_Jobs = Get-Job | Export-Csv $Group_Folder_Location\$WSUSGroup-Collect-Patching-Jobs-Backup-$Dte.csv -NoTypeInformation + +#$Patch_Job | Select @{n="Server";e={$_.Name.Split('-')[0]}},@{n="MainJobID";e={$_.ID}},@{n="MainJobName";e={$_.Name}},@{n="ChildJobID";e={$_.Childjobs.ID}},@{n="ChildJobState";e={$_.Childjobs.State}},PSBeginTime,PSEndTime,Command | Export-Csv $Location\Patching-Day\$Group_Folder\$Current_Month-2019\$WSUSGroup-Jobs-ChildJobs-$Dte.csv -NoTypeInformation +$Patch_Job | Select @{n="Server";e={$_.Name.Split('-')[0]}},@{n="MainJobID";e={$_.ID}},@{n="MainJobName";e={$_.Name}},@{n="ChildJobID";e={$_.Childjobs.ID}},@{n="ChildJobState";e={$_.Childjobs.State}},PSBeginTime,PSEndTime,Command | Export-Csv $Group_Folder_Location\$WSUSGroup-Jobs-ChildJobs-Backup-$Dte.csv -NoTypeInformation + +Get-Job +<# + +$Failed_Jobs += $Patch_Job | ? { $_.State -eq "Failed" } + +$Failed_Jobs | ft -autosize + +$Failed_Jobs | Export-Csv "E:\WSUS_Scripts\Patching-Day\$Current_Month-$Current_Year\$WSUSGroup-$Current_Month-Patching\failed-jobs.csv" -NoTypeInformation + +#> + + +### Running Count + +# $Patch_Job + +<# + + $Patch_Job | ft -AutoSize + + ( $Patch_Job | ? { $_.State -eq "Running" } ).count + + ( $Patch_Job | ? { $_.State -eq "Completed" } ).count + + ( $Patch_Job | ? { $_.State -eq "Failed" } ).count + + + + $Patch_Job | ? { $_.State -eq "Running" } | export-csv $Group_Folder_Location\jobs-running.csv + + $T = import-csv $Group_Folder_Location\jobs-running.csv + $T = $T | % {$_.Name.Split('#')[1] } +#> diff --git a/dump/WSUS_Scripts/2-new-WSUS-Patch-Job-Status.ps1 b/dump/WSUS_Scripts/2-new-WSUS-Patch-Job-Status.ps1 new file mode 100644 index 0000000..5097478 --- /dev/null +++ b/dump/WSUS_Scripts/2-new-WSUS-Patch-Job-Status.ps1 @@ -0,0 +1,61 @@ +###### This Script must be run after the patching is in progress #################### +$File_Date = Get-Date -UFormat %H-%M-%p +$Current_Month = (Get-Date -UFormat %B) +$Current_Year = (Get-Date -UFormat %Y) + +If(!(Test-Path "E:\WSUS_Scripts\Patching-Day\$Current_Month-$Current_Year\$WSUSGroup-$Current_Month-Patching\ReRun")) { New-Item -Path "E:\WSUS_Scripts\Patching-Day\$Current_Month-$Current_Year\$WSUSGroup-$Current_Month-Patching\ReRun" -ItemType Directory } + +$Collect_Completed_Servers = @() +$Collect_Completed_Jobs = "" + +$WSUSGroup = "" +$WSUSGroup = Read-Host "Enter Target Group Name" + +$Collect_Completed_Jobs = $Patch_Job +$Patch_Job = $Patch_Job | ? { $_.State -ne "Completed" } +$Failed_Jobs = $Patch_Job | ? { $_.State -eq "Failed" } + +$Collect_Completed_Jobs | % { + $Obj = New-Object -TypeName PSObject + $Obj | Add-Member -MemberType NoteProperty -Name Server -Value ($_.Name.Split('#')[1]) + $Obj | Add-Member -MemberType NoteProperty -Name State -Value $_.State + $Obj +} + +$TPJ = $Obj + +#If(!(Test-Path "E:\WSUS_Scripts\Patching-Day\$Current_Month-$Current_Year\$WSUSGroup-$Current_Month-Patching\ReRun")) { New-Item -Path "E:\WSUS_Scripts\Patching-Day\$Current_Month-$Current_Year\$WSUSGroup-$Current_Month-Patching\ReRun" -ItemType Directory } + +$Patch_Job | Export-Csv "$ReRun_File_Location\$WSUSGroup-Completed-Jobs-$File_Date.csv" -NoTypeInformation + +$ReRun_File_Location = "E:\WSUS_Scripts\Patching-Day\$Current_Month-$Current_Year\$WSUSGroup-$Current_Month-Patching\ReRun" + +#$TPJ | Export-Csv "$ReRun_File_Location\$WSUSGroup-Completed-Jobs-$File_Date.csv" -NoTypeInformation +$Failed_Jobs | Export-Csv "$ReRun_File_Location\$WSUSGroup-FAILED-Jobs-$File_Date.csv" -NoTypeInformation + +#$Unique_Servers = $Collect_Completed_Servers | select Name -Unique +#$temp = Import-Csv "E:\WSUS_Scripts\Patching-Day\November-2019\NCRA - Development Servers-November-Patching\test--NCRA - Development Servers-Patching-Jobs-11-01-2019 - Copy.csv" +#$Collect_Completed_Servers = $Collect_Completed_Jobs.Name | % {$_.Split('#')[1] } + +###################################### Reboot Servers ########################## + +Restart-Computer -ComputerName $TPJ.Server -Force -Verbose +################################################################################ +<# + +$servers | % { $T = Test-Connection -ComputerName $_ -Count 1 -ErrorAction SilentlyContinue + If($T) { Write-Host "Server $_ -- Responding" -ForegroundColor Green } Else { Write-Host "Server $_ -- Not Responding" -ForegroundColor Red } + } + + +#> + + + +# $Servers | % { gwmi win32_operatingsystem -ComputerName $_ | select @{n="Server";e={$_.PSComputername}},@{n="LastBootup";e={$_.Converttodatetime($_.LastBootUpTime)}}} + + + + + + diff --git a/dump/WSUS_Scripts/3-new-ReRun-Patch-WSUSGroup-1.ps1 b/dump/WSUS_Scripts/3-new-ReRun-Patch-WSUSGroup-1.ps1 new file mode 100644 index 0000000..48240dc --- /dev/null +++ b/dump/WSUS_Scripts/3-new-ReRun-Patch-WSUSGroup-1.ps1 @@ -0,0 +1,96 @@ +################################################################################################################################# +#$ErrorActionPreference = "Ignore" + +#$servers = "W2012A","W2012B","slfkjsdl" +#$WSUSGroup = "Test GGroupppppp" + +#$Location = Split-Path $MyInvocation.MyCommand.Path -Parent +################################################################################################################################# +If(Test-Path E:\WSUS_Scripts\Patching-Day\December-2019\Lock_Script.txt) { + Write-Host "The Script is locked for protection. If you are not running it by mistake - Delete the file (E:\WSUS_Scripts\Patching-Day\December-2019\Lock_Script.txt) and run the Script again" -ForegroundColor Yellow + Break +} +Else { New-Item -Path E:\WSUS_Scripts\Patching-Day\December-2019 -Name Lock_Script.txt -ItemType File } +################################################################################################################################# + +############################################################ +#$WSUSGroup = gc H:\Scripts\Patching\_Group-Config-File\Config-WSUS-Group.txt +$Current_Month = (Get-Date -UFormat %B) +$Current_Year = (Get-Date -UFormat %Y) +############################################################ +$Dte = Get-Date -UFormat %m-%d-%Y +$Collect_Jobs = @() +$Patch_Job = @() +$Failed_Jobs = @() +$Receive_Jobs = @() + +#If(!(Test-Path E:\WSUS_Scripts\Patching-Day\$WSUSGroup-$Current_Month-Patching)) { New-Item -Path "E:\WSUS_Scripts\Patching-Day" -ItemType Directory -Name $WSUSGroup-$Current_Month-Patching } + +$servers = "" +$WSUSGroup = Read-Host "Enter Target Group Name" + +$ReRun_File_Location = "E:\WSUS_Scripts\Patching-Day\$Current_Month-$Current_Year\$WSUSGroup-$Current_Month-Patching\ReRun" + +#$Group_Folder = "$WSUSGroup-$Current_Month-Patching" +$Recent_File = gci $ReRun_File_Location | sort LastWriteTime -Descending | select -First 1 | Select FullName + +$servers = Import-Csv $Recent_File.FullName | select -ExpandProperty Server + +#$servers | Out-File $Location\Patching-Day\$Current_Month-$Current_Year\$Group_Folder\$WSUSGroup-Patching-Today-$Dte.txt +#$servers | Out-File $ReRun_File_Location\$WSUSGroup-Patching-Today-Backup-$Dte.txt + +Foreach ($server in $servers) { + + New-EventLog -LogName Application -Source "Patching-Started" -ErrorAction SilentlyContinue -ComputerName $server -verbose + New-EventLog -LogName Application -Source "Patching-Finished" -ErrorAction SilentlyContinue -ComputerName $server -verbose + New-EventLog -LogName System -Source "Reboot-After-Patching" -ErrorAction SilentlyContinue -ComputerName $server -verbose + Write-EventLog -LogName Application -Source "Patching-Started" -EntryType Information -EventId 7890 -Message "Server Patching Started with Powershell - Remote" -ComputerName $server -ErrorAction SilentlyContinue -verbose + + $Patch_Job_ReRun += Start-Job -ScriptBlock { Param($server) WindowsUpdate\Install-WindowsUpdate -ComputerName $server } -Name "ReRun-$WSUSGroup-#$server#-Patching" -ArgumentList $server + + Invoke-Command $server -ErrorAction SilentlyContinue { + New-EventLog -LogName Application -Source "Patching-Started" -ErrorAction SilentlyContinue -verbose + New-EventLog -LogName Application -Source "Patching-Finished" -ErrorAction SilentlyContinue -verbose + New-EventLog -LogName System -Source "Reboot-After-Patching" -ErrorAction SilentlyContinue -verbose + Write-EventLog -LogName Application -Source "Patching-Started" -EntryType Information -EventId 7890 -Message "Server Patching Started with Powershell - Invoke" -verbose + }#endInvoke + +}#endForeach + + +#Get-Job + +#$Patch_Job_ReRun | Export-Csv $Location\Patching-Day\$Current_Month-$Current_Year\$Group_Folder\ReRun-$WSUSGroup-Patching-Jobs-$Dte.csv -NoTypeInformation +$Patch_Job_ReRun | Export-Csv $ReRun_File_Location\ReRun-$WSUSGroup-Patching-Jobs-Backup-$Dte.csv -NoTypeInformation + +#$Collect_Jobs_ReRun = Get-Job | Export-Csv $Location\Patching-Day\$Current_Month-$Current_Year\$Group_Folder\ReRun-$WSUSGroup-Collect-Patching-Jobs-$Dte.csv -NoTypeInformation +$Collect_Jobs_ReRun = Get-Job | Export-Csv $ReRun_File_Location\ReRun-$WSUSGroup-Collect-Patching-Jobs-Backup-$Dte.csv -NoTypeInformation + +#$Patch_Job_ReRun | Select @{n="Server";e={$_.Name.Split('-')[0]}},@{n="MainJobID";e={$_.ID}},@{n="MainJobName";e={$_.Name}},@{n="ChildJobID";e={$_.Childjobs.ID}},@{n="ChildJobState";e={$_.Childjobs.State}},PSBeginTime,PSEndTime,Command | Export-Csv $Location\Patching-Day\$Current_Month-$Current_Year\$Group_Folder\ReRun-$WSUSGroup-Jobs-ChildJobs-$Dte.csv -NoTypeInformation +$Patch_Job_ReRun | Select @{n="Server";e={$_.Name.Split('-')[0]}},@{n="MainJobID";e={$_.ID}},@{n="MainJobName";e={$_.Name}},@{n="ChildJobID";e={$_.Childjobs.ID}},@{n="ChildJobState";e={$_.Childjobs.State}},PSBeginTime,PSEndTime,Command | Export-Csv $ReRun_File_Location\ReRun-$WSUSGroup-Jobs-ChildJobs-Backup-$Dte.csv -NoTypeInformation + + +#################### Reboot Servers ######################## +# Restart-Computer -ComputerName $servers -Verbose +############################################################ + +<# + +$Failed_Jobs += $Patch_Job | ? { $_.State -eq "Failed" } + +$Failed_Jobs | ft -autosize + +$Failed_Jobs | Export-Csv "E:\WSUS_Scripts\Patching-Day\NCRA - Quality Assurance Servers-November-Patching\failed-jobs.csv" -NoTypeInformation + +#> + + +### Running Count +## ( $Patch_Job | ? { $_.State -eq "Running" } ).count + +## ( $Patch_Job | ? { $_.State -eq "Completed" } ).count + +## ( $Patch_Job | ? { $_.State -eq "Failed" } ).count + +#> + \ No newline at end of file diff --git a/dump/WSUS_Scripts/4--new-Reboot-WSUSGroup-4.ps1 b/dump/WSUS_Scripts/4--new-Reboot-WSUSGroup-4.ps1 new file mode 100644 index 0000000..563e647 --- /dev/null +++ b/dump/WSUS_Scripts/4--new-Reboot-WSUSGroup-4.ps1 @@ -0,0 +1,67 @@ + +$Location = Split-Path $MyInvocation.MyCommand.Path -Parent +################################################################################################################################# +$Dte = Get-Date -UFormat %m-%d-%Y +$Current_Month = (Get-Date -UFormat %B) +#$WSUSGroup = gc H:\Scripts\Patching\_Group-Config-File\Config-WSUS-Group.txt +#$Group_Folder = "$WSUSGroup-$Current_Month-Patching" +#$Group = "NCRA - Development Servers" +################################################################################################################################# +$servers = "" +$WSUSGroup = Read-Host "Enter Target Group Name" +#$servers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select Fulldomainname -ExpandProperty Fulldomainname +$Group_Folder = "$WSUSGroup-$Current_Month-Patching" + +#$servers = Import-Csv E:\WSUS_Scripts\Patching-Day\December-2019\$Group_Folder\CCXQ1-November-Prep-Files\$WSUSGroup-Target-Group-Computers-$Current_Month.csv | select -ExpandProperty FullDomainName +$servers = Import-Csv E:\WSUS_Scripts\Patching-Day\December-2019\$WSUSGroup.csv | select -ExpandProperty "Server Name" + + +#$servers | Out-File $Location\Patching-Day\$Group_Folder\$WSUSGroup-Servers-Rebooting-$Dte.txt -ErrorAction SilentlyContinue +$servers | Out-File E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Servers-Rebooting-Backup-$Dte.txt -ErrorAction SilentlyContinue + +#$servers = $servers | ? { $_ -ne "qadf001.ccx.carecentrix.com"} + +#$Patch_Job | Export-Csv $Location\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Jobs-$Dte-Before-Reboot.csv -NoTypeInformation -ErrorAction SilentlyContinue +$Patch_Job | Export-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Jobs-$Dte-Before-Reboot-Backup.csv -NoTypeInformation -ErrorAction SilentlyContinue + +Get-Job | Export-Csv $Location\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Get-Jobs-$Dte-Before-Reboot.csv -NoTypeInformation -ErrorAction SilentlyContinue +Get-Job | Export-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Get-Jobs-$Dte-Before-Reboot-Backup.csv -NoTypeInformation -ErrorAction SilentlyContinue + +#$Collect_Jobs = Get-Job | Export-Csv $Location\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Collect-Patching-Jobs-$Dte-Before-Reboot.csv -NoTypeInformation +$Collect_Jobs = Get-Job | Export-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Collect-Patching-Jobs-$Dte-Before-Reboot-Backup.csv -NoTypeInformation + +Foreach ($server in $servers) { + + Write-EventLog -LogName Application -Source "Patching-Finished" -EntryType Information -EventId 7891 -Message "Powershell-WSUS-Patching-Finished - Remote" -ComputerName $server -ErrorAction SilentlyContinue + Write-EventLog -LogName System -Source "Reboot-After-Patching" -EntryType Information -EventId 7892 -Message "Server Rebooting After Patching - Remote" -ComputerName $server -ErrorAction SilentlyContinue + + Invoke-Command $server -ErrorAction SilentlyContinue { + #New-EventLog -LogName Application -Source "Powershell-WSUS-Patching-Finished" -ErrorAction SilentlyContinue + #New-EventLog -LogName System -Source "Powershell-Reboot-After-Patching" -ErrorAction SilentlyContinue + Write-EventLog -LogName Application -Source "Patching-Finished" -EntryType Information -EventId 7891 -Message "Powershell-WSUS-Patching-Finished - Invoke" -ErrorAction SilentlyContinue + Write-EventLog -LogName System -Source "Reboot-After-Patching" -EntryType Information -EventId 7892 -Message "Server Rebooting After Patching - Invoke" -ErrorAction SilentlyContinue + }#endInvoke + Restart-Computer -ComputerName $server -Force -Verbose + +}#endForeach + + + +<# + +$servers | % { $T = Test-Connection -ComputerName $_ -Count 1 -ErrorAction SilentlyContinue + If($T) { Write-Host "Server $_ -- Responding" -ForegroundColor Green } Else { Write-Host "Server $_ -- Not Responding" -ForegroundColor Red } + } + + +#> + +# $Servers | % { Get-EventLog -LogName System -ComputerName $_.computer | ? { $_.EventID -eq '7893' } } + + +# $Servers | % { gwmi win32_operatingsystem -ComputerName $_ | select @{n="Server";e={$_.PSComputername}},@{n="LastBootup";e={$_.Converttodatetime($_.LastBootUpTime)}}} + + + + + diff --git a/dump/WSUS_Scripts/Backups/new-Patch-WSUSGroup.ps1 b/dump/WSUS_Scripts/Backups/new-Patch-WSUSGroup.ps1 new file mode 100644 index 0000000..0f8d339 --- /dev/null +++ b/dump/WSUS_Scripts/Backups/new-Patch-WSUSGroup.ps1 @@ -0,0 +1,70 @@ +<# + +$ErrorActionPreference = "Ignore" +$WSUSGroup = Read-Host "Enter Target Group Name" +$servers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select Fulldomainname -ExpandProperty Fulldomainname +Foreach ($server in $servers) {Install-WindowsUpdate -ComputerName $server -AsJob} + +#Function Restart {# Force Reboot of Group (when auto failed) un-rem and run line below. +#Foreach ($server in $servers) {Restart-Computer -ComputerName $server -Force}} + +#Write-Host "Type Restart and press enter to reboot the $WSUSGroup WSUS Computer Group" +Read-Host -Prompt "Press Enter to exit" +#> + +################################################################################################################################# +#$ErrorActionPreference = "Ignore" +$WSUSGroup = Read-Host "Enter Target Group Name" + +$servers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select Fulldomainname -ExpandProperty Fulldomainname + +#$servers = "W2012A","W2012B","slfkjsdl" +#$WSUSGroup = "Test GGroupppppp" + +$Location = Split-Path $MyInvocation.MyCommand.Path -Parent +$Dte = Get-Date -UFormat %m-%d-%Y +$Collect_Jobs = @() +$Patch_Job = @() + +$servers | Out-File $Location\Patching-Day\"$WSUSGroup"-Server-Patching-Today-$Dte.txt +$servers | Out-File E:\WSUS_Scripts\Patching-Day\"$WSUSGroup"-Server-Patching-Today-Backup-$Dte.txt + +Foreach ($server in $servers) { + + New-EventLog -LogName Application -Source "Patching-Started" -ErrorAction SilentlyContinue -ComputerName $server + New-EventLog -LogName Application -Source "Patching-Finished" -ErrorAction SilentlyContinue -ComputerName $server + New-EventLog -LogName System -Source "Reboot-After-Patching" -ErrorAction SilentlyContinue -ComputerName $server + Write-EventLog -LogName Application -Source "Patching-Started" -EntryType Information -EventId 7890 -Message "Server Patching Started with Powershell - Remote" -ComputerName $server -ErrorAction SilentlyContinue + + $Patch_Job += Start-Job -ScriptBlock { Param($server) Install-WindowsUpdate -ComputerName $server } -Name "$server-Patching" -ArgumentList $server + + Invoke-Command $server -ErrorAction SilentlyContinue { + New-EventLog -LogName Application -Source "Patching-Started" -ErrorAction SilentlyContinue + New-EventLog -LogName Application -Source "Patching-Finished" -ErrorAction SilentlyContinue + New-EventLog -LogName System -Source "Reboot-After-Patching" -ErrorAction SilentlyContinue + Write-EventLog -LogName Application -Source "Patching-Started" -EntryType Information -EventId 7890 -Message "Server Patching Started with Powershell - Invoke" + }#endInvoke + + Install-WindowsUpdate -ComputerName $server -AsJob + +}#endForeach + +Get-Job + +$Patch_Job | Export-Csv $Location\Patching-Day\Patching-Jobs-$Dte.csv -NoTypeInformation +$Patch_Job | Export-Csv E:\WSUS_Scripts\Patching-Day\Patching-Jobs-Backup-$Dte.csv -NoTypeInformation + +$Collect_Jobs = Get-Job | Export-Csv $Location\Patching-Day\Collect-Patching-Jobs-$Dte.csv -NoTypeInformation +$Collect_Jobs = Get-Job | Export-Csv E:\WSUS_Scripts\Patching-Day\Collect-Patching-Jobs-Backup-$Dte.csv -NoTypeInformation + +$Patch_Job | Select @{n="Server";e={$_.Name.Split('-')[0]}},@{n="MainJobID";e={$_.ID}},@{n="MainJobName";e={$_.Name}},@{n="ChildJobID";e={$_.Childjobs.ID}},@{n="ChildJobState";e={$_.Childjobs.State}},PSBeginTime,PSEndTime,Command | Export-Csv $Location\Patching-Day\Jobs-ChildJobs-$Dte.csv -NoTypeInformation +$Patch_Job | Select @{n="Server";e={$_.Name.Split('-')[0]}},@{n="MainJobID";e={$_.ID}},@{n="MainJobName";e={$_.Name}},@{n="ChildJobID";e={$_.Childjobs.ID}},@{n="ChildJobState";e={$_.Childjobs.State}},PSBeginTime,PSEndTime,Command | Export-Csv E:\WSUS_Scripts\Patching-Day\Jobs-ChildJobs-Backup-$Dte.csv -NoTypeInformation + + + + + + + + + \ No newline at end of file diff --git a/dump/WSUS_Scripts/Backups/new-Reboot-WSUSGroup-backup1.ps1 b/dump/WSUS_Scripts/Backups/new-Reboot-WSUSGroup-backup1.ps1 new file mode 100644 index 0000000..7eda7f6 --- /dev/null +++ b/dump/WSUS_Scripts/Backups/new-Reboot-WSUSGroup-backup1.ps1 @@ -0,0 +1,29 @@ +$Location = Split-Path $MyInvocation.MyCommand.Path -Parent +$Dte = Get-Date -UFormat %m-%d-%Y + +$WSUSGroup = Read-Host "Enter Target Group Name" +$servers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select Fulldomainname -ExpandProperty Fulldomainname + +$servers | Out-File $Location\Patching-Day\"$WSUSGroup"-Servers-Rebooting-$Dte.txt -ErrorAction SilentlyContinue +$servers | Out-File E:\WSUS_Scripts\Patching-Day\"$WSUSGroup"-Servers-Rebooting-Backup-$Dte.txt -ErrorAction SilentlyContinue + +$Patch_Job | Export-Csv $Location\Patching-Day\Patching-Jobs-$Dte-Before-Reboot.csv -NoTypeInformation -ErrorAction SilentlyContinue +$Patch_Job | Export-Csv E:\WSUS_Scripts\Patching-Day\Patching-Jobs-$Dte-Before-Reboot-Backup.csv -NoTypeInformation -ErrorAction SilentlyContinue + +Get-Job | Export-Csv $Location\Patching-Day\Patching-Get-Jobs-$Dte-Before-Reboot.csv -NoTypeInformation -ErrorAction SilentlyContinue +Get-Job | Export-Csv E:\WSUS_Scripts\Patching-Day\Patching-Get-Jobs-$Dte-Before-Reboot-Backup.csv -NoTypeInformation -ErrorAction SilentlyContinue + +$Collect_Jobs = Get-Job | Export-Csv $Location\Patching-Day\Patching-Collect-Patching-Jobs-$Dte-Before-Reboot.csv -NoTypeInformation +$Collect_Jobs = Get-Job | Export-Csv E:\WSUS_Scripts\Patching-Day\Patching-Collect-Patching-Jobs-$Dte-Before-Reboot-Backup.csv -NoTypeInformation + +Foreach ($server in $servers) { + + Invoke-Command $server -ErrorAction SilentlyContinue { + #New-EventLog -LogName Application -Source "Powershell-WSUS-Patching-Finished" -ErrorAction SilentlyContinue + #New-EventLog -LogName System -Source "Powershell-Reboot-After-Patching" -ErrorAction SilentlyContinue + Write-EventLog -LogName Application -Source "Patching-Finished" -EntryType Information -EventId 7891 -Message "Powershell-WSUS-Patching-Finished" + Write-EventLog -LogName System -Source "Reboot-After-Patching" -EntryType Information -EventId 7892 -Message "Server Rebooting After Patching" + }#endInvoke + Restart-Computer -ComputerName $server -Force -Verbose + +}#endForeach \ No newline at end of file diff --git a/dump/WSUS_Scripts/Backups/new-Reboot-WSUSGroup.ps1 b/dump/WSUS_Scripts/Backups/new-Reboot-WSUSGroup.ps1 new file mode 100644 index 0000000..3efdd2f --- /dev/null +++ b/dump/WSUS_Scripts/Backups/new-Reboot-WSUSGroup.ps1 @@ -0,0 +1,32 @@ +$Location = Split-Path $MyInvocation.MyCommand.Path -Parent +$Dte = Get-Date -UFormat %m-%d-%Y + +$WSUSGroup = Read-Host "Enter Target Group Name" +$servers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select Fulldomainname -ExpandProperty Fulldomainname + +$servers | Out-File $Location\Patching-Day\"$WSUSGroup"-Servers-Rebooting-$Dte.txt -ErrorAction SilentlyContinue +$servers | Out-File E:\WSUS_Scripts\Patching-Day\"$WSUSGroup"-Servers-Rebooting-Backup-$Dte.txt -ErrorAction SilentlyContinue + +$Patch_Job | Export-Csv $Location\Patching-Day\Patching-Jobs-$Dte-Before-Reboot.csv -NoTypeInformation -ErrorAction SilentlyContinue +$Patch_Job | Export-Csv E:\WSUS_Scripts\Patching-Day\Patching-Jobs-$Dte-Before-Reboot-Backup.csv -NoTypeInformation -ErrorAction SilentlyContinue + +Get-Job | Export-Csv $Location\Patching-Day\Patching-Get-Jobs-$Dte-Before-Reboot.csv -NoTypeInformation -ErrorAction SilentlyContinue +Get-Job | Export-Csv E:\WSUS_Scripts\Patching-Day\Patching-Get-Jobs-$Dte-Before-Reboot-Backup.csv -NoTypeInformation -ErrorAction SilentlyContinue + +$Collect_Jobs = Get-Job | Export-Csv $Location\Patching-Day\Patching-Collect-Patching-Jobs-$Dte-Before-Reboot.csv -NoTypeInformation +$Collect_Jobs = Get-Job | Export-Csv E:\WSUS_Scripts\Patching-Day\Patching-Collect-Patching-Jobs-$Dte-Before-Reboot-Backup.csv -NoTypeInformation + +Foreach ($server in $servers) { + + Write-EventLog -LogName Application -Source "Patching-Finished" -EntryType Information -EventId 7891 -Message "Powershell-WSUS-Patching-Finished - Remote" -ComputerName $server -ErrorAction SilentlyContinue + Write-EventLog -LogName System -Source "Reboot-After-Patching" -EntryType Information -EventId 7892 -Message "Server Rebooting After Patching - Remote" -ComputerName $server -ErrorAction SilentlyContinue + + Invoke-Command $server -ErrorAction SilentlyContinue { + #New-EventLog -LogName Application -Source "Powershell-WSUS-Patching-Finished" -ErrorAction SilentlyContinue + #New-EventLog -LogName System -Source "Powershell-Reboot-After-Patching" -ErrorAction SilentlyContinue + Write-EventLog -LogName Application -Source "Patching-Finished" -EntryType Information -EventId 7891 -Message "Powershell-WSUS-Patching-Finished - Invoke" -ErrorAction SilentlyContinue + Write-EventLog -LogName System -Source "Reboot-After-Patching" -EntryType Information -EventId 7892 -Message "Server Rebooting After Patching - Invoke" -ErrorAction SilentlyContinue + }#endInvoke + Restart-Computer -ComputerName $server -Force -Verbose + +}#endForeach \ No newline at end of file diff --git a/dump/WSUS_Scripts/Backups/new-WSUS-PendingReboot.ps1 b/dump/WSUS_Scripts/Backups/new-WSUS-PendingReboot.ps1 new file mode 100644 index 0000000..45dbb37 --- /dev/null +++ b/dump/WSUS_Scripts/Backups/new-WSUS-PendingReboot.ps1 @@ -0,0 +1,15 @@ +#import correct file +#Uncomment Restart-Computer + +$Server_Reboot_Before_Patching = Import-Csv E:\WSUS_Scripts\Files\PENDING-Reboots-10-08-2019.csv | ? { $_.RebootPending -eq "True" } | select computer + +$Server_Reboot_Before_Patching.Computer | % { + Write-EventLog -LogName System -Source "Powershell-WSUS-Reboot-Before-Patching" -EntryType Information -EventId 7893 -Message "Reboot-Before-Patching-Remote" -ErrorAction SilentlyContinue + Invoke-Command $_ -ErrorAction SilentlyContinue { + New-EventLog -LogName System -Source "Reboot-Before-Patching" -ErrorAction SilentlyContinue + Write-EventLog -LogName System -Source "Reboot-Before-Patching" -EntryType Information -EventId 7893 -Message "Reboot-Before-Patching-Invoke" -ErrorAction SilentlyContinue + }#endInvoke + Restart-Computer $_ -Force -Verbose +}#end% + + \ No newline at end of file diff --git a/dump/WSUS_Scripts/Check-Hotfix-2.ps1 b/dump/WSUS_Scripts/Check-Hotfix-2.ps1 new file mode 100644 index 0000000..26c9be6 --- /dev/null +++ b/dump/WSUS_Scripts/Check-Hotfix-2.ps1 @@ -0,0 +1,4 @@ + + +$ServerName | % { Get-HotFix -ComputerName $_ | sort installedon -Descending | select -First 1 } + diff --git a/dump/WSUS_Scripts/Check-Hotfix.ps1 b/dump/WSUS_Scripts/Check-Hotfix.ps1 new file mode 100644 index 0000000..7d3b8e4 --- /dev/null +++ b/dump/WSUS_Scripts/Check-Hotfix.ps1 @@ -0,0 +1,8 @@ + +$WSUSGroup = Read-Host "Enter Target Group Name" +$servers = Import-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Target-Group-Computers-$Current_Month.csv | select -ExpandProperty FullDomainName +$servers | % { Get-HotFix -ComputerName $_ | ? { $_.InstalledOn} | sort installedon -Descending | select -First 1 } + + + + diff --git a/dump/WSUS_Scripts/Check-Jobs.ps1 b/dump/WSUS_Scripts/Check-Jobs.ps1 new file mode 100644 index 0000000..937bae7 --- /dev/null +++ b/dump/WSUS_Scripts/Check-Jobs.ps1 @@ -0,0 +1,32 @@ +$Check_Jobs = Import-Csv "E:\WSUS_Scripts\Patching-Day\December-2019\Tier2B-December-Patching\ReRun\Tier2B-FAILED-Jobs-22-01-PM.csv" | select @{n="Server";e={$_.Name.split('#')[1]}},State,PSBeginTime + +##$Completed_Jobs = $Check_Jobs | ? { $_.State -eq "Completed" } +##$Failed_Jobs = $Check_Jobs | ? { $_.State -eq "Failed" } +#$P_Job_Servers = @() + +##### Reboot Completed Ones and Run patching again ##### +#Restart-Computer $Completed_Jobs.Server -Force -Verbose + + +Foreach ($S in $Completed_Jobs.Server) { + #$S = $T.name + #$P_Job_Servers += Start-Job -ScriptBlock { Param($S) WindowsUpdate\Install-WindowsUpdate -ComputerName $S } -Name "$WSUSGroup-#$S#-Patching" -ArgumentList $S + +}#endForeach + +<# + +$Tier2B_Servers."Server Name" | % { $T = Test-Connection -ComputerName $_ -Count 1 -ErrorAction SilentlyContinue + If($T) { Write-Host "Server $_ -- Responding" -ForegroundColor Green } Else { Write-Host "Server $_ -- Not Responding" -ForegroundColor Red } +} + +####################################################################################################### + +$Tier2B_Servers."Server Name" | % { gwmi win32_operatingsystem -ComputerName $_ | select @{n="Server";e={$_.PSComputername}},@{n="LastBootup";e={$_.Converttodatetime($_.LastBootUpTime)}}} | ft -autosize + + +#> + + + + diff --git a/dump/WSUS_Scripts/Files/NCRA - Development Servers-PENDING-Reboots-November.csv b/dump/WSUS_Scripts/Files/NCRA - Development Servers-PENDING-Reboots-November.csv new file mode 100644 index 0000000..38877a9 --- /dev/null +++ b/dump/WSUS_Scripts/Files/NCRA - Development Servers-PENDING-Reboots-November.csv @@ -0,0 +1,60 @@ +"Computer","CBServicing","WindowsUpdate","CCMClientSDK","PendComputerRename","PendFileRename","PendFileRenVal","RebootPending" +"DAPP006","True","True",,"False","True","System.String[]","True" +"DSQL001","False","False",,"False","False",,"False" +"DAPP012","True","True",,"False","True","System.String[]","True" +"DIIS004",,"False",,"False","True","System.String[]","True" +"DSQL002","False","False",,"False","False",,"False" +"DWHD001","False","False",,"False","False",,"False" +"DEDI001","False","False",,"False","False",,"False" +"DOWA001","False","False",,"False","True","System.String[]","True" +"DSWF001","False","False",,"False","False",,"False" +"DSAP001","False","False",,"False","True","System.String[]","True" +"DSQL009","False","False",,"False","True","System.String[]","True" +"DFNP009","True","True",,"False","False",,"True" +"DDOC001","True","True",,"False","False",,"True" +"DCPR001","False","False",,"False","False",,"False" +"DTABL001","False","False",,"False","True","System.String[]","True" +"DBTS001","False","False",,"False","False",,"False" +"DPGP001","False","False",,"False","False",,"False" +"DSSS001","False","False",,"False","True","System.String[]","True" +"DAPP001",,"False",,"False","True","System.String[]","True" +"DBIT901","True","True",,"False","True","System.String[]","True" +"DFNP002","True","True",,"False","False",,"True" +"DDWH001","False","False",,"False","False",,"False" +"DVRS001","True","True",,"False","False",,"True" +"DSHP001","False","False",,"False","False",,"False" +"DWHD003","False","False",,"False","True","System.String[]","True" +"DSRS001","False","False",,"False","True","System.String[]","True" +"DWTS001","False","False",,"False","False",,"False" +"DAPP003",,"False",,"False","True","System.String[]","True" +"DWAM002","True","True",,"False","True","System.String[]","True" +"DFNP001","True","True",,"False","True","System.String[]","True" +"DSIS001","False","False",,"False","False",,"False" +"DIIS003","False","False",,"False","True","System.String[]","True" +"DVB6001","True","True",,"False","True","System.String[]","True" +"DSQL006","False","False",,"False","False",,"False" +"DCTI001","True","True",,"False","True","System.String[]","True" +"DIIS002",,"False",,"False","True","System.String[]","True" +"DFNP020","True","True",,"False","True","System.String[]","True" +"DFNP014","True","True",,"False","False",,"True" +"DIAP001","True","True",,"False","True","System.String[]","True" +"DSQL027B","False","False",,"False","True","System.String[]","True" +"DSQL027A","False","False",,"False","True","System.String[]","True" +"DVVC004","True","True",,"False","True","System.String[]","True" +"DVCO001","True","True",,"False","True","System.String[]","True" +"DVVC003","True","True",,"False","True","System.String[]","True" +"DEDI113","False","False",,"False","True","System.String[]","True" +"DSQL000","False","False",,"False","True","System.String[]","True" +"DSQL028","False","False",,"False","True","System.String[]","True" +"DSIS003","False","False",,"False","False",,"False" +"DFAX011","False","False",,"False","True","System.String[]","True" +"DMQS001","False","False",,"False","True","System.String[]","True" +"DGAW001","False","False",,"False","True","System.String[]","True" +"DSQL004","False","False",,"False","True","System.String[]","True" +"DSQL029","False","False",,"False","True","System.String[]","True" +"DSQL030","False","False",,"False","True","System.String[]","True" +"DAPCAC001","False","False",,"False","True","System.String[]","True" +"DAPCAV001","False","False",,"False","True","System.String[]","True" +"DAPCAC002","False","False",,"False","False",,"False" +"DAPVRNS001","False","False",,"False","True","System.String[]","True" +"DAPSEP001","False","False",,"False","True","System.String[]","True" diff --git a/dump/WSUS_Scripts/Files/NCRA - Development Servers-Ping-Failed-November.txt b/dump/WSUS_Scripts/Files/NCRA - Development Servers-Ping-Failed-November.txt new file mode 100644 index 0000000..916ed88 Binary files /dev/null and b/dump/WSUS_Scripts/Files/NCRA - Development Servers-Ping-Failed-November.txt differ diff --git a/dump/WSUS_Scripts/Files/NCRA - Quality Assurance Servers-PENDING-Reboots-November.csv b/dump/WSUS_Scripts/Files/NCRA - Quality Assurance Servers-PENDING-Reboots-November.csv new file mode 100644 index 0000000..8eed953 --- /dev/null +++ b/dump/WSUS_Scripts/Files/NCRA - Quality Assurance Servers-PENDING-Reboots-November.csv @@ -0,0 +1,91 @@ +"Computer","CBServicing","WindowsUpdate","CCMClientSDK","PendComputerRename","PendFileRename","PendFileRenVal","RebootPending" +"Q1FNP003","False","False",,"False","False",,"False" +"Q1SQL022","False","False",,"False","True","System.String[]","True" +"Q1SQL024","False","False",,"False","True","System.String[]","True" +"Q2FNP003","False","False",,"False","False",,"False" +"Q2SQL022","False","False",,"False","True","System.String[]","True" +"Q3FNP003","False","False",,"False","False",,"False" +"Q3SQL022","False","False",,"False","True","System.String[]","True" +"Q4FNP003","False","False",,"False","False",,"False" +"Q4SQL022","False","False",,"False","True","System.String[]","True" +"Q4SQL022B","False","False",,"False","True","System.String[]","True" +"Q4SQL024","False","False",,"False","True","System.String[]","True" +"Q5FNP003","False","False",,"False","False",,"False" +"Q5SQL022","False","False",,"False","True","System.String[]","True" +"QADF001","False","False",,"False","True","System.String[]","True" +"QAPP011","False","False",,"False","True","System.String[]","True" +"QAPP021","False","False",,"False","True","System.String[]","True" +"QAPP031","False","False",,"False","True","System.String[]","True" +"QAPP041","False","False",,"False","True","System.String[]","True" +"QAPP051","False","False",,"False","True","System.String[]","True" +"QBIZ111","False","False",,"False","True","System.String[]","True" +"QBIZ112","False","False",,"False","True","System.String[]","True" +"QBIZ121","True","True",,"False","True","System.String[]","True" +"QBIZ122","False","False",,"False","True","System.String[]","True" +"QBIZ131","False","False",,"False","True","System.String[]","True" +"QBIZ132","False","False",,"False","True","System.String[]","True" +"QBIZ141","False","False",,"False","True","System.String[]","True" +"QBIZ142","False","False",,"False","True","System.String[]","True" +"QBIZ151","False","False",,"False","True","System.String[]","True" +"QBIZ152","False","False",,"False","True","System.String[]","True" +"QCMX001","False","False",,"False","True","System.String[]","True" +"QDRF001","False","False",,"False","True","System.String[]","True" +"QEDI111","False","False",,"False","True","System.String[]","True" +"QEDI112","False","False",,"False","True","System.String[]","True" +"QEDI113","False","False",,"False","True","System.String[]","True" +"QEDI151","False","False",,"False","True","System.String[]","True" +"QEDI152","False","False",,"False","True","System.String[]","True" +"QEDI153","False","False",,"False","True","System.String[]","True" +"QFNP001","False","False",,"False","True","System.String[]","True" +"QFNP003","False","False",,"False","True","System.String[]","True" +"QFNP007","False","False",,"False","True","System.String[]","True" +"QFNP008","False","False",,"False","False",,"False" +"QFNP009","False","False",,"False","False",,"False" +"QIIS005","False","False",,"False","True","System.String[]","True" +"QMFT001","False","False",,"False","True","System.String[]","True" +"QMHB001","False","False",,"False","True","System.String[]","True" +"QMHB002","False","False",,"False","True","System.String[]","True" +"QMHB003","False","False",,"False","True","System.String[]","True" +"QMHB004","False","False",,"False","True","System.String[]","True" +"QNCRASPAPP01","False","False",,"False","False",,"False" +"QNCRASPAPP02","False","False",,"False","False",,"False" +"QNCRASPDC01","False","False",,"False","False",,"False" +"QNCRASPDC02","False","False",,"False","False",,"False" +"QNCRASPOWA01","False","False",,"False","True","System.String[]","True" +"QNCRASPSEA01","False","False",,"False","False",,"False" +"QNCRASPSEA02","False","False",,"False","False",,"False" +"QNCRASPWFE01","False","False",,"False","False",,"False" +"QNCRASPWFE02","False","False",,"False","False",,"False" +"QQATEST01","False","False",,"False","True","System.String[]","True" +"QRDS001","False","False",,"False","True","System.String[]","True" +"QRDS002","False","False",,"False","True","System.String[]","True" +"QRSH001","False","False",,"False","True","System.String[]","True" +"QRSH002","False","False",,"False","True","System.String[]","True" +"QRSH021","False","False",,"False","True","System.String[]","True" +"QRSH022","False","False",,"False","True","System.String[]","True" +"QRSH023","False","False",,"False","True","System.String[]","True" +"QRSH031","False","False",,"False","True","System.String[]","True" +"QRSH041","False","False",,"False","False",,"False" +"QRSH051","False","False",,"False","True","System.String[]","True" +"QRSH101","False","False",,"False","True","System.String[]","True" +"QRSH111","False","False",,"False","True","System.String[]","True" +"QRSH112","False","False",,"False","False",,"False" +"QSCH011","False","False",,"False","False",,"False" +"QSCH012","False","False",,"False","False",,"False" +"QSCH013","False","False",,"False","False",,"False" +"QSCH014","False","False",,"False","False",,"False" +"QSIS001","False","False",,"False","False",,"False" +"QSIS002","False","False",,"False","False",,"False" +"QSIS003","False","False",,"False","True","System.String[]","True" +"QSQL006","False","False",,"False","True","System.String[]","True" +"QSQL028","False","False",,"False","True","System.String[]","True" +"QSQL029","False","False",,"False","True","System.String[]","True" +"QSQL030","False","False",,"False","True","System.String[]","True" +"QSRS001","False","False",,"False","False",,"False" +"QSRS004","False","False",,"False","True","System.String[]","True" +"QTABL001","False","False",,"False","True","System.String[]","True" +"QUTL012","False","False",,"False","False",,"False" +"QVST011","False","False",,"False","True","System.String[]","True" +"QVST012","False","False",,"False","True","System.String[]","True" +"QVST021","False","False",,"False","True","System.String[]","True" +"QVST022","False","False",,"False","True","System.String[]","True" diff --git a/dump/WSUS_Scripts/Files/PENDING-Reboots-10-08-2019.csv b/dump/WSUS_Scripts/Files/PENDING-Reboots-10-08-2019.csv new file mode 100644 index 0000000..91758af --- /dev/null +++ b/dump/WSUS_Scripts/Files/PENDING-Reboots-10-08-2019.csv @@ -0,0 +1,308 @@ +"Computer","CBServicing","WindowsUpdate","CCMClientSDK","PendComputerRename","PendFileRename","PendFileRenVal","RebootPending" +"PMON003","False","False",,"False","False",,"False" +"PMHB002","False","False",,"False","True","System.String[]","True" +"PSKY001","False","False",,"False","True","System.String[]","True" +"NYMEPALT001","False","False",,"False","False",,"False" +"PLNC001","False","False",,"False","False",,"False" +"PFNP009","False","False",,"False","True","System.String[]","True" +"PFAX002",,"False",,"False","False",,"False" +"PVTS002",,"False",,"False","False",,"False" +"PFNP003","False","False",,"False","False",,"False" +"POCS002","False","False",,"False","False",,"False" +"PARM001","False","False",,"False","True","System.String[]","True" +"PSHP002","False","False",,"False","False",,"False" +"PSSS001","False","False",,"False","True","System.String[]","True" +"PAPC001","False","False",,"False","False",,"False" +"PFNP001","False","False",,"False","False",,"False" +"PFNP005","False","False",,"False","False",,"False" +"PSQL006","False","False",,"False","False",,"False" +"PSPT002","False","False",,"False","False",,"False" +"PVTS003",,"False",,"False","False",,"False" +"PSUF001","False","False",,"False","True","System.String[]","True" +"PFAX005",,"False",,"False","False",,"False" +"PTABL001","False","False",,"False","True","System.String[]","True" +"PIIS006",,"False",,"False","False",,"False" +"PWTS041","False","False",,"False","True","System.String[]","True" +"CTHAPALT001","False","False",,"False","True","System.String[]","True" +"PATV001","False","False",,"False","True","System.String[]","True" +"PSQL001","False","False",,"False","False",,"False" +"PWHD003","False","False",,"False","True","System.String[]","True" +"PMON008","False","False",,"False","False",,"False" +"PVSS011","False","False",,"False","True","System.String[]","True" +"PFNP007","False","False",,"False","False",,"False" +"PSQL014","False","False",,"False","False",,"False" +"PSEV011","False","False",,"False","False",,"False" +"PIIS001",,"False",,"False","False",,"False" +"PUTL005","False","False",,"False","True","System.String[]","True" +"PBIT901","False","False",,"False","True","System.String[]","True" +"PWTS040","False","False",,"False","True","System.String[]","True" +"PSRS001","False","False",,"False","False",,"False" +"PFAX003",,"False",,"False","False",,"False" +"PFAX007","False","False",,"False","True","System.String[]","True" +"PVRS001","False","False",,"False","False",,"False" +"PSEV016","False","False",,"False","False",,"False" +"PPKI004","False","False",,"False","False",,"False" +"PCVV001","False","False",,"False","False",,"False" +"PPCH001","False","False",,"False","False",,"False" +"PSQL007","False","False",,"False","False",,"False" +"PVEO002","False","False",,"False","True","System.String[]","True" +"PSEC002","False","False",,"False","True","System.String[]","True" +"PPGP001","False","False",,"False","False",,"False" +"PFNP011","False","False",,"False","True","System.String[]","True" +"PSEV012","False","False",,"False","True","System.String[]","True" +"PSEV014","False","False",,"False","True","System.String[]","True" +"PPDQ001","False","False",,"False","True","System.String[]","True" +"PVEO001","False","False",,"False","False",,"False" +"PSKY003","False","False",,"False","False",,"False" +"CTHAPALT002","False","False",,"False","False",,"False" +"PSQL008","False","False",,"False","True","System.String[]","True" +"PVTS006",,"False",,"False","False",,"False" +"PVTS004",,"False",,"False","False",,"False" +"PDFS001","False","False",,"False","False",,"False" +"PVVC013","False","False",,"False","False",,"False" +"PSHP001","False","False",,"False","False",,"False" +"PRAD002","False","False",,"False","True","System.String[]","True" +"PIIS002",,"False",,"False","False",,"False" +"CTSTPALT001","False","False",,"False","False",,"False" +"KSOVEPAPP010",,"False",,"False","False",,"False" +"PSQL016","False","False",,"False","True","System.String[]","True" +"PSIS002","False","False",,"False","True","System.String[]","True" +"PVVC015","False","False",,"False","False",,"False" +"PVVC011","False","False",,"False","False",,"False" +"PFNP010","False","False",,"False","True","System.String[]","True" +"PLNC002","False","False",,"False","False",,"False" +"AZPHPALT001","False","False",,"False","False",,"False" +"PCPR001","False","False",,"False","False",,"False" +"PSQL015","False","False",,"False","True","System.String[]","True" +"PDFS002","False","False",,"False","False",,"False" +"PBTS001","False","False",,"False","False",,"False" +"PBLD001","False","False",,"False","True","System.String[]","True" +"KSOPPALT001","False","False",,"False","False",,"False" +"PEZP001","False","False",,"False","True","System.String[]","True" +"PSUF002","False","False",,"False","False",,"False" +"PKEY001","False","False",,"False","True","System.String[]","True" +"PVTS005",,"False",,"False","False",,"False" +"PADF001","False","False",,"False","False",,"False" +"PALT001","False","False",,"False","False",,"False" +"PPCS001","False","False",,"False","False",,"False" +"PSRS003","False","False",,"False","False",,"False" +"PALM001","False","False",,"False","False",,"False" +"PSQL013","False","False",,"False","True","System.String[]","True" +"PVVC014","False","False",,"False","False",,"False" +"PIPM001","False","False",,"False","False",,"False" +"PSRS002","False","False",,"False","False",,"False" +"PSIS001","False","False",,"False","False",,"False" +"PVTS001",,"False",,"False","False",,"False" +"PDFS003","False","False",,"False","False",,"False" +"PMHB001","False","False",,"False","False",,"False" +"PFNP012","False","False",,"False","True","System.String[]","True" +"PDOC001","False","False",,"False","False",,"False" +"PFNP008","False","False",,"False","True","System.String[]","True" +"FLT2PALT001","False","False",,"False","False",,"False" +"PUTL006","False","False",,"False","True","System.String[]","True" +"PIIS003","False","False",,"False","False",,"False" +"PSEV010","False","False",,"False","False",,"False" +"PSEV013","False","False",,"False","False",,"False" +"PUTL011","False","False",,"False","True","System.String[]","True" +"PFAX004",,"False",,"False","False",,"False" +"PSNW001","False","False",,"False","False",,"False" +"PMON007","False","False",,"False","True","System.String[]","True" +"PSQL010","False","False",,"False","True","System.String[]","True" +"PDWH002","False","False",,"False","False",,"False" +"PSQL009","False","False",,"False","True","System.String[]","True" +"PVVC016","False","False",,"False","False",,"False" +"PVCO001","False","False",,"False","False",,"False" +"PFNP002","False","False",,"False","True","System.String[]","True" +"PWHD004","False","False",,"False","False",,"False" +"PDEP001","False","False",,"False","False",,"False" +"PVVC012","False","False",,"False","False",,"False" +"PVSS012","False","False",,"False","False",,"False" +"PVAV001","False","False",,"False","True","System.String[]","True" +"PGAW001","False","False",,"False","True","System.String[]","True" +"PAPP011","False","False",,"False","True","System.String[]","True" +"PSWF001","False","False",,"False","True","System.String[]","True" +"PVRS012","False","False",,"False","True","System.String[]","True" +"PSAP001","False","False",,"False","True","System.String[]","True" +"PFNP006","False","False",,"False","True","System.String[]","True" +"PSQL012","False","False",,"False","True","System.String[]","True" +"PKEY002","False","False",,"False","True","System.String[]","True" +"PSRS004","False","False",,"False","True","System.String[]","True" +"PSEV022","False","False",,"False","False",,"False" +"PSEV015","False","False",,"False","False",,"False" +"PCCR001","False","False",,"False","True","System.String[]","True" +"PSQL026","False","False",,"False","True","System.String[]","True" +"PVRS011","False","False",,"False","True","System.String[]","True" +"PFNP015","False","False",,"False","False",,"False" +"PSEV024","False","False",,"False","False",,"False" +"PVRT006","False","False",,"False","False",,"False" +"PRSH016","False","False",,"False","False",,"False" +"PRSH033","False","False",,"False","False",,"False" +"PRSH036","False","False",,"False","False",,"False" +"PRSH040","False","False",,"False","False",,"False" +"PRSH021","False","False",,"False","False",,"False" +"PRSH032","False","False",,"False","False",,"False" +"PRSH027","False","False",,"False","True","System.String[]","True" +"PRSH182","False","False",,"False","True","System.String[]","True" +"PRSH028","False","False",,"False","False",,"False" +"PRSH175","False","False",,"False","True","System.String[]","True" +"PEDI116","False","False",,"False","True","System.String[]","True" +"PRSH029","False","False",,"False","False",,"False" +"PVRT003","False","False",,"False","False",,"False" +"PRSH014","False","False",,"False","False",,"False" +"PRSH018","False","False",,"False","False",,"False" +"PRSH002","False","False",,"False","False",,"False" +"PRSH005","False","False",,"False","False",,"False" +"PRSH162","False","False",,"False","True","System.String[]","True" +"PRSH176","False","False",,"False","True","System.String[]","True" +"PBIZ112","False","False",,"False","False",,"False" +"PBIZ111","False","False",,"False","False",,"False" +"PRSH000","False","False",,"False","False",,"False" +"PRSH026","False","False",,"False","False",,"False" +"PVRT005","False","False",,"False","False",,"False" +"PRSH030","False","False",,"False","False",,"False" +"PRSH174","False","False",,"False","True","System.String[]","True" +"PRSH013","False","False",,"False","False",,"False" +"PRSH004","False","False",,"False","False",,"False" +"PRSH039","False","False",,"False","False",,"False" +"PRSH008","False","False",,"False","False",,"False" +"PRSH022","False","False",,"False","False",,"False" +"PRSH015","False","False",,"False","False",,"False" +"PRSH019","False","False",,"False","False",,"False" +"PRSH012","False","False",,"False","False",,"False" +"PEDI113","False","False",,"False","True","System.String[]","True" +"PRSH003","False","False",,"False","False",,"False" +"PRSH011","False","False",,"False","False",,"False" +"PRSH102","False","False",,"False","True","System.String[]","True" +"PRSH017","False","False",,"False","False",,"False" +"PRDS001","False","False",,"False","False",,"False" +"PRSH010","False","False",,"False","False",,"False" +"PRSH025","False","False",,"False","False",,"False" +"PRSH181","False","False",,"False","False",,"False" +"PRSH006","False","False",,"False","False",,"False" +"PRSH151","False","False",,"False","True","System.String[]","True" +"PRSH007","False","False",,"False","False",,"False" +"PRSH035","False","False",,"False","False",,"False" +"PRSH037","False","False",,"False","False",,"False" +"PVRT004","False","False",,"False","False",,"False" +"PRSH031","False","False",,"False","False",,"False" +"PRSH009","False","False",,"False","False",,"False" +"PRSH020","False","False",,"False","False",,"False" +"PRSH172","False","False",,"False","True","System.String[]","True" +"PRSH034","False","False",,"False","False",,"False" +"PRSH023","False","False",,"False","False",,"False" +"PEDI112","False","False",,"False","True","System.String[]","True" +"PRSH101","False","False",,"False","True","System.String[]","True" +"PRSH024","False","False",,"False","False",,"False" +"PRSH001","False","False",,"False","False",,"False" +"PRSH038","False","False",,"False","False",,"False" +"PRSH161","False","False",,"False","True","System.String[]","True" +"PVRT001","False","False",,"False","False",,"False" +"PVRT002","False","False",,"False","False",,"False" +"PRSH051","False","False",,"False","False",,"False" +"PSQL025","False","False",,"False","False",,"False" +"PEDI114","False","False",,"False","True","System.String[]","True" +"PEDI111","False","False",,"False","True","System.String[]","True" +"PEDI115","False","False",,"False","True","System.String[]","True" +"PRSH056","False","False",,"False","False",,"False" +"PRSH053","False","False",,"False","False",,"False" +"PRSH173","False","False",,"False","True","System.String[]","True" +"PRDS002","False","False",,"False","True","System.String[]","True" +"PRSH059","False","False",,"False","False",,"False" +"PRSH054","False","False",,"False","False",,"False" +"PRSH058","False","False",,"False","False",,"False" +"PRSH057","False","False",,"False","False",,"False" +"PRSH171","False","False",,"False","True","System.String[]","True" +"PRSH052","False","False",,"False","False",,"False" +"PRSH060","False","False",,"False","False",,"False" +"PRSH050","False","False",,"False","False",,"False" +"PRSH049","False","False",,"False","True","System.String[]","True" +"PRSH055","False","False",,"False","False",,"False" +"KSOVEPOPS001",,"False",,"False","False",,"False" +"PDISKTEST1","False","False",,"False","True","System.String[]","True" +"PAPP001","False","False",,"False","True","System.String[]","True" +"PFNP013","False","False",,"False","True","System.String[]","True" +"PVAV002","False","False",,"False","True","System.String[]","True" +"PVCO007","False","False",,"False","True","System.String[]","True" +"PDMC006","False","False",,"False","True","System.String[]","True" +"FLT2PDMC001","False","False",,"False","True","System.String[]","True" +"CTSTPDMC001","False","False",,"False","False",,"False" +"FLT2PDMC002","False","False",,"False","False",,"False" +"PDMC005","False","False",,"False","True","System.String[]","True" +"KSOPPDMC001","False","False",,"False","False",,"False" +"CTHAPDMC001","False","False",,"False","True","System.String[]","True" +"NYMEPDMC001","False","False",,"False","True","System.String[]","True" +"PDMC004","False","False",,"False","True","System.String[]","True" +"AZPHPDMC001","False","False",,"False","True","System.String[]","True" +"PIAM001","False","False",,"False","True","System.String[]","True" +"PIAM002","False","False",,"False","True","System.String[]","True" +"PIAC001","False","False",,"False","True","System.String[]","True" +"PIWM001","False","False",,"False","True","System.String[]","True" +"PIWM002","False","False",,"False","True","System.String[]","True" +"PICO001","True","False",,"False","True","System.String[]","True" +"POWA001","False","False",,"False","True","System.String[]","True" +"PVAV003","False","False",,"False","True","System.String[]","True" +"PSPT001","False","False",,"False","True","System.String[]","True" +"PBIZ122","False","False",,"False","False",,"False" +"PBIZ124","False","False",,"False","False",,"False" +"PBIZ125","False","False",,"False","False",,"False" +"PBIZ126","False","False",,"False","False",,"False" +"PBIZ123","False","False",,"False","False",,"False" +"PSLK001","False","False",,"False","False",,"False" +"PBIZ121","False","False",,"False","False",,"False" +"PFAX014","False","False",,"False","False",,"False" +"PDRF001","False","False",,"False","True","System.String[]","True" +"PSNX001","False","False",,"False","True","System.String[]","True" +"PIAP002","False","False",,"False","True","System.String[]","True" +"PFNP014","False","False",,"False","False",,"False" +"PFAX013","False","False",,"False","False",,"False" +"PMFT001","False","False",,"False","True","System.String[]","True" +"PFAX015","False","False",,"False","True","System.String[]","True" +"PIAP001","False","False",,"False","True","System.String[]","True" +"PMON006","False","False",,"False","True","System.String[]","True" +"PMQS001","False","False",,"False","True","System.String[]","True" +"PFOG001","False","False",,"False","True","System.String[]","True" +"PADS001","False","False",,"False","False",,"False" +"PFAX012","False","False",,"False","False",,"False" +"PRMS002","False","False",,"False","False",,"False" +"PRMS001","False","False",,"False","False",,"False" +"PFAX011","False","False",,"False","True","System.String[]","True" +"PFNP016","False","False",,"False","False",,"False" +"PFNP017","False","False",,"False","False",,"False" +"PJMP001","False","False",,"False","True","System.String[]","True" +"PKEY003","False","False",,"False","True","System.String[]","True" +"PUTL012","False","False",,"False","True","System.String[]","True" +"PIQV001","False","False",,"False","True","System.String[]","True" +"PSUS001","False","False",,"False","True","System.String[]","True" +"PSQL022","False","False",,"False","True","System.String[]","True" +"PSQL023B","False","False",,"False","True","System.String[]","True" +"PSQL022B","False","False",,"False","True","System.String[]","True" +"PSQL023","False","False",,"False","True","System.String[]","True" +"PSQL024","False","False",,"False","True","System.String[]","True" +"PSQL028B","False","False",,"False","True","System.String[]","True" +"PSIS003","False","False",,"False","False",,"False" +"PSQL029A","False","False",,"False","True","System.String[]","True" +"PSQL029B","False","False",,"False","True","System.String[]","True" +"PSQL028A","False","False",,"False","True","System.String[]","True" +"PCMX001","False","False",,"False","True","System.String[]","True" +"PSSP001","False","False",,"False","True","System.String[]","True" +"PSSP002","False","False",,"False","True","System.String[]","True" +"PSQL030A","False","False",,"False","True","System.String[]","True" +"PSQL030B","False","False",,"False","True","System.String[]","True" +"PAPJNKSSLA201","False","False",,"False","True","System.String[]","True" +"PNCRAFILE001","False","False",,"False","True","System.String[]","True" +"PSSP004","False","False",,"False","True","System.String[]","True" +"PSSP003","False","False",,"False","True","System.String[]","True" +"PNCRAFILE005","False","False",,"False","True","System.String[]","True" +"FLT2VEB002","False","False",,"False","False",,"False" +"PNCRAFILE003","False","False",,"False","True","System.String[]","True" +"PNCRANTRX002","False","False",,"False","False",,"False" +"FLT2VEB003","False","False",,"False","False",,"False" +"PNCRAVERIDX003","False","False",,"False","False",,"False" +"PNCRAVERVLT002","False","False",,"False","True","System.String[]","True" +"PNCRAMSMQ001","False","False",,"False","True","System.String[]","True" +"PNCRAVERVLT003","False","False",,"False","False",,"False" +"PNCRAVERVLT001","False","False",,"False","True","System.String[]","True" +"PNCRAVERIDX002","False","False",,"False","False",,"False" +"PNCRAVERIDX001","False","False",,"False","False",,"False" +"PNCRAVERDA001","False","False",,"False","False",,"False" +"PRSH152","False","False",,"False","True","System.String[]","True" diff --git a/dump/WSUS_Scripts/Files/PENDING-Reboots-CCXQ2-10-29-2019.csv b/dump/WSUS_Scripts/Files/PENDING-Reboots-CCXQ2-10-29-2019.csv new file mode 100644 index 0000000..b4f5ebe --- /dev/null +++ b/dump/WSUS_Scripts/Files/PENDING-Reboots-CCXQ2-10-29-2019.csv @@ -0,0 +1,6 @@ +"Computer","CBServicing","WindowsUpdate","CCMClientSDK","PendComputerRename","PendFileRename","PendFileRenVal","RebootPending" +"Q2FNP003","False","False",,"False","False",,"False" +"QRSH022","False","False",,"False","True","System.String[]","True" +"QRSH021","False","False",,"False","False",,"False" +"QRSH023","False","False",,"False","False",,"False" +"Q2SQL022","False","False",,"False","True","System.String[]","True" diff --git a/dump/WSUS_Scripts/Files/PENDING-Reboots-CCXQ4-10-23-2019.csv b/dump/WSUS_Scripts/Files/PENDING-Reboots-CCXQ4-10-23-2019.csv new file mode 100644 index 0000000..83765c6 --- /dev/null +++ b/dump/WSUS_Scripts/Files/PENDING-Reboots-CCXQ4-10-23-2019.csv @@ -0,0 +1,8 @@ +"Computer","CBServicing","WindowsUpdate","CCMClientSDK","PendComputerRename","PendFileRename","PendFileRenVal","RebootPending" +"QBIZ142","False","False",,"False","False",,"False" +"QBIZ141","False","False",,"False","False",,"False" +"QAPP041","False","False",,"False","True","System.String[]","True" +"QRSH041","False","False",,"False","False",,"False" +"Q4SQL022B","False","False",,"False","True","System.String[]","True" +"Q4FNP003","False","False",,"False","False",,"False" +"Q4SQL022","False","False",,"False","True","System.String[]","True" diff --git a/dump/WSUS_Scripts/Files/PENDING-Reboots-CCXQ5-10-22-2019.csv b/dump/WSUS_Scripts/Files/PENDING-Reboots-CCXQ5-10-22-2019.csv new file mode 100644 index 0000000..56d2f72 --- /dev/null +++ b/dump/WSUS_Scripts/Files/PENDING-Reboots-CCXQ5-10-22-2019.csv @@ -0,0 +1,6 @@ +"Computer","CBServicing","WindowsUpdate","CCMClientSDK","PendComputerRename","PendFileRename","PendFileRenVal","RebootPending" +"QAPP051","False","False",,"False","True","System.String[]","True" +"QRSH051","False","False",,"False","False",,"False" +"Q5FNP003","False","False",,"False","False",,"False" +"QBIZ152","False","False",,"False","True","System.String[]","True" +"Q5SQL022","False","False",,"False","True","System.String[]","True" diff --git a/dump/WSUS_Scripts/Files/new-Patch-WSUSGroup-backup1.ps1 b/dump/WSUS_Scripts/Files/new-Patch-WSUSGroup-backup1.ps1 new file mode 100644 index 0000000..b4d8c50 --- /dev/null +++ b/dump/WSUS_Scripts/Files/new-Patch-WSUSGroup-backup1.ps1 @@ -0,0 +1,76 @@ +<# + +$ErrorActionPreference = "Ignore" +$WSUSGroup = Read-Host "Enter Target Group Name" +$servers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select Fulldomainname -ExpandProperty Fulldomainname +Foreach ($server in $servers) {Install-WindowsUpdate -ComputerName $server -AsJob} + +#Function Restart {# Force Reboot of Group (when auto failed) un-rem and run line below. +#Foreach ($server in $servers) {Restart-Computer -ComputerName $server -Force}} + +#Write-Host "Type Restart and press enter to reboot the $WSUSGroup WSUS Computer Group" +Read-Host -Prompt "Press Enter to exit" +#> + +################################################################################################################################# +#$ErrorActionPreference = "Ignore" +$WSUSGroup = Read-Host "Enter Target Group Name" + +$servers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select Fulldomainname -ExpandProperty Fulldomainname + +#$servers = "W2012A","W2012B","slfkjsdl" +#$WSUSGroup = "Test GGroupp" +$Location = Split-Path $MyInvocation.MyCommand.Path -Parent +$Dte = Get-Date -UFormat %m-%d-%Y +$Collect_Jobs = @() +$Patch_Job = @() + +$servers | Out-File $Location\Patching-Day\"$WSUSGroup"-Server-Patching-Today-$Dte.txt +$servers | Out-File E:\WSUS_Scripts\Patching-Day\"$WSUSGroup"-Server-Patching-Today-Backup-$Dte.txt + +Foreach ($server in $servers) { + + $Patch_Job += Start-Job -ScriptBlock { Param($server) Install-WindowsUpdate -ComputerName $server } -Name "$server-Patching" -ArgumentList $server + + Invoke-Command $server -ErrorAction SilentlyContinue { + New-EventLog -LogName Application -Source "Patching-Started" -ErrorAction SilentlyContinue + New-EventLog -LogName Application -Source "Patching-Finished" -ErrorAction SilentlyContinue + New-EventLog -LogName System -Source "Reboot-After-Patching" -ErrorAction SilentlyContinue + Write-EventLog -LogName Application -Source "Patching-Started" -EntryType Information -EventId 7890 -Message "Server Patching Started with Powershell" + }#endInvoke + + + + + #Install-WindowsUpdate -ComputerName $server -AsJob + + + + +}#endForeach + +Get-Job + +$Patch_Job | Export-Csv $Location\Patching-Day\Patching-Jobs-$Dte.csv -NoTypeInformation +$Patch_Job | Export-Csv E:\WSUS_Scripts\Patching-Day\Patching-Jobs-Backup-$Dte.csv -NoTypeInformation + +$Collect_Jobs = Get-Job | Export-Csv $Location\Patching-Day\Collect-Patching-Jobs-$Dte.csv -NoTypeInformation +$Collect_Jobs = Get-Job | Export-Csv E:\WSUS_Scripts\Patching-Day\Collect-Patching-Jobs-Backup-$Dte.csv -NoTypeInformation + +$Patch_Job | Select @{n="Server";e={$_.Name.Split('-')[0]}},@{n="MainJobID";e={$_.ID}},@{n="MainJobName";e={$_.Name}},@{n="ChildJobID";e={$_.Childjobs.ID}},@{n="ChildJobState";e={$_.Childjobs.State}},PSBeginTime,PSEndTime,Command | Export-Csv $Location\Patching-Day\Jobs-ChildJobs-$Dte.csv -NoTypeInformation +$Patch_Job | Select @{n="Server";e={$_.Name.Split('-')[0]}},@{n="MainJobID";e={$_.ID}},@{n="MainJobName";e={$_.Name}},@{n="ChildJobID";e={$_.Childjobs.ID}},@{n="ChildJobState";e={$_.Childjobs.State}},PSBeginTime,PSEndTime,Command | Export-Csv E:\WSUS_Scripts\Patching-Day\Jobs-ChildJobs-Backup-$Dte.csv -NoTypeInformation + +#Function Restart {# Force Reboot of Group (when auto failed) un-rem and run line below. +#Foreach ($server in $servers) {Restart-Computer -ComputerName $server -Force}} + +#Write-Host "Type Restart and press enter to reboot the $WSUSGroup WSUS Computer Group" + + + + + + + + + + \ No newline at end of file diff --git a/dump/WSUS_Scripts/Lock_Script.txt b/dump/WSUS_Scripts/Lock_Script.txt new file mode 100644 index 0000000..e69de29 diff --git a/dump/WSUS_Scripts/Old-Scripts/Get-WSUSGroupFailedUpdates.ps1 b/dump/WSUS_Scripts/Old-Scripts/Get-WSUSGroupFailedUpdates.ps1 new file mode 100644 index 0000000..a8557b7 --- /dev/null +++ b/dump/WSUS_Scripts/Old-Scripts/Get-WSUSGroupFailedUpdates.ps1 @@ -0,0 +1,26 @@ +$WSUSGroup = Read-Host "Enter Target Group Name" +$Computers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select Fulldomainname -ExpandProperty Fulldomainname + +foreach ($computer in $computers){ +if(!(Test-Connection -Cn $computer -BufferSize 16 -Count 1 -ea 0 -quiet)) +{write-host "cannot reach $computer" -f red} + +else {$Session = New-Object -ComObject "Microsoft.Update.Session" + +$Searcher = $Session.CreateUpdateSearcher() + +$historyCount = $Searcher.GetTotalHistoryCount() + +$Searcher.QueryHistory(0, $historyCount) | Select-Object @{Name="Computer"; Expression={$Computer}}, Date, + + @{name="Operation"; expression={switch($_.operation){ + + 1 {"Installation"}; 2 {"Uninstallation"}; 3 {"Other"}}}}, + + @{name="Status"; expression={switch($_.resultcode){ + + 1 {"In Progress"}; 2 {"Succeeded"}; 3 {"Succeeded With Errors"}; + + 4 {"Failed"}; 5 {"Aborted"} + +}}},Title| Where {$_.Status -eq "Failed"}|Write-Host|Export-Csv -NoType "$Env:userprofile\Desktop\$wsusgroup-Failed-WindowsUpdates.csv" -Append}} \ No newline at end of file diff --git a/dump/WSUS_Scripts/Old-Scripts/Get-WSUSGroupPatchInProgress.ps1 b/dump/WSUS_Scripts/Old-Scripts/Get-WSUSGroupPatchInProgress.ps1 new file mode 100644 index 0000000..b602935 --- /dev/null +++ b/dump/WSUS_Scripts/Old-Scripts/Get-WSUSGroupPatchInProgress.ps1 @@ -0,0 +1,26 @@ +$WSUSGroup = Read-Host "Enter Target Group Name" +$Computers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select Fulldomainname -ExpandProperty Fulldomainname + +foreach ($computer in $computers){ +if(!(Test-Connection -Cn $computer -BufferSize 16 -Count 1 -ea 0 -quiet)) +{write-host "cannot reach $computer" -f red} + +else {$Session = New-Object -ComObject "Microsoft.Update.Session" + +$Searcher = $Session.CreateUpdateSearcher() + +$historyCount = $Searcher.GetTotalHistoryCount() + +$Searcher.QueryHistory(0, $historyCount) | Select-Object @{Name="Computer"; Expression={$Computer}}, Date, + + @{name="Operation"; expression={switch($_.operation){ + + 1 {"Installation"}; 2 {"Uninstallation"}; 3 {"Other"}}}}, + + @{name="Status"; expression={switch($_.resultcode){ + + 1 {"In Progress"}; 2 {"Succeeded"}; 3 {"Succeeded With Errors"}; + + 4 {"Failed"}; 5 {"Aborted"} + +}}},Title| Where {$_.Status -eq "In Progress"}|Write-Host}} \ No newline at end of file diff --git a/dump/WSUS_Scripts/Old-Scripts/Get-WSUSGroupPatchStatus.ps1 b/dump/WSUS_Scripts/Old-Scripts/Get-WSUSGroupPatchStatus.ps1 new file mode 100644 index 0000000..b602935 --- /dev/null +++ b/dump/WSUS_Scripts/Old-Scripts/Get-WSUSGroupPatchStatus.ps1 @@ -0,0 +1,26 @@ +$WSUSGroup = Read-Host "Enter Target Group Name" +$Computers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select Fulldomainname -ExpandProperty Fulldomainname + +foreach ($computer in $computers){ +if(!(Test-Connection -Cn $computer -BufferSize 16 -Count 1 -ea 0 -quiet)) +{write-host "cannot reach $computer" -f red} + +else {$Session = New-Object -ComObject "Microsoft.Update.Session" + +$Searcher = $Session.CreateUpdateSearcher() + +$historyCount = $Searcher.GetTotalHistoryCount() + +$Searcher.QueryHistory(0, $historyCount) | Select-Object @{Name="Computer"; Expression={$Computer}}, Date, + + @{name="Operation"; expression={switch($_.operation){ + + 1 {"Installation"}; 2 {"Uninstallation"}; 3 {"Other"}}}}, + + @{name="Status"; expression={switch($_.resultcode){ + + 1 {"In Progress"}; 2 {"Succeeded"}; 3 {"Succeeded With Errors"}; + + 4 {"Failed"}; 5 {"Aborted"} + +}}},Title| Where {$_.Status -eq "In Progress"}|Write-Host}} \ No newline at end of file diff --git a/dump/WSUS_Scripts/Old-Scripts/Get-WSUSGroupUpdatesInProgress.ps1 b/dump/WSUS_Scripts/Old-Scripts/Get-WSUSGroupUpdatesInProgress.ps1 new file mode 100644 index 0000000..9fa538a --- /dev/null +++ b/dump/WSUS_Scripts/Old-Scripts/Get-WSUSGroupUpdatesInProgress.ps1 @@ -0,0 +1,28 @@ +#https://gallery.technet.microsoft.com/scriptcenter/Get-Installed-FailedWindows-9f28742a + +$WSUSGroup = Read-Host "Enter Target Group Name" +$Computers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select Fulldomainname -ExpandProperty Fulldomainname + +foreach ($computer in $computers){ +if(!(Test-Connection -Cn $computer -BufferSize 16 -Count 1 -ea 0 -quiet)) +{write-host "cannot reach $computer" -f red} + +else {$Session = New-Object -ComObject "Microsoft.Update.Session" + +$Searcher = $Session.CreateUpdateSearcher() + +$historyCount = $Searcher.GetTotalHistoryCount() + +$Searcher.QueryHistory(0, $historyCount) | Select-Object @{Name="Computer"; Expression={$Computer}}, Date, + + @{name="Operation"; expression={switch($_.operation){ + + 1 {"Installation"}; 2 {"Uninstallation"}; 3 {"Other"}}}}, + + @{name="Status"; expression={switch($_.resultcode){ + + 1 {"In Progress"}; 2 {"Succeeded"}; 3 {"Succeeded With Errors"}; + + 4 {"Failed"}; 5 {"Aborted"} + +}}},Title| Where {$_.Status -eq "In Progress"}}} \ No newline at end of file diff --git a/dump/WSUS_Scripts/Old-Scripts/NewSorting.ps1 b/dump/WSUS_Scripts/Old-Scripts/NewSorting.ps1 new file mode 100644 index 0000000..766152e --- /dev/null +++ b/dump/WSUS_Scripts/Old-Scripts/NewSorting.ps1 @@ -0,0 +1,19 @@ +Import-Module ActiveDirectory +Import-Module WindowsUpdate + + +$ServerList = Import-Csv 'C:\Users\abamaso-ccxadmin\Desktop\CompletedProd_WindowsServers - Classifications.csv' + + +foreach ($Server in $ServerList) { +$patchingtier = $Server.Classification + +switch ($patchingtier){ + +"Tier0 - Infrastructure" {Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server.'Server Name'| Add-WsusComputer -TargetGroupName "Tier0 - Infrastructure"} +"Tier1 - Critical Infrastructure" {Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server.'Server Name'| Add-WsusComputer -TargetGroupName "Tier1 - Critical Infrastructure"} +"Tier2 - File Servers" {Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server.'Server Name'| Add-WsusComputer -TargetGroupName "Tier2 - File Servers"} +"Tier2 - Application Servers" {Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server.'Server Name'| Add-WsusComputer -TargetGroupName "Tier2 - Application Servers"} +} +Write-host $Server.'Server Name'" Sorted into Group" +} \ No newline at end of file diff --git a/dump/WSUS_Scripts/Old-Scripts/Patch Checklist.xlsx b/dump/WSUS_Scripts/Old-Scripts/Patch Checklist.xlsx new file mode 100644 index 0000000..d6adc60 Binary files /dev/null and b/dump/WSUS_Scripts/Old-Scripts/Patch Checklist.xlsx differ diff --git a/dump/WSUS_Scripts/Old-Scripts/Sorting_Hat.ps1 b/dump/WSUS_Scripts/Old-Scripts/Sorting_Hat.ps1 new file mode 100644 index 0000000..853a8b0 --- /dev/null +++ b/dump/WSUS_Scripts/Old-Scripts/Sorting_Hat.ps1 @@ -0,0 +1,603 @@ +# +# WSUS_Sorting_HAT.PS1 +# +#DOCUMENTATION: +#Written by Kevin Trent, kevin.trent@carecentrix.com + +#CHANGE LOG: + #Version 1.0 6/12/2018 - First functional edition - Kevin Trent + +#UPGRADES: + # Planned: + # Add auto detection of new OU and auto creation of new function. - KJT + +#DESCRIPTION: +#WSUS Server-Side targeting chosen to enable flexibility with group assignment. Sorting Hat, takes the place of client-side targeting in a GPO. +#Servers are still added to the unassigned computers group via linked GPO: + #(Prod Server SUS 2016 - PSUS002 - Server Side Targeting, DEV Server SUS 2016 - PSUS002 - Server Side Targeting, QA Server SUS 2016 - PSUS002 - Server Side Targeting) +#Each function sorts systems from the WSUS unassigned computers group to an appropriate target group based on the AD OU. + +#MAINTENANCE: +#NEW Active Directory OUs require reciprocal functions to be added. + #New Function Copy/Paste existing function and make these required changes: + #Function name = WSUS Group Name, remove spaces - between each word. + #Variable name - WSUS Group Name, remove spaces change - to _. TargetGroupName = WSUS Group name. + #Canonicalname = OU with wildcard (*) in place of machine name(s). + #Find Canonicalname of a group by running the following command against a machine in that OU: Get-ADComputer -Identity qbiz111 -Properties *|select CanonicalName + #Add Group function to the Run function: (If $newservers.count -gt 0) Scriptblock near the bottom, so that the new function is called when the script is executed. + #Add comment to the ChangeLog remark above + +#Module Import. This Script requires RSAT and PowerShell v3.0 or higher on the executing system. +Import-Module ActiveDirectory +Import-Module WindowsUpdate + +#System Collection: +#Building the collections to be sorted from the WSUS unassigned computers group removes the need to validate each member. + #Each array memeber can only be in the collection if it passed cetificate, protocol, and connectivity requirements. +$newserversfull = Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -ComputerTargetGroups "Unassigned Computers"|select Fulldomainname -ExpandProperty Fulldomainname + +#Shortening the array member names to a useable Get-ADComputer Identity +$newservers = Foreach ($server in $newserversfull) {$server.split(‘.’)[0]} + +#SORTING FUNCTIONS: +#Each function runs each memeber of the collection through a loop that contains an AD-OU query. If the member(s) are in the specified AD-OU they are inserted into the WSUS Target Group. +#For simplified locating; functions are grouped under comments with the WSUS group parent name. Example, NCRA QUALITY ASSURANCE SERVERS or CTHA PRODUCTION SERVERS + +#CTHA PRODUCTION SERVERS +Function CTHA-Verint-PROD { + $CTHA_Verint_PROD = Foreach ($server in $newservers) { + Get-ADComputer -Identity $server -Properties * | + Select dnshostname,canonicalname -ExpandProperty canonicalname| + Where canonicalname -Like "ccx.carecentrix.com/CTHA/Servers/Production Servers/Verint Servers/*"| + Select dnshostname -ExpandProperty dnshostname + } + + Foreach ($server in $CTHA_Verint_PROD) { + Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "CTHA - Verint - PROD" + } + +} + +#KSOP PRODUCTION SERVERS +Function KSOP-Verint-PROD { + $KSOP_Verint_PROD = Foreach ($server in $newservers) { + Get-ADComputer -Identity $server -Properties * | + Select dnshostname,canonicalname -ExpandProperty canonicalname| + Where canonicalname -Like "ccx.carecentrix.com/KSOP/Servers/Production Servers/Verint Servers/*"| + Select dnshostname -ExpandProperty dnshostname + } + + Foreach ($server in $KSOP_Verint_PROD) { + Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "KSOP - Verint - PROD" + } + +} + +#AZPH PRODUCTION SERVERS +Function AZPH-Verint-PROD { + $AZPH_Verint_PROD = Foreach ($server in $newservers) { + Get-ADComputer -Identity $server -Properties * | + Select dnshostname,canonicalname -ExpandProperty canonicalname| + Where canonicalname -Like "ccx.carecentrix.com/AZPH/Servers/Production Servers/Verint Servers/*"| + Select dnshostname -ExpandProperty dnshostname + } + + Foreach ($server in $AZPH_Verint_PROD) { + Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "AZPH - Verint - PROD" + } + +} + +#FLT2 PRODUCTION SERVERS +Function FLT2-Application-PROD { + $FLT2_Application_PROD = Foreach ($server in $newservers) { + Get-ADComputer -Identity $server -Properties * | + Select dnshostname,canonicalname -ExpandProperty canonicalname| + Where canonicalname -Like "ccx.carecentrix.com/FLT2/Servers/Production Servers/Application Servers/*"| + Select dnshostname -ExpandProperty dnshostname + } + + Foreach ($server in $FLT2_Application_PROD) { + Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "FLT2 - Application - PROD" + } + +} + +Function FLT2-Verint-PROD { + $FLT2_Verint_PROD = Foreach ($server in $newservers) { + Get-ADComputer -Identity $server -Properties * | + Select dnshostname,canonicalname -ExpandProperty canonicalname| + Where canonicalname -Like "ccx.carecentrix.com/FLT2/Servers/Production Servers/Verint Servers/*"| + Select dnshostname -ExpandProperty dnshostname + } + + Foreach ($server in $FLT2_Verint_PROD) { + Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "FLT2 - Verint - PROD" + } + +} + +Function FLT2-Voice-PROD { + $FLT2_Voice_PROD = Foreach ($server in $newservers) { + Get-ADComputer -Identity $server -Properties * | + Select dnshostname,canonicalname -ExpandProperty canonicalname| + Where canonicalname -Like "ccx.carecentrix.com/FLT2/Servers/Production Servers/Voice Servers/*"| + Select dnshostname -ExpandProperty dnshostname + } + + Foreach ($server in $FLT2_Voice_PROD) { + Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "FLT2 - Voice - PROD" + } + +} + +#NCRA DEVELOPMENT SERVERS +Function NCRA-Application-DEV { + $NCRA_Application_DEV = Foreach ($server in $newservers) { + Get-ADComputer -Identity $server -Properties * | + Select dnshostname,canonicalname -ExpandProperty canonicalname| + Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/Development Servers/Application Servers/*"| + Select dnshostname -ExpandProperty dnshostname + } + + Foreach ($server in $NCRA_Application_DEV) { + Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - Application - DEV" + } + +} + +Function NCRA-BizTalk-DEV { + $NCRA_BizTalk_DEV = Foreach ($server in $newservers) { + Get-ADComputer -Identity $server -Properties * | + Select dnshostname,canonicalname -ExpandProperty canonicalname| + Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/Development Servers/BizTalk Servers/*"| + Select dnshostname -ExpandProperty dnshostname + } + + Foreach ($server in $NCRA_BizTalk_DEV) { + Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - BizTalk - DEV" + } + +} + +Function NCRA-Edifecs-DEV { + $NCRA_Edifecs_DEV = Foreach ($server in $newservers) { + Get-ADComputer -Identity $server -Properties * | + Select dnshostname,canonicalname -ExpandProperty canonicalname| + Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/Development Servers/Edifecs Servers/*"| + Select dnshostname -ExpandProperty dnshostname + } + + Foreach ($server in $NCRA_Edifecs_DEV) { + Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - Edifecs - DEV" + } + +} + +Function NCRA-Remote-Desktop-DEV{ + $NCRA_Remote_Desktop_DEV = Foreach ($server in $newservers) { + Get-ADComputer -Identity $server -Properties * | + Select dnshostname,canonicalname -ExpandProperty canonicalname| + Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/Development Servers/Remote Desktop Servers/*"| + Select dnshostname -ExpandProperty dnshostname + } + + Foreach ($server in $NCRA_Remote_Desktop_DEV) { + Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - Remote Desktop - DEV" + } + +} + +Function NCRA-SQL-DEV { + $NCRA_SQL_DEV = Foreach ($server in $newservers) { + Get-ADComputer -Identity $server -Properties * | + Select dnshostname,canonicalname -ExpandProperty canonicalname| + Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/Development Servers/SQL Servers/*"| + Select dnshostname -ExpandProperty dnshostname + } + + Foreach ($server in $NCRA_SQL_DEV) { + Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - SQL - DEV" + } + +} + +Function NCRA-Terminal-Servers-DEV { + $NCRA_Terminal_Servers_DEV = Foreach ($server in $newservers) { + Get-ADComputer -Identity $server -Properties * | + Select dnshostname,canonicalname -ExpandProperty canonicalname| + Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/Development Servers/Terminal Servers/*"| + Select dnshostname -ExpandProperty dnshostname + } + + Foreach ($server in $NCRA_Application_DEV) { + Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - Terminal Servers - DEV" + } + +} + +Function NCRA-Voice-DEV { + $NCRA_Voice_DEV = Foreach ($server in $newservers) { + Get-ADComputer -Identity $server -Properties * | + Select dnshostname,canonicalname -ExpandProperty canonicalname| + Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/Development Servers/Voice Servers/*"| + Select dnshostname -ExpandProperty dnshostname + } + + Foreach ($server in $NCRA_Voice_DEV) { + Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - Voice - DEV" + } + +} + +Function NCRA-Web-DEV { + $NCRA_Web_DEV = Foreach ($server in $newservers) { + Get-ADComputer -Identity $server -Properties * | + Select dnshostname,canonicalname -ExpandProperty canonicalname| + Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/Development Servers/Web Servers/*"| + Select dnshostname -ExpandProperty dnshostname + } + + Foreach ($server in $NCRA_Web_DEV) { + Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - Web - DEV" + } + +} + +#NCRA PRODUCTION SERVERS: +Function NCRA-Application-PROD { + $NCRA_Application_PROD = Foreach ($server in $newservers) { + Get-ADComputer -Identity $server -Properties * | + Select dnshostname,canonicalname -ExpandProperty canonicalname| + Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/Production Servers/Application Servers/*"| + Select dnshostname -ExpandProperty dnshostname + } + + Foreach ($server in $NCRA_Application_PROD) { + Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - Application - PROD" + } + +} + +Function NCRA-BizTalk-PROD { + $NCRA_BizTalk_PROD = Foreach ($server in $newservers) { + Get-ADComputer -Identity $server -Properties * | + Select dnshostname,canonicalname -ExpandProperty canonicalname| + Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/Production Servers/BizTalk Servers/*"| + Select dnshostname -ExpandProperty dnshostname + } + + Foreach ($server in $NCRA_BizTalk_PROD) { + Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - BizTalk - PROD" + } + +} + +Function NCRA-Edifecs-PROD { + $NCRA_Edifecs_PROD = Foreach ($server in $newservers) { + Get-ADComputer -Identity $server -Properties * | + Select dnshostname,canonicalname -ExpandProperty canonicalname| + Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/Production Servers/Edifecs Servers/*"| + Select dnshostname -ExpandProperty dnshostname + } + + Foreach ($server in $NCRA_Edifecs_PROD) { + Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - Edifecs - PROD" + } + +} + +Function NCRA-Exchange-PROD { + $NCRA_Exchange_PROD = Foreach ($server in $newservers) { + Get-ADComputer -Identity $server -Properties * | + Select dnshostname,canonicalname -ExpandProperty canonicalname| + Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/Production Servers/Exchange Servers/*"| + Select dnshostname -ExpandProperty dnshostname + } + + Foreach ($server in $NCRA_Exchange_PROD) { + Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - Exchange - PROD" + } + +} + +Function NCRA-Mail-Terminal-Servers-PROD { + $NCRA_Mail_Terminal_Servers_PROD = Foreach ($server in $newservers) { + Get-ADComputer -Identity $server -Properties * | + Select dnshostname,canonicalname -ExpandProperty canonicalname| + Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/Production Servers/Mail Terminal Servers/*"| + Select dnshostname -ExpandProperty dnshostname + } + + Foreach ($server in $NCRA_Mail_Terminal_Servers_PROD) { + Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - Mail Terminal Servers - PROD" + } + +} + +Function NCRA-Remote-Desktop-Prod { + $NCRA_Remote_Desktop_Prod = Foreach ($server in $newservers) { + Get-ADComputer -Identity $server -Properties * | + Select dnshostname,canonicalname -ExpandProperty canonicalname| + Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/Production Servers/Remote Desktop Servers/*"| + Select dnshostname -ExpandProperty dnshostname + } + + Foreach ($server in $NCRA_Remote_Desktop_Prod) { + Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - Remote Desktop - PROD" + } + +} + +Function NCRA-SQL-PROD { + $NCRA_SQL_PROD = Foreach ($server in $newservers) { + Get-ADComputer -Identity $server -Properties * | + Select dnshostname,canonicalname -ExpandProperty canonicalname| + Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/Production Servers/SQL Servers/*"| + Select dnshostname -ExpandProperty dnshostname + } + + Foreach ($server in $NCRA_SQL_PROD) { + Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - SQL - PROD" + } + +} + +Function NCRA-Terminal-Servers-PROD { + $NCRA_Terminal_Servers_PROD = Foreach ($server in $newservers) { + Get-ADComputer -Identity $server -Properties * | + Select dnshostname,canonicalname -ExpandProperty canonicalname| + Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/Production Servers/Terminal Servers/*"| + Select dnshostname -ExpandProperty dnshostname + } + + Foreach ($server in $NCRA_Terminal_Servers_PROD) { + Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - Terminal Servers - PROD" + } + +} + +Function NCRA-Tidal-PROD { + $NCRA_Tidal_PROD = Foreach ($server in $newservers) { + Get-ADComputer -Identity $server -Properties * | + Select dnshostname,canonicalname -ExpandProperty canonicalname| + Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/Production Servers/Tidal Servers/*"| + Select dnshostname -ExpandProperty dnshostname + } + + Foreach ($server in $NCRA_Tidal_PROD) { + Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - Tidal - PROD" + } + +} + +Function NCRA-Verint-PROD { + $NCRA_Verint_PROD = Foreach ($server in $newservers) { + Get-ADComputer -Identity $server -Properties * | + Select dnshostname,canonicalname -ExpandProperty canonicalname| + Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/Production Servers/Verint Servers/*"| + Select dnshostname -ExpandProperty dnshostname + } + + Foreach ($server in $NCRA_Verint_PROD) { + Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - Verint - PROD" + } + +} + +Function NCRA-Vistar-Terminal-Servers-PROD { + $NCRA_Vistar_Terminal_Servers_PROD = Foreach ($server in $newservers) { + Get-ADComputer -Identity $server -Properties * | + Select dnshostname,canonicalname -ExpandProperty canonicalname| + Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/Production Servers/Vistar Terminal Servers/*"| + Select dnshostname -ExpandProperty dnshostname + } + + Foreach ($server in $NCRA_Vistar_Terminal_Servers_PROD) { + Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - Vistar Terminal Servers - PROD" + } + +} + +Function NCRA-Voice-PROD { + $NCRA_Voice_PROD = Foreach ($server in $newservers) { + Get-ADComputer -Identity $server -Properties * | + Select dnshostname,canonicalname -ExpandProperty canonicalname| + Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/Production Servers/Voice Servers/*"| + Select dnshostname -ExpandProperty dnshostname + } + + Foreach ($server in $NCRA_Voice_PROD) { + Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - Voice - PROD" + } + +} + +Function NCRA-Web-PROD { + $NCRA_Web_PROD = Foreach ($server in $newservers) { + Get-ADComputer -Identity $server -Properties * | + Select dnshostname,canonicalname -ExpandProperty canonicalname| + Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/Production Servers/Web Servers/*"| + Select dnshostname -ExpandProperty dnshostname + } + + Foreach ($server in $NCRA_Web_PROD) { + Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - Web - PROD" + } + +} + +#NCRA QUALITY ASSURANCE SERVERS: +Function NCRA-Application-QA { + $NCRA_Application_QA = Foreach ($server in $newservers) { + Get-ADComputer -Identity $server -Properties * | + Select dnshostname,canonicalname -ExpandProperty canonicalname| + Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/QA Servers/Application Servers/*"| + Select dnshostname -ExpandProperty dnshostname + } + + Foreach ($server in $NCRA_Application_QA) { + Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - Application - QA" + } + +} + +Function NCRA-BizTalk-QA { + $NCRA_BizTalk_QA = Foreach ($server in $newservers) { + Get-ADComputer -Identity $server -Properties * | + Select dnshostname,canonicalname -ExpandProperty canonicalname| + Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/QA Servers/BizTalk Servers/*"| + Select dnshostname -ExpandProperty dnshostname + } + + Foreach ($server in $NCRA_BizTalk_QA) { + Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - BizTalk - QA" + } + +} + +Function NCRA-Edifecs-QA { + $NCRA_Edifecs_QA = Foreach ($server in $newservers) { + Get-ADComputer -Identity $server -Properties * | + Select dnshostname,canonicalname -ExpandProperty canonicalname| + Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/QA Servers/Edifecs Servers/*"| + Select dnshostname -ExpandProperty dnshostname + } + + Foreach ($server in $NCRA_Edifecs_QA) { + Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - Edifecs - QA" + } + +} + +Function NCRA-Remote-Desktop-QA { + $NCRA_Remote_Desktop_QA = Foreach ($server in $newservers) { + Get-ADComputer -Identity $server -Properties * | + Select dnshostname,canonicalname -ExpandProperty canonicalname| + Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/QA Servers/Remote Desktop Servers/*"| + Select dnshostname -ExpandProperty dnshostname + } + + Foreach ($server in $NCRA_Remote_Desktop_QA) { + Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - Remote Desktop - QA" + } + +} + +Function NCRA-SQL-QA { + $NCRA_SQL_QA = Foreach ($server in $newservers) { + Get-ADComputer -Identity $server -Properties * | + Select dnshostname,canonicalname -ExpandProperty canonicalname| + Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/QA Servers/Remote Desktop Servers/*"| + Select dnshostname -ExpandProperty dnshostname + } + + Foreach ($server in $NCRA_SQL_QA) { + Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - SQL - QA" + } + +} + +Function NCRA-Terminal-Servers-QA { + $NCRA_Terminal_Servers_QA = Foreach ($server in $newservers) { + Get-ADComputer -Identity $server -Properties * | + Select dnshostname,canonicalname -ExpandProperty canonicalname| + Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/QA Servers/Remote Desktop Servers/*"| + Select dnshostname -ExpandProperty dnshostname + } + + Foreach ($server in $NCRA_Terminal_Servers_QA) { + Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - Terminal Servers - QA" + } + +} + +Function NCRA-Tidal-QA { + $NCRA_Tidal_QA = Foreach ($server in $newservers) { + Get-ADComputer -Identity $server -Properties * | + Select dnshostname,canonicalname -ExpandProperty canonicalname| + Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/QA Servers/Tidal Servers/*"| + Select dnshostname -ExpandProperty dnshostname + } + + Foreach ($server in $NCRA_Tidal_QA) { + Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - Tidal - QA" + } + +} + +Function NCRA-Web-QA { + $NCRA_Web_QA = Foreach ($server in $newservers) { + Get-ADComputer -Identity $server -Properties * | + Select dnshostname,canonicalname -ExpandProperty canonicalname| + Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/QA Servers/Web Servers/*"| + Select dnshostname -ExpandProperty dnshostname + } + + Foreach ($server in $NCRA_Web_QA) { + Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - WEb - QA" + } + +} + +#RUN: +# This function executes the script if there are new/unsorted servers in the Unassigned Computers group on the WSUS server +Function Run { + +If ($newservers.Count -gt 0) + { + CTHA-Verint-PROD + KSOP-Verint-PROD + AZPH-Verint-PROD + FLT2-Application-PROD + FLT2-Verint-PROD + FLT2-Voice-PROD + NCRA-Application-DEV + NCRA-BizTalk-DEV + NCRA-Edifecs-DEV + NCRA-Remote-Desktop-DEV + NCRA-SQL-DEV + NCRA-Terminal-Servers-DEV + NCRA-Voice-DEV + NCRA-Web-DEV + NCRA-Application-PROD + NCRA-BizTalk-PROD + NCRA-Edifecs-PROD + NCRA-Exchange-PROD + NCRA-Mail-Terminal-Servers-PROD + NCRA-Remote-Desktop-Prod + NCRA-SQL-PROD + NCRA-Terminal-Servers-PROD + NCRA-Tidal-PROD + NCRA-Verint-PROD + NCRA-Vistar-Terminal-Servers-PROD + NCRA-Voice-PROD + NCRA-Web-PROD + NCRA-Application-QA + NCRA-BizTalk-QA + NCRA-Edifecs-QA + NCRA-Remote-Desktop-QA + NCRA-SQL-QA + NCRA-Terminal-Servers-QA + NCRA-Tidal-QA + NCRA-Web-QA + + + } + Else {Send-MailMessage -SmtpServer smtp.ccx.carecentrix.com -From WSUS-Sorting-Hat@carecentrix.com -To kevin.trent@carecentrix.com -Subject "No new unassigned computers" + -Body "Sorting Hat did not dectect any new servers in the WSUS unassigned computers group. No action was taken."} +} + +Run + +#REPORTING: + #Still working on this section. Sudo-code below. + +#Servers Not Registered with WSUS: + #$wsus = get-wsusserver -name psus002 -portnumber 8530|get-wsuscomputer|select -ExpandProperty Fulldomainname + #$windows = Get-ADComputer -Properties * -Filter {(OperatingSystem -like "*Windows Server*")}|Select DNSHostName -ExpandProperty DNSHostName + #$nonreg = Compare-Object $wsus $windows|ForEach-Object {$_.InputObject} + +#Servers still in the Unassigned Group + #$unassed = Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -ComputerTargetGroups "Unassigned Computers"|select Fulldomainname -ExpandProperty Fulldomainname + diff --git a/dump/WSUS_Scripts/Old-Scripts/Start-Backups.ps1 b/dump/WSUS_Scripts/Old-Scripts/Start-Backups.ps1 new file mode 100644 index 0000000..f28c1fa --- /dev/null +++ b/dump/WSUS_Scripts/Old-Scripts/Start-Backups.ps1 @@ -0,0 +1,7 @@ +#Enable VEEAM Job Scheduler at the end of maintenance +Add-PSSnapin -Name VeeamPSSnapIn +Connect-VBRServer -Server PVEB001 +Get-VBRJob | where {$_.JobTargetType -eq "Backup" -and $_.IsScheduleEnabled -eq $true} | Enable-VBRJobSchedule +Disconnect-VBRServer +Send-MailMessage -SmtpServer smtp.ccx.carecentrix.com -To windows-admins@carecentrix.com -From backups@carecentrix.com -Subject "Veeam Backups Started" -Body "The Veeam Backup Jobs have been rescheduled after the infrastructure weekend.Please verify they are running as expected." +Exit \ No newline at end of file diff --git a/dump/WSUS_Scripts/Old-Scripts/Stop-Backups.ps1 b/dump/WSUS_Scripts/Old-Scripts/Stop-Backups.ps1 new file mode 100644 index 0000000..1a9220f --- /dev/null +++ b/dump/WSUS_Scripts/Old-Scripts/Stop-Backups.ps1 @@ -0,0 +1,6 @@ +#Disable VEEAM Job Schedule - Schedule to Run at 7pm on maintenance day +Add-PSSnapin -Name VeeamPSSnapIn +Connect-VBRServer -Server PVEB001 +Get-VBRJob | where {$_.JobTargetType -eq "Backup" -and $_.IsScheduleEnabled -eq $true} | Disable-VBRJobSchedule + +Disconnect-VBRServer diff --git a/dump/WSUS_Scripts/Old-Scripts/Test-WSUS-Patch-WSUSGroup.ps1 b/dump/WSUS_Scripts/Old-Scripts/Test-WSUS-Patch-WSUSGroup.ps1 new file mode 100644 index 0000000..2cd108b --- /dev/null +++ b/dump/WSUS_Scripts/Old-Scripts/Test-WSUS-Patch-WSUSGroup.ps1 @@ -0,0 +1,68 @@ +<# + +$ErrorActionPreference = "Ignore" +$WSUSGroup = Read-Host "Enter Target Group Name" +$servers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select Fulldomainname -ExpandProperty Fulldomainname +Foreach ($server in $servers) {Install-WindowsUpdate -ComputerName $server -AsJob} + +#Function Restart {# Force Reboot of Group (when auto failed) un-rem and run line below. +#Foreach ($server in $servers) {Restart-Computer -ComputerName $server -Force}} + +#Write-Host "Type Restart and press enter to reboot the $WSUSGroup WSUS Computer Group" +Read-Host -Prompt "Press Enter to exit" +#> + +################################################################################################################################# +#$ErrorActionPreference = "Ignore" +#$WSUSGroup = Read-Host "Enter Target Group Name" + +#$servers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select Fulldomainname -ExpandProperty Fulldomainname + +$servers = "W2012A","W2012B","slfkjsdl" +$WSUSGroup = "Test GGroupp" +$Location = Split-Path $MyInvocation.MyCommand.Path -Parent +$Dte = Get-Date -UFormat %m-%d-%Y +$Collect_Jobs = @() +$Patch_Job = @() + +$servers | Out-File $Location\Patching-Day\"$WSUSGroup"-Server-Patching-Today-$Dte.txt +$servers | Out-File E:\WSUS_Scripts\Patching-Day\"$WSUSGroup"-Server-Patching-Today-$Dte.txt + +Foreach ($server in $servers) { + + Invoke-Command $server -ErrorAction SilentlyContinue { + New-EventLog -LogName Application -Source "Powershell-WSUS-Patching-Started" -ErrorAction SilentlyContinue + New-EventLog -LogName Application -Source "Powershell-WSUS-Patching-Finished" -ErrorAction SilentlyContinue + New-EventLog -LogName System -Source "Powershell-Reboot-After-Patching" -ErrorAction SilentlyContinue + Write-EventLog -LogName Application -Source "Powershell-WSUS-Patching-Started" -EntryType Information -EventId 7890 -Message "Server Patching Started with Powershell" + }#endInvoke + + #Install-WindowsUpdate -ComputerName $server -AsJob + + $Patch_Job += Start-Job -ScriptBlock { Param($server) Install-WindowsUpdate -ComputerName $server } -Name "$server-Patching" -ArgumentList $server + + +}#endForeach +$Patch_Job | Export-Csv $Location\Patching-Day\Patching-Jobs-$Dte.csv -NoTypeInformation +$Patch_Job | Export-Csv E:\WSUS_Scripts\Patching-Day\Patching-Jobs-Backup-$Dte.csv -NoTypeInformation + +$Collect_Jobs = Get-Job | Export-Csv $Location\Patching-Day\Collect-Patching-Jobs-$Dte.csv -NoTypeInformation +$Collect_Jobs = Get-Job | Export-Csv E:\WSUS_Scripts\Patching-Day\Collect-Patching-Jobs-Backup-$Dte.csv -NoTypeInformation + +$Patch_Job | Select @{n="Server";e={$_.Name.Split('-')[0]}},@{n="MainJobID";e={$_.ID}},@{n="MainJobName";e={$_.Name}},@{n="ChildJobID";e={$_.Childjobs.ID}},@{n="ChildJobState";e={$_.Childjobs.State}},PSBeginTime,PSEndTime,Command | Export-Csv $Location\Patching-Day\Jobs-ChildJobs-$Dte.csv -NoTypeInformation +$Patch_Job | Select @{n="Server";e={$_.Name.Split('-')[0]}},@{n="MainJobID";e={$_.ID}},@{n="MainJobName";e={$_.Name}},@{n="ChildJobID";e={$_.Childjobs.ID}},@{n="ChildJobState";e={$_.Childjobs.State}},PSBeginTime,PSEndTime,Command | Export-Csv E:\WSUS_Scripts\Patching-Day\Jobs-ChildJobs-Backup-$Dte.csv -NoTypeInformation + +#Function Restart {# Force Reboot of Group (when auto failed) un-rem and run line below. +#Foreach ($server in $servers) {Restart-Computer -ComputerName $server -Force}} + +#Write-Host "Type Restart and press enter to reboot the $WSUSGroup WSUS Computer Group" + +$servers | % { Get-EventLog -LogName Application -ComputerName $_ -ErrorAction SilentlyContinue | ? { $_.EventID -eq '7890' -and $_.TimeWritten -like "*$Dte*" } } +#Collect event log + + + + + + + diff --git a/dump/WSUS_Scripts/Old-Scripts/WSUSComputerCheck.ps1 b/dump/WSUS_Scripts/Old-Scripts/WSUSComputerCheck.ps1 new file mode 100644 index 0000000..906d14b --- /dev/null +++ b/dump/WSUS_Scripts/Old-Scripts/WSUSComputerCheck.ps1 @@ -0,0 +1,35 @@ +Import-Module ActiveDirectory +Import-Module WindowsUpdate + + +$ServerList = Import-Csv 'C:\Users\abamaso-ccxadmin\Desktop\CompletedProd_WindowsServers - Classifications.csv' + +$AllServers = @() + +foreach ($Server in $ServerList) { +$patchingtier = $Server.Classification +$ServerObject = New-Object psobject + +$ComputerValidation = $null + +$WSUSComputerObject = Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server.'Server Name' + +$ComputerValidation = $wsuscomputerobject.FullDomainName + +$ServerObject | Add-Member -MemberType NoteProperty -Name "Server Name" -Value $server.'Server Name' +$ServerObject | Add-Member -MemberType NoteProperty -Name "Operating System" -Value $server.'Operating System' +$ServerObject | Add-Member -MemberType NoteProperty -Name "Application" -Value $server.Application + +if ($ComputerValidation -eq $null) { +$ServerObject | Add-Member -MemberType NoteProperty -Name "WSUS Status" -Value "Server is not in WSUS" +} +else { +$ServerObject | Add-Member -MemberType NoteProperty -Name "WSUS Status" -Value "Server is in WSUS" +} + +$AllServers +=$ServerObject + +Write-host $Server.'Server Name'" checked in WSUS" +} + +$AllServers | export-csv C:\Users\abamaso-ccxadmin\Desktop\WSUSComputers.csv \ No newline at end of file diff --git a/dump/WSUS_Scripts/Old-Scripts/new-Patch-WSUSGroup-2.ps1 b/dump/WSUS_Scripts/Old-Scripts/new-Patch-WSUSGroup-2.ps1 new file mode 100644 index 0000000..968195e --- /dev/null +++ b/dump/WSUS_Scripts/Old-Scripts/new-Patch-WSUSGroup-2.ps1 @@ -0,0 +1,110 @@ +<# + +$ErrorActionPreference = "Ignore" +$WSUSGroup = Read-Host "Enter Target Group Name" +$servers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select Fulldomainname -ExpandProperty Fulldomainname +Foreach ($server in $servers) {Install-WindowsUpdate -ComputerName $server -AsJob} + +#Function Restart {# Force Reboot of Group (when auto failed) un-rem and run line below. +#Foreach ($server in $servers) {Restart-Computer -ComputerName $server -Force}} + +#Write-Host "Type Restart and press enter to reboot the $WSUSGroup WSUS Computer Group" +Read-Host -Prompt "Press Enter to exit" +#> + +################################################################################################################################# +#$ErrorActionPreference = "Ignore" + +#$servers = "W2012A","W2012B","slfkjsdl" +#$WSUSGroup = "Test GGroupppppp" +################################################################################################################################# +If(Test-Path E:\WSUS_Scripts\Lock_Script.txt) { + Write-Host "The Script is locked for protection. If you are not running it by mistake - Delete the file (E:\WSUS_Scripts\Lock_Script.txt) and run the Script again" -ForegroundColor Yellow + Break +} +Else { New-Item -Path E:\WSUS_Scripts -Name Lock_Script.txt -ItemType File } +################################################################################################################################# + +Get-Job | Remove-Job + +$Location = Split-Path $MyInvocation.MyCommand.Path -Parent +############################################################ +#$WSUSGroup = gc H:\Scripts\Patching\_Group-Config-File\Config-WSUS-Group.txt +$Current_Month = (Get-Date -UFormat %B) + +############################################################ +$Dte = Get-Date -UFormat %m-%d-%Y +$Collect_Jobs = @() +$Patch_Job = @() +$Failed_Jobs = @() +$Receive_Jobs = @() + +If(!(Test-Path E:\WSUS_Scripts\Patching-Day\$WSUSGroup-$Current_Month-Patching)) { New-Item -Path "E:\WSUS_Scripts\Patching-Day" -ItemType Directory -Name $WSUSGroup-$Current_Month-Patching } + +$servers = "" +$WSUSGroup = Read-Host "Enter Target Group Name" + +#$servers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select -ExpandProperty Fulldomainname +$Group_Folder = "$WSUSGroup-$Current_Month-Patching" + +$Servers_Reboot_Only = Import-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\CCXQ1-November-Prep-Files\Manual-$WSUSGroup-OperatingSystems-$Current_Month.csv +$servers = Import-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\CCXQ1-November-Prep-Files\$WSUSGroup-Target-Group-Computers-$Current_Month.csv | select -ExpandProperty FullDomainName + +$servers = $servers | ? { $_ -notin $Servers_Reboot_Only.FullDomainName } + +#$Failed_Ping_Test = gc $Location\Files\$WSUSGroup-Ping-Failed-$Current_Month.txt +#$servers = $servers | ? { $_ -notin $Failed_Ping_Test } + +$servers | Out-File $Location\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Today-$Dte.txt +$servers | Out-File E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Today-Backup-$Dte.txt + +Foreach ($server in $servers) { + + New-EventLog -LogName Application -Source "Patching-Started" -ErrorAction SilentlyContinue -ComputerName $server -verbose + New-EventLog -LogName Application -Source "Patching-Finished" -ErrorAction SilentlyContinue -ComputerName $server -verbose + New-EventLog -LogName System -Source "Reboot-After-Patching" -ErrorAction SilentlyContinue -ComputerName $server -verbose + Write-EventLog -LogName Application -Source "Patching-Started" -EntryType Information -EventId 7890 -Message "Server Patching Started with Powershell - Remote" -ComputerName $server -ErrorAction SilentlyContinue -verbose + + $Patch_Job += Start-Job -ScriptBlock { Param($server) WindowsUpdate\Install-WindowsUpdate -ComputerName $server } -Name "$WSUSGroup-$server-Patching" -ArgumentList $server + + Invoke-Command $server -ErrorAction SilentlyContinue { + New-EventLog -LogName Application -Source "Patching-Started" -ErrorAction SilentlyContinue -verbose + New-EventLog -LogName Application -Source "Patching-Finished" -ErrorAction SilentlyContinue -verbose + New-EventLog -LogName System -Source "Reboot-After-Patching" -ErrorAction SilentlyContinue -verbose + Write-EventLog -LogName Application -Source "Patching-Started" -EntryType Information -EventId 7890 -Message "Server Patching Started with Powershell - Invoke" -verbose + }#endInvoke + +}#endForeach + +#Get-Job + +$Patch_Job | Export-Csv $Location\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Jobs-$Dte.csv -NoTypeInformation +$Patch_Job | Export-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Jobs-Backup-$Dte.csv -NoTypeInformation + +$Collect_Jobs = Get-Job | Export-Csv $Location\Patching-Day\$Group_Folder\$WSUSGroup-Collect-Patching-Jobs-$Dte.csv -NoTypeInformation +$Collect_Jobs = Get-Job | Export-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Collect-Patching-Jobs-Backup-$Dte.csv -NoTypeInformation + +$Patch_Job | Select @{n="Server";e={$_.Name.Split('-')[0]}},@{n="MainJobID";e={$_.ID}},@{n="MainJobName";e={$_.Name}},@{n="ChildJobID";e={$_.Childjobs.ID}},@{n="ChildJobState";e={$_.Childjobs.State}},PSBeginTime,PSEndTime,Command | Export-Csv $Location\Patching-Day\$Group_Folder\$WSUSGroup-Jobs-ChildJobs-$Dte.csv -NoTypeInformation +$Patch_Job | Select @{n="Server";e={$_.Name.Split('-')[0]}},@{n="MainJobID";e={$_.ID}},@{n="MainJobName";e={$_.Name}},@{n="ChildJobID";e={$_.Childjobs.ID}},@{n="ChildJobState";e={$_.Childjobs.State}},PSBeginTime,PSEndTime,Command | Export-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Jobs-ChildJobs-Backup-$Dte.csv -NoTypeInformation + + +<# + +$Failed_Jobs += $Patch_Job | ? { $_.State -eq "Failed" } + +$Failed_Jobs | ft -autosize + +$Failed_Jobs | Export-Csv "E:\WSUS_Scripts\Patching-Day\NCRA - Quality Assurance Servers-November-Patching\failed-jobs.csv" -NoTypeInformation + +#> + + +### Running Count +## ( $Patch_Job | ? { $_.State -eq "Running" } ).count + +## ( $Patch_Job | ? { $_.State -eq "Completed" } ).count + +## ( $Patch_Job | ? { $_.State -eq "Failed" } ).count + + + \ No newline at end of file diff --git a/dump/WSUS_Scripts/Old-Scripts/new-Patch-WSUSGroup-3.ps1 b/dump/WSUS_Scripts/Old-Scripts/new-Patch-WSUSGroup-3.ps1 new file mode 100644 index 0000000..968195e --- /dev/null +++ b/dump/WSUS_Scripts/Old-Scripts/new-Patch-WSUSGroup-3.ps1 @@ -0,0 +1,110 @@ +<# + +$ErrorActionPreference = "Ignore" +$WSUSGroup = Read-Host "Enter Target Group Name" +$servers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select Fulldomainname -ExpandProperty Fulldomainname +Foreach ($server in $servers) {Install-WindowsUpdate -ComputerName $server -AsJob} + +#Function Restart {# Force Reboot of Group (when auto failed) un-rem and run line below. +#Foreach ($server in $servers) {Restart-Computer -ComputerName $server -Force}} + +#Write-Host "Type Restart and press enter to reboot the $WSUSGroup WSUS Computer Group" +Read-Host -Prompt "Press Enter to exit" +#> + +################################################################################################################################# +#$ErrorActionPreference = "Ignore" + +#$servers = "W2012A","W2012B","slfkjsdl" +#$WSUSGroup = "Test GGroupppppp" +################################################################################################################################# +If(Test-Path E:\WSUS_Scripts\Lock_Script.txt) { + Write-Host "The Script is locked for protection. If you are not running it by mistake - Delete the file (E:\WSUS_Scripts\Lock_Script.txt) and run the Script again" -ForegroundColor Yellow + Break +} +Else { New-Item -Path E:\WSUS_Scripts -Name Lock_Script.txt -ItemType File } +################################################################################################################################# + +Get-Job | Remove-Job + +$Location = Split-Path $MyInvocation.MyCommand.Path -Parent +############################################################ +#$WSUSGroup = gc H:\Scripts\Patching\_Group-Config-File\Config-WSUS-Group.txt +$Current_Month = (Get-Date -UFormat %B) + +############################################################ +$Dte = Get-Date -UFormat %m-%d-%Y +$Collect_Jobs = @() +$Patch_Job = @() +$Failed_Jobs = @() +$Receive_Jobs = @() + +If(!(Test-Path E:\WSUS_Scripts\Patching-Day\$WSUSGroup-$Current_Month-Patching)) { New-Item -Path "E:\WSUS_Scripts\Patching-Day" -ItemType Directory -Name $WSUSGroup-$Current_Month-Patching } + +$servers = "" +$WSUSGroup = Read-Host "Enter Target Group Name" + +#$servers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select -ExpandProperty Fulldomainname +$Group_Folder = "$WSUSGroup-$Current_Month-Patching" + +$Servers_Reboot_Only = Import-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\CCXQ1-November-Prep-Files\Manual-$WSUSGroup-OperatingSystems-$Current_Month.csv +$servers = Import-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\CCXQ1-November-Prep-Files\$WSUSGroup-Target-Group-Computers-$Current_Month.csv | select -ExpandProperty FullDomainName + +$servers = $servers | ? { $_ -notin $Servers_Reboot_Only.FullDomainName } + +#$Failed_Ping_Test = gc $Location\Files\$WSUSGroup-Ping-Failed-$Current_Month.txt +#$servers = $servers | ? { $_ -notin $Failed_Ping_Test } + +$servers | Out-File $Location\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Today-$Dte.txt +$servers | Out-File E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Today-Backup-$Dte.txt + +Foreach ($server in $servers) { + + New-EventLog -LogName Application -Source "Patching-Started" -ErrorAction SilentlyContinue -ComputerName $server -verbose + New-EventLog -LogName Application -Source "Patching-Finished" -ErrorAction SilentlyContinue -ComputerName $server -verbose + New-EventLog -LogName System -Source "Reboot-After-Patching" -ErrorAction SilentlyContinue -ComputerName $server -verbose + Write-EventLog -LogName Application -Source "Patching-Started" -EntryType Information -EventId 7890 -Message "Server Patching Started with Powershell - Remote" -ComputerName $server -ErrorAction SilentlyContinue -verbose + + $Patch_Job += Start-Job -ScriptBlock { Param($server) WindowsUpdate\Install-WindowsUpdate -ComputerName $server } -Name "$WSUSGroup-$server-Patching" -ArgumentList $server + + Invoke-Command $server -ErrorAction SilentlyContinue { + New-EventLog -LogName Application -Source "Patching-Started" -ErrorAction SilentlyContinue -verbose + New-EventLog -LogName Application -Source "Patching-Finished" -ErrorAction SilentlyContinue -verbose + New-EventLog -LogName System -Source "Reboot-After-Patching" -ErrorAction SilentlyContinue -verbose + Write-EventLog -LogName Application -Source "Patching-Started" -EntryType Information -EventId 7890 -Message "Server Patching Started with Powershell - Invoke" -verbose + }#endInvoke + +}#endForeach + +#Get-Job + +$Patch_Job | Export-Csv $Location\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Jobs-$Dte.csv -NoTypeInformation +$Patch_Job | Export-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Jobs-Backup-$Dte.csv -NoTypeInformation + +$Collect_Jobs = Get-Job | Export-Csv $Location\Patching-Day\$Group_Folder\$WSUSGroup-Collect-Patching-Jobs-$Dte.csv -NoTypeInformation +$Collect_Jobs = Get-Job | Export-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Collect-Patching-Jobs-Backup-$Dte.csv -NoTypeInformation + +$Patch_Job | Select @{n="Server";e={$_.Name.Split('-')[0]}},@{n="MainJobID";e={$_.ID}},@{n="MainJobName";e={$_.Name}},@{n="ChildJobID";e={$_.Childjobs.ID}},@{n="ChildJobState";e={$_.Childjobs.State}},PSBeginTime,PSEndTime,Command | Export-Csv $Location\Patching-Day\$Group_Folder\$WSUSGroup-Jobs-ChildJobs-$Dte.csv -NoTypeInformation +$Patch_Job | Select @{n="Server";e={$_.Name.Split('-')[0]}},@{n="MainJobID";e={$_.ID}},@{n="MainJobName";e={$_.Name}},@{n="ChildJobID";e={$_.Childjobs.ID}},@{n="ChildJobState";e={$_.Childjobs.State}},PSBeginTime,PSEndTime,Command | Export-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Jobs-ChildJobs-Backup-$Dte.csv -NoTypeInformation + + +<# + +$Failed_Jobs += $Patch_Job | ? { $_.State -eq "Failed" } + +$Failed_Jobs | ft -autosize + +$Failed_Jobs | Export-Csv "E:\WSUS_Scripts\Patching-Day\NCRA - Quality Assurance Servers-November-Patching\failed-jobs.csv" -NoTypeInformation + +#> + + +### Running Count +## ( $Patch_Job | ? { $_.State -eq "Running" } ).count + +## ( $Patch_Job | ? { $_.State -eq "Completed" } ).count + +## ( $Patch_Job | ? { $_.State -eq "Failed" } ).count + + + \ No newline at end of file diff --git a/dump/WSUS_Scripts/Old-Scripts/new-Patch-WSUSGroup.ps1 b/dump/WSUS_Scripts/Old-Scripts/new-Patch-WSUSGroup.ps1 new file mode 100644 index 0000000..0f8d339 --- /dev/null +++ b/dump/WSUS_Scripts/Old-Scripts/new-Patch-WSUSGroup.ps1 @@ -0,0 +1,70 @@ +<# + +$ErrorActionPreference = "Ignore" +$WSUSGroup = Read-Host "Enter Target Group Name" +$servers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select Fulldomainname -ExpandProperty Fulldomainname +Foreach ($server in $servers) {Install-WindowsUpdate -ComputerName $server -AsJob} + +#Function Restart {# Force Reboot of Group (when auto failed) un-rem and run line below. +#Foreach ($server in $servers) {Restart-Computer -ComputerName $server -Force}} + +#Write-Host "Type Restart and press enter to reboot the $WSUSGroup WSUS Computer Group" +Read-Host -Prompt "Press Enter to exit" +#> + +################################################################################################################################# +#$ErrorActionPreference = "Ignore" +$WSUSGroup = Read-Host "Enter Target Group Name" + +$servers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select Fulldomainname -ExpandProperty Fulldomainname + +#$servers = "W2012A","W2012B","slfkjsdl" +#$WSUSGroup = "Test GGroupppppp" + +$Location = Split-Path $MyInvocation.MyCommand.Path -Parent +$Dte = Get-Date -UFormat %m-%d-%Y +$Collect_Jobs = @() +$Patch_Job = @() + +$servers | Out-File $Location\Patching-Day\"$WSUSGroup"-Server-Patching-Today-$Dte.txt +$servers | Out-File E:\WSUS_Scripts\Patching-Day\"$WSUSGroup"-Server-Patching-Today-Backup-$Dte.txt + +Foreach ($server in $servers) { + + New-EventLog -LogName Application -Source "Patching-Started" -ErrorAction SilentlyContinue -ComputerName $server + New-EventLog -LogName Application -Source "Patching-Finished" -ErrorAction SilentlyContinue -ComputerName $server + New-EventLog -LogName System -Source "Reboot-After-Patching" -ErrorAction SilentlyContinue -ComputerName $server + Write-EventLog -LogName Application -Source "Patching-Started" -EntryType Information -EventId 7890 -Message "Server Patching Started with Powershell - Remote" -ComputerName $server -ErrorAction SilentlyContinue + + $Patch_Job += Start-Job -ScriptBlock { Param($server) Install-WindowsUpdate -ComputerName $server } -Name "$server-Patching" -ArgumentList $server + + Invoke-Command $server -ErrorAction SilentlyContinue { + New-EventLog -LogName Application -Source "Patching-Started" -ErrorAction SilentlyContinue + New-EventLog -LogName Application -Source "Patching-Finished" -ErrorAction SilentlyContinue + New-EventLog -LogName System -Source "Reboot-After-Patching" -ErrorAction SilentlyContinue + Write-EventLog -LogName Application -Source "Patching-Started" -EntryType Information -EventId 7890 -Message "Server Patching Started with Powershell - Invoke" + }#endInvoke + + Install-WindowsUpdate -ComputerName $server -AsJob + +}#endForeach + +Get-Job + +$Patch_Job | Export-Csv $Location\Patching-Day\Patching-Jobs-$Dte.csv -NoTypeInformation +$Patch_Job | Export-Csv E:\WSUS_Scripts\Patching-Day\Patching-Jobs-Backup-$Dte.csv -NoTypeInformation + +$Collect_Jobs = Get-Job | Export-Csv $Location\Patching-Day\Collect-Patching-Jobs-$Dte.csv -NoTypeInformation +$Collect_Jobs = Get-Job | Export-Csv E:\WSUS_Scripts\Patching-Day\Collect-Patching-Jobs-Backup-$Dte.csv -NoTypeInformation + +$Patch_Job | Select @{n="Server";e={$_.Name.Split('-')[0]}},@{n="MainJobID";e={$_.ID}},@{n="MainJobName";e={$_.Name}},@{n="ChildJobID";e={$_.Childjobs.ID}},@{n="ChildJobState";e={$_.Childjobs.State}},PSBeginTime,PSEndTime,Command | Export-Csv $Location\Patching-Day\Jobs-ChildJobs-$Dte.csv -NoTypeInformation +$Patch_Job | Select @{n="Server";e={$_.Name.Split('-')[0]}},@{n="MainJobID";e={$_.ID}},@{n="MainJobName";e={$_.Name}},@{n="ChildJobID";e={$_.Childjobs.ID}},@{n="ChildJobState";e={$_.Childjobs.State}},PSBeginTime,PSEndTime,Command | Export-Csv E:\WSUS_Scripts\Patching-Day\Jobs-ChildJobs-Backup-$Dte.csv -NoTypeInformation + + + + + + + + + \ No newline at end of file diff --git a/dump/WSUS_Scripts/Old-Scripts/new-Reboot-WSUSGroup-2.ps1 b/dump/WSUS_Scripts/Old-Scripts/new-Reboot-WSUSGroup-2.ps1 new file mode 100644 index 0000000..ffaf1aa --- /dev/null +++ b/dump/WSUS_Scripts/Old-Scripts/new-Reboot-WSUSGroup-2.ps1 @@ -0,0 +1,48 @@ +$Location = Split-Path $MyInvocation.MyCommand.Path -Parent +################################################################################################################################# +$Dte = Get-Date -UFormat %m-%d-%Y +$Current_Month = (Get-Date -UFormat %B) +$WSUSGroup = "NCRA - Development Servers" +$Group_Folder = "$WSUSGroup-$Current_Month-Patching" +$Group = "NCRA - Development Servers" +################################################################################################################################# +#$WSUSGroup = Read-Host "Enter Target Group Name" +#$servers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select Fulldomainname -ExpandProperty Fulldomainname +$servers = Import-Csv E:\WSUS_Scripts\Files\*$Group*.csv +#$servers = "w2012a","w2012b","testtest" + +$servers | Out-File $Location\Patching-Day\$Group_Folder\$WSUSGroup-Servers-Rebooting-$Dte.txt -ErrorAction SilentlyContinue +$servers | Out-File E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Servers-Rebooting-Backup-$Dte.txt -ErrorAction SilentlyContinue + +$Patch_Job | Export-Csv $Location\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Jobs-$Dte-Before-Reboot.csv -NoTypeInformation -ErrorAction SilentlyContinue +$Patch_Job | Export-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Jobs-$Dte-Before-Reboot-Backup.csv -NoTypeInformation -ErrorAction SilentlyContinue + +Get-Job | Export-Csv $Location\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Get-Jobs-$Dte-Before-Reboot.csv -NoTypeInformation -ErrorAction SilentlyContinue +Get-Job | Export-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Get-Jobs-$Dte-Before-Reboot-Backup.csv -NoTypeInformation -ErrorAction SilentlyContinue + +$Collect_Jobs = Get-Job | Export-Csv $Location\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Collect-Patching-Jobs-$Dte-Before-Reboot.csv -NoTypeInformation +$Collect_Jobs = Get-Job | Export-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Collect-Patching-Jobs-$Dte-Before-Reboot-Backup.csv -NoTypeInformation + +Foreach ($server in $servers) { + + Write-EventLog -LogName Application -Source "Patching-Finished" -EntryType Information -EventId 7891 -Message "Powershell-WSUS-Patching-Finished - Remote" -ComputerName $server.Computer -ErrorAction SilentlyContinue + Write-EventLog -LogName System -Source "Reboot-After-Patching" -EntryType Information -EventId 7892 -Message "Server Rebooting After Patching - Remote" -ComputerName $server.Computer -ErrorAction SilentlyContinue + + Invoke-Command $server.Computer -ErrorAction SilentlyContinue { + #New-EventLog -LogName Application -Source "Powershell-WSUS-Patching-Finished" -ErrorAction SilentlyContinue + #New-EventLog -LogName System -Source "Powershell-Reboot-After-Patching" -ErrorAction SilentlyContinue + Write-EventLog -LogName Application -Source "Patching-Finished" -EntryType Information -EventId 7891 -Message "Powershell-WSUS-Patching-Finished - Invoke" -ErrorAction SilentlyContinue + Write-EventLog -LogName System -Source "Reboot-After-Patching" -EntryType Information -EventId 7892 -Message "Server Rebooting After Patching - Invoke" -ErrorAction SilentlyContinue + }#endInvoke + Restart-Computer -ComputerName $server.Computer -Force -Verbose + +}#endForeach + +<# + +$servers.computer | % { $T = Test-Connection -ComputerName $_ -Count 1 -ErrorAction SilentlyContinue + If($T) { Write-Host "Server $_ -- Responding" -ForegroundColor Green } Else { Write-Host "Server $_ -- Not Responding" -ForegroundColor Red } + } + + +#> \ No newline at end of file diff --git a/dump/WSUS_Scripts/Old-Scripts/new-Reboot-WSUSGroup.ps1 b/dump/WSUS_Scripts/Old-Scripts/new-Reboot-WSUSGroup.ps1 new file mode 100644 index 0000000..3efdd2f --- /dev/null +++ b/dump/WSUS_Scripts/Old-Scripts/new-Reboot-WSUSGroup.ps1 @@ -0,0 +1,32 @@ +$Location = Split-Path $MyInvocation.MyCommand.Path -Parent +$Dte = Get-Date -UFormat %m-%d-%Y + +$WSUSGroup = Read-Host "Enter Target Group Name" +$servers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select Fulldomainname -ExpandProperty Fulldomainname + +$servers | Out-File $Location\Patching-Day\"$WSUSGroup"-Servers-Rebooting-$Dte.txt -ErrorAction SilentlyContinue +$servers | Out-File E:\WSUS_Scripts\Patching-Day\"$WSUSGroup"-Servers-Rebooting-Backup-$Dte.txt -ErrorAction SilentlyContinue + +$Patch_Job | Export-Csv $Location\Patching-Day\Patching-Jobs-$Dte-Before-Reboot.csv -NoTypeInformation -ErrorAction SilentlyContinue +$Patch_Job | Export-Csv E:\WSUS_Scripts\Patching-Day\Patching-Jobs-$Dte-Before-Reboot-Backup.csv -NoTypeInformation -ErrorAction SilentlyContinue + +Get-Job | Export-Csv $Location\Patching-Day\Patching-Get-Jobs-$Dte-Before-Reboot.csv -NoTypeInformation -ErrorAction SilentlyContinue +Get-Job | Export-Csv E:\WSUS_Scripts\Patching-Day\Patching-Get-Jobs-$Dte-Before-Reboot-Backup.csv -NoTypeInformation -ErrorAction SilentlyContinue + +$Collect_Jobs = Get-Job | Export-Csv $Location\Patching-Day\Patching-Collect-Patching-Jobs-$Dte-Before-Reboot.csv -NoTypeInformation +$Collect_Jobs = Get-Job | Export-Csv E:\WSUS_Scripts\Patching-Day\Patching-Collect-Patching-Jobs-$Dte-Before-Reboot-Backup.csv -NoTypeInformation + +Foreach ($server in $servers) { + + Write-EventLog -LogName Application -Source "Patching-Finished" -EntryType Information -EventId 7891 -Message "Powershell-WSUS-Patching-Finished - Remote" -ComputerName $server -ErrorAction SilentlyContinue + Write-EventLog -LogName System -Source "Reboot-After-Patching" -EntryType Information -EventId 7892 -Message "Server Rebooting After Patching - Remote" -ComputerName $server -ErrorAction SilentlyContinue + + Invoke-Command $server -ErrorAction SilentlyContinue { + #New-EventLog -LogName Application -Source "Powershell-WSUS-Patching-Finished" -ErrorAction SilentlyContinue + #New-EventLog -LogName System -Source "Powershell-Reboot-After-Patching" -ErrorAction SilentlyContinue + Write-EventLog -LogName Application -Source "Patching-Finished" -EntryType Information -EventId 7891 -Message "Powershell-WSUS-Patching-Finished - Invoke" -ErrorAction SilentlyContinue + Write-EventLog -LogName System -Source "Reboot-After-Patching" -EntryType Information -EventId 7892 -Message "Server Rebooting After Patching - Invoke" -ErrorAction SilentlyContinue + }#endInvoke + Restart-Computer -ComputerName $server -Force -Verbose + +}#endForeach \ No newline at end of file diff --git a/dump/WSUS_Scripts/Old-Scripts/old-Patch-WSUSGroup.ps1 b/dump/WSUS_Scripts/Old-Scripts/old-Patch-WSUSGroup.ps1 new file mode 100644 index 0000000..ba10956 --- /dev/null +++ b/dump/WSUS_Scripts/Old-Scripts/old-Patch-WSUSGroup.ps1 @@ -0,0 +1,10 @@ +$ErrorActionPreference = "Ignore" +$WSUSGroup = Read-Host "Enter Target Group Name" +$servers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select Fulldomainname -ExpandProperty Fulldomainname +Foreach ($server in $servers) {Install-WindowsUpdate -ComputerName $server -AsJob} + +#Function Restart {# Force Reboot of Group (when auto failed) un-rem and run line below. +#Foreach ($server in $servers) {Restart-Computer -ComputerName $server -Force}} + +#Write-Host "Type Restart and press enter to reboot the $WSUSGroup WSUS Computer Group" +Read-Host -Prompt "Press Enter to exit" \ No newline at end of file diff --git a/dump/WSUS_Scripts/Old-Scripts/old-Reboot-WSUSGroup.ps1 b/dump/WSUS_Scripts/Old-Scripts/old-Reboot-WSUSGroup.ps1 new file mode 100644 index 0000000..a4c54d5 --- /dev/null +++ b/dump/WSUS_Scripts/Old-Scripts/old-Reboot-WSUSGroup.ps1 @@ -0,0 +1,3 @@ +$WSUSGroup = Read-Host "Enter Target Group Name" +$servers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select Fulldomainname -ExpandProperty Fulldomainname +Foreach ($server in $servers) {Restart-Computer -ComputerName $server -Force} \ No newline at end of file diff --git a/dump/WSUS_Scripts/PSUS_ConnectivityTests.ps1 b/dump/WSUS_Scripts/PSUS_ConnectivityTests.ps1 new file mode 100644 index 0000000..765955c --- /dev/null +++ b/dump/WSUS_Scripts/PSUS_ConnectivityTests.ps1 @@ -0,0 +1,141 @@ +$ServerList1 = Get-ADComputer -Filter {(Enabled -eq $true)} -SearchBase "OU=Servers,OU=NCRA,DC=ccx,DC=carecentrix,DC=com" | Select-Object DNSHostName +$ServerList2 = Get-ADComputer -Filter {(Enabled -eq $true)} -SearchBase "OU=Servers,OU=FLT2,DC=ccx,DC=carecentrix,DC=com" | Select-Object DNSHostName +$ServerList3 = Get-ADComputer -Filter {(Enabled -eq $true)} -SearchBase "OU=Servers,OU=AZPH,DC=ccx,DC=carecentrix,DC=com" | Select-Object DNSHostName +$ServerList4 = Get-ADComputer -Filter {(Enabled -eq $true)} -SearchBase "OU=Servers,OU=CLVA1,DC=ccx,DC=carecentrix,DC=com" | Select-Object DNSHostName +$ServerList5 = Get-ADComputer -Filter {(Enabled -eq $true)} -SearchBase "OU=Servers,OU=CTHA,DC=ccx,DC=carecentrix,DC=com" | Select-Object DNSHostName +$ServerList6 = Get-ADComputer -Filter {(Enabled -eq $true)} -SearchBase "OU=Servers,OU=KSOP,DC=ccx,DC=carecentrix,DC=com" | Select-Object DNSHostName +$ServerList = $ServerList1+$ServerList2+$ServerList3+$ServerList4+$ServerList5+$ServerList6 + +$ServerReport = @() + +$port1 = "8530" +$port2 = "8531" +$wsusserver = "psus002.ccx.carecentrix.com" + + + +foreach ($Server in $ServerList) { +$ServerName = $Server.DNSHostName + +$pssession = New-PSSession -ComputerName $ServerName -ErrorAction SilentlyContinue +$CurrentServer = New-Object System.Object +$CurrentServer | Add-Member -MemberType NoteProperty -Name "Name" -Value $ServerName +#Enter-PSSession $pssession + +if ($null -ne $pssession){ + write-host "Connected to $ServerName" + $CurrentServer | Add-Member -MemberType NoteProperty -Name "Status" -Value "Accessible" + $CurrentServer.Name = $ServerName + + + #Check HTTP Port + #Clear Port Variables + $port8530= @() + $port8531= @() + $port8530 = Invoke-Command -Session $pssession -ScriptBlock {invoke-webrequest http://psus002.ccx.carecentrix.com:8530/CLientWebService/Client.asmx -UseBasicParsing} -ErrorAction SilentlyContinue + if ($port8530.StatusCode -eq "200"){ + Write-host "Port 8530 Accessible" + $CurrentServer | Add-Member -MemberType NoteProperty -Name "8530" -Value "Open" + } + + elseif ($null -eq $port8530) { + $TestNetConnection = New-Object Net.Sockets.TcpClient + $testnetconnection.connect($wsusserver,$port1) + + if ($testnetconnection.Connected){ + $TestNetConnection.Close() + $CurrentServer | Add-Member -MemberType NoteProperty -Name "8530" -Value "Open" + } + else { + $CurrentServer | Add-Member -MemberType NoteProperty -Name "8530" -Value "Unable to Verify" + Write-host "Invoke Webrequest not recognized" + } + } + + else { + $CurrentServer | Add-Member -MemberType NoteProperty -Name "8530" -Value "Closed" + Write-host "Port 8531 Inaccessible" + + } + # Check HTTPS Port + $port8531 = Invoke-Command -Session $pssession -ScriptBlock {invoke-webrequest https://psus002.ccx.carecentrix.com:8531/CLientWebService/Client.asmx -UseBasicParsing} -ErrorAction SilentlyContinue + + + if ($port8531.StatusCode -eq "200"){ + $CurrentServer | Add-Member -MemberType NoteProperty -Name "8531" -Value "Open" + Write-host "Port 8531 Accessible" + } + + elseif ($null -eq $port8531) { + $TestNetConnection = New-Object Net.Sockets.TcpClient + $testnetconnection.connect($wsusserver,$port2) + + if ($testnetconnection.Connected){ + $TestNetConnection.Close() + $CurrentServer | Add-Member -MemberType NoteProperty -Name "8531" -Value "Open" + } + else{ + $CurrentServer | Add-Member -MemberType NoteProperty -Name "8531" -Value "Unable to Verify" + Write-host "Invoke Webrequest not recognized" + } + } + + else { + $CurrentServer | Add-Member -MemberType NoteProperty -Name "8531" -Value "Blocked" + Write-host "Port 8531 Inaccessible" + } + + #Check C: Drive Space + $DriveCheck =Invoke-Command -Session $pssession -ScriptBlock {get-WmiObject win32_logicaldisk -Filter "DeviceID='C:'"} + $HDFreespace = [Math]::Round($DriveCheck.Freespace / 1GB) + $HDSize =[Math]::Round($DriveCheck.Size / 1GB) + $CurrentServer | Add-Member -MemberType NoteProperty -Name "C: Size" -Value $HDSize + $CurrentServer | Add-Member -MemberType NoteProperty -Name "C: Freespace" -Value $HDFreespace + if ($HDFreespace -lt 5) { + $CurrentServer | Add-Member -MemberType NoteProperty -Name "SpaceCheck" -Value "Consider adding Space to C:" + Write-host "C: Drive does not have enough space" + } + else { + $CurrentServer | Add-Member -MemberType NoteProperty -Name "SpaceCheck" -Value "Server has sufficient space for Windows Updates" + Write-host "C: has plenty of space" + } + + $DriveCheck = @() + + #Windows Update Details + $failedupdates = Invoke-Command -Session $pssession -ScriptBlock { + $Session = New-Object -ComObject "Microsoft.Update.Session" + + $Searcher = $Session.CreateUpdateSearcher() + + $historyCount = $Searcher.GetTotalHistoryCount() + + $Searcher.QueryHistory(0, $historyCount) | Select-Object @{Name="Computer"; Expression={$Computer}}, Date, + + @{name="Operation"; expression={switch($_.operation){ + + 1 {"Installation"}; 2 {"Uninstallation"}; 3 {"Other"}}}}, + + @{name="Status"; expression={switch($_.resultcode){ + + 1 {"In Progress"}; 2 {"Succeeded"}; 3 {"Succeeded With Errors"}; + + 4 {"Failed"}; 5 {"Aborted"} + + }}},Title| Where-Object {$_.Status -eq "Failed"} +} +$failedupdates |Export-Csv -NoType "E:\Windows Update Failures\UpdateAudit-$ServerName-Failed-WindowsUpdates.csv" + # Exit-PSSession + $ServerReport += $CurrentServer + Get-PSSession | Remove-PSSession + #Copy-Item -Path \\$ServerName\Users\abamaso-ccxadmin\Desktop\UpdateAudit-$ServerName-Failed-WindowsUpdates.csv -Destination 'C:\Users\abamaso-ccxadmin\Desktop\WIndows Update Failures' +} +#outSide PSSession if +else { + $CurrentServer | Add-Member -MemberType NoteProperty -Name "Status" -Value "Inaccessible" + Write-host "$ServerName Inaccessible" + $ServerReport += $CurrentServer +} +} +#outside for each +$ServerReport | Export-Csv "E:\Windows Update Failures\ServerReport.csv" \ No newline at end of file diff --git a/dump/WSUS_Scripts/Patching-Day/Get-WSUSGroupPatchInProgress2.ps1 b/dump/WSUS_Scripts/Patching-Day/Get-WSUSGroupPatchInProgress2.ps1 new file mode 100644 index 0000000..b602935 --- /dev/null +++ b/dump/WSUS_Scripts/Patching-Day/Get-WSUSGroupPatchInProgress2.ps1 @@ -0,0 +1,26 @@ +$WSUSGroup = Read-Host "Enter Target Group Name" +$Computers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select Fulldomainname -ExpandProperty Fulldomainname + +foreach ($computer in $computers){ +if(!(Test-Connection -Cn $computer -BufferSize 16 -Count 1 -ea 0 -quiet)) +{write-host "cannot reach $computer" -f red} + +else {$Session = New-Object -ComObject "Microsoft.Update.Session" + +$Searcher = $Session.CreateUpdateSearcher() + +$historyCount = $Searcher.GetTotalHistoryCount() + +$Searcher.QueryHistory(0, $historyCount) | Select-Object @{Name="Computer"; Expression={$Computer}}, Date, + + @{name="Operation"; expression={switch($_.operation){ + + 1 {"Installation"}; 2 {"Uninstallation"}; 3 {"Other"}}}}, + + @{name="Status"; expression={switch($_.resultcode){ + + 1 {"In Progress"}; 2 {"Succeeded"}; 3 {"Succeeded With Errors"}; + + 4 {"Failed"}; 5 {"Aborted"} + +}}},Title| Where {$_.Status -eq "In Progress"}|Write-Host}} \ No newline at end of file diff --git a/dump/WSUS_Scripts/Patching-Day/Patching Groups Host UI.txt b/dump/WSUS_Scripts/Patching-Day/Patching Groups Host UI.txt new file mode 100644 index 0000000..d1a8139 --- /dev/null +++ b/dump/WSUS_Scripts/Patching-Day/Patching Groups Host UI.txt @@ -0,0 +1,27 @@ +PROD: + +NCRA +$Host.UI.RawUI.WindowTitle = "NCRA - AD - Servers" +$Host.UI.RawUI.WindowTitle = "NCRA - Application - Prod" +$Host.UI.RawUI.WindowTitle = "NCRA - BizTalk - PROD" +$Host.UI.RawUI.WindowTitle = "NCRA - Edifecs - PROD" +$Host.UI.RawUI.WindowTitle = "NCRA - Exchange - PROD" +$Host.UI.RawUI.WindowTitle = "NCRA - File Servers - PROD" +$Host.UI.RawUI.WindowTitle = "NCRA - Mail Terminal Servers - PROD" +$Host.UI.RawUI.WindowTitle = "NCRA - Remote Desktop - PROD" +$Host.UI.RawUI.WindowTitle = "NCRA - SQL - PROD" +$Host.UI.RawUI.WindowTitle = "NCRA - Terminal Servers - PROD" +$Host.UI.RawUI.WindowTitle = "NCRA - Verint - PROD" +$Host.UI.RawUI.WindowTitle = "NCRA - Vistar Terminal Servers - PROD" +$Host.UI.RawUI.WindowTitle = "NCRA - Web - PROD" + +OTHERS: +$Host.UI.RawUI.WindowTitle = "CTHA - Production Servers" +$Host.UI.RawUI.WindowTitle = "FLT2 - Application - PROD" + +MANUAL: +$Host.UI.RawUI.WindowTitle = "CyberArc - PROD" +$Host.UI.RawUI.WindowTitle = "Exchange - PROD" +$Host.UI.RawUI.WindowTitle = "Infrastructure Weekend" +$Host.UI.RawUI.WindowTitle = "Last AD Controller" +$Host.UI.RawUI.WindowTitle = "Tidal - PROD" diff --git a/dump/WSUS_Scripts/Patching-Day/temp.txt b/dump/WSUS_Scripts/Patching-Day/temp.txt new file mode 100644 index 0000000..70ec74a --- /dev/null +++ b/dump/WSUS_Scripts/Patching-Day/temp.txt @@ -0,0 +1,27 @@ +psrs001 +psql007 +psis002 +pcpr001 +psql015 +psrs003 + +prsh182-failed connect +prsh028-failed connect +prsh175 +pedi116 +prsh029-failed connect +pvrt003 +prsh014-failed connect +prsh018-failed connect +prsh002-failed connect + +pedi114-failed connect +pedi111-failed connect +pedi115-failed connect +pspt001 +pbiz122 +pbiz124 +pbiz125 +pbiz126 +pbiz123 +pbiz121 \ No newline at end of file diff --git a/dump/WSUS_Scripts/ReRun-Quick.ps1 b/dump/WSUS_Scripts/ReRun-Quick.ps1 new file mode 100644 index 0000000..08f027f --- /dev/null +++ b/dump/WSUS_Scripts/ReRun-Quick.ps1 @@ -0,0 +1,28 @@ +$servers = Import-Csv "E:\WSUS_Scripts\Patching-Day\December-2019\Tier0-December-Patching\ReRun\.csv" | select name +Get-Job | Remove-Job +$S2 = @() +$T = @() +$servers | % { $T += $_.Name.Split('#')[1] } +$P_Job_Failed_Servers = @() + +Foreach ($S in $T) { + #$S = $T.name + $P_Job_Failed_Servers += Start-Job -ScriptBlock { Param($S) WindowsUpdate\Install-WindowsUpdate -ComputerName $S } -Name "$WSUSGroup-#$S#-Patching" -ArgumentList $S + +}#endForeach + +$P_Job_Failed_Servers | ft -AutoSize + + +<# + + +$Failed_J = Get-Job | ? { $_.State -eq "Failed" } | Select Name +$Failed_J | % { $S2 += $_.Name.Split('#')[1] } + + +#> + + + + diff --git a/dump/WSUS_Scripts/Reboot-QATidal.ps1 b/dump/WSUS_Scripts/Reboot-QATidal.ps1 new file mode 100644 index 0000000..16bfbfd --- /dev/null +++ b/dump/WSUS_Scripts/Reboot-QATidal.ps1 @@ -0,0 +1,45 @@ +Restart-Computer -ComputerName qsch013.ccx.carecentrix.com -Force +Write-Host "qsch013.ccx.carecentrix.com restart initiated" +Start-Sleep -Seconds 180 +$ServerStatusCheck = Test-NetConnection -ComputerName qsch013.ccx.carecentrix.com +$ServerStatusOnline = $ServerStatusCheck.PingSucceeded +if ($ServerStatusOnline -eq $true) { +Write-Host "qsch013 is Online" +} +else { +Write-Host "qsch013 is not online" +} + +Restart-Computer -ComputerName qsch014.ccx.carecentrix.com -Force +Write-Host "qsch014.ccx.carecentrix.com restart initiated" +Start-Sleep -Seconds 180 +$ServerStatusCheck = Test-NetConnection -ComputerName qsch014.ccx.carecentrix.com +$ServerStatusOnline = $ServerStatusCheck.PingSucceeded +if ($ServerStatusOnline -eq $true) { +Write-Host "qsch014 is Online" +} +else { +Write-Host "qsch014 is not online" +} +Restart-Computer -ComputerName qsch011.ccx.carecentrix.com -Force +Write-Host "qsch011.ccx.carecentrix.com restart initiated" +Start-Sleep -Seconds 180 +$ServerStatusCheck = Test-NetConnection -ComputerName qsch011.ccx.carecentrix.com +$ServerStatusOnline = $ServerStatusCheck.PingSucceeded +if ($ServerStatusOnline -eq $true) { +Write-Host "qsch011 is Online" +} +else { +Write-Host "qsch011 is not online" +} +Restart-Computer -ComputerName qsch012.ccx.carecentrix.com -Force +Write-Host "qsch012.ccx.carecentrix.com restart initiated" +Start-Sleep -Seconds 180 +$ServerStatusCheck = Test-NetConnection -ComputerName qsch012.ccx.carecentrix.com +$ServerStatusOnline = $ServerStatusCheck.PingSucceeded +if ($ServerStatusOnline -eq $true) { +Write-Host "qsch012 is Online" +} +else { +Write-Host "qsch012 is not online" +} \ No newline at end of file diff --git a/dump/WSUS_Scripts/Reboot-Tidal.ps1 b/dump/WSUS_Scripts/Reboot-Tidal.ps1 new file mode 100644 index 0000000..f2b69e2 --- /dev/null +++ b/dump/WSUS_Scripts/Reboot-Tidal.ps1 @@ -0,0 +1,8 @@ +$ErrorActionPreference = "Ignore" +Restart-Computer -ComputerName psch013.ccx.carecentrix.com -Force +Start-Sleep -Seconds 600 +Restart-Computer -ComputerName psch014.ccx.carecentrix.com -Force +Start-Sleep -Seconds 600 +Restart-Computer -ComputerName psch011.ccx.carecentrix.com -Force +Start-Sleep -Seconds 600 +Restart-Computer -ComputerName psch012.ccx.carecentrix.com -Force \ No newline at end of file diff --git a/dump/WSUS_Scripts/Reset-WindowsUpdateAgent.ps1 b/dump/WSUS_Scripts/Reset-WindowsUpdateAgent.ps1 new file mode 100644 index 0000000..3b065a8 --- /dev/null +++ b/dump/WSUS_Scripts/Reset-WindowsUpdateAgent.ps1 @@ -0,0 +1,120 @@ +<# +.SYNOPSIS +Reset-WindowsUpdate.ps1 - Resets the Windows Update components + +.DESCRIPTION +This script will reset all of the Windows Updates components to DEFAULT SETTINGS. + +.OUTPUTS +Results are printed to the console. Future releases will support outputting to a log file. + +.NOTES +Written by: Ryan Nemeth + +Find me on: + +* My Blog: http://www.geekyryan.com +* Twitter: https://twitter.com/geeky_ryan +* LinkedIn: https://www.linkedin.com/in/ryan-nemeth-b0b1504b/ +* Github: https://github.com/rnemeth90 +* TechNet: https://social.technet.microsoft.com/profile/ryan%20nemeth/ + +Change Log +V1.00, 05/21/2015 - Initial version +V1.10, 09/22/2016 - Fixed bug with call to sc.exe +V1.20, 11/13/2017 - Fixed environment variables +#> + + +$arch = Get-WMIObject -Class Win32_Processor -ComputerName LocalHost | Select-Object AddressWidth + +Write-Host "1. Stopping Windows Update Services..." +Stop-Service -Name BITS +Stop-Service -Name wuauserv +Stop-Service -Name appidsvc +Stop-Service -Name cryptsvc + +Write-Host "2. Remove QMGR Data file..." +Remove-Item "$env:allusersprofile\Application Data\Microsoft\Network\Downloader\qmgr*.dat" -ErrorAction SilentlyContinue + +Write-Host "3. Renaming the Software Distribution and CatRoot Folder..." +Rename-Item $env:systemroot\SoftwareDistribution SoftwareDistribution.bak -ErrorAction SilentlyContinue +Rename-Item $env:systemroot\System32\Catroot2 catroot2.bak -ErrorAction SilentlyContinue + +Write-Host "4. Removing old Windows Update log..." +Remove-Item $env:systemroot\WindowsUpdate.log -ErrorAction SilentlyContinue + +Write-Host "5. Resetting the Windows Update Services to defualt settings..." +"sc.exe sdset bits D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;AU)(A;;CCLCSWRPWPDTLOCRRC;;;PU)" +"sc.exe sdset wuauserv D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;AU)(A;;CCLCSWRPWPDTLOCRRC;;;PU)" + +Set-Location $env:systemroot\system32 + +Write-Host "6. Registering some DLLs..." +regsvr32.exe /s atl.dll +regsvr32.exe /s urlmon.dll +regsvr32.exe /s mshtml.dll +regsvr32.exe /s shdocvw.dll +regsvr32.exe /s browseui.dll +regsvr32.exe /s jscript.dll +regsvr32.exe /s vbscript.dll +regsvr32.exe /s scrrun.dll +regsvr32.exe /s msxml.dll +regsvr32.exe /s msxml3.dll +regsvr32.exe /s msxml6.dll +regsvr32.exe /s actxprxy.dll +regsvr32.exe /s softpub.dll +regsvr32.exe /s wintrust.dll +regsvr32.exe /s dssenh.dll +regsvr32.exe /s rsaenh.dll +regsvr32.exe /s gpkcsp.dll +regsvr32.exe /s sccbase.dll +regsvr32.exe /s slbcsp.dll +regsvr32.exe /s cryptdlg.dll +regsvr32.exe /s oleaut32.dll +regsvr32.exe /s ole32.dll +regsvr32.exe /s shell32.dll +regsvr32.exe /s initpki.dll +regsvr32.exe /s wuapi.dll +regsvr32.exe /s wuaueng.dll +regsvr32.exe /s wuaueng1.dll +regsvr32.exe /s wucltui.dll +regsvr32.exe /s wups.dll +regsvr32.exe /s wups2.dll +regsvr32.exe /s wuweb.dll +regsvr32.exe /s qmgr.dll +regsvr32.exe /s qmgrprxy.dll +regsvr32.exe /s wucltux.dll +regsvr32.exe /s muweb.dll +regsvr32.exe /s wuwebv.dll + +Write-Host "7) Removing WSUS client settings..." +REG DELETE "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate" /v AccountDomainSid /f +REG DELETE "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate" /v PingID /f +REG DELETE "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate" /v SusClientId /f + +Write-Host "8) Resetting the WinSock..." +netsh winsock reset +netsh winhttp reset proxy + +Write-Host "9) Delete all BITS jobs..." +Get-BitsTransfer | Remove-BitsTransfer + +Write-Host "10) Attempting to install the Windows Update Agent..." +if($arch -eq 64){ + wusa Windows8-RT-KB2937636-x64 /quiet +} +else{ + wusa Windows8-RT-KB2937636-x86 /quiet +} + +Write-Host "11) Starting Windows Update Services..." +Start-Service -Name BITS +Start-Service -Name wuauserv +Start-Service -Name appidsvc +Start-Service -Name cryptsvc + +Write-Host "12) Forcing discovery..." +wuauclt /resetauthorization /detectnow + +Write-Host "Process complete. Please reboot your computer." \ No newline at end of file diff --git a/dump/WSUS_Scripts/new-Get-EventLogs.ps1 b/dump/WSUS_Scripts/new-Get-EventLogs.ps1 new file mode 100644 index 0000000..5888825 --- /dev/null +++ b/dump/WSUS_Scripts/new-Get-EventLogs.ps1 @@ -0,0 +1,12 @@ +[DateTime]$Check_Date = "10/1/2019" +$Event_ID = "7890","7891" +"w2012a","w2012b" | % { + $Comp_Name = $_ + Write-Host "Checking Server: $_" + $Event_ID | % { + $E_ID = $_ + Write-Host "Checking EventID: $_" + Get-EventLog -LogName Application -ComputerName $Comp_Name | ? { $_.EventID -eq $E_ID -and $_.TimeGenerated -like "*$Check_Date*" } | select MachineName,EventID,EntryType,Source,Message,TimeGenerated,TimeWritten + }#end% + + }#end% \ No newline at end of file diff --git a/dump/WSUS_Scripts/new-Patch-WSUSGroup-4.ps1 b/dump/WSUS_Scripts/new-Patch-WSUSGroup-4.ps1 new file mode 100644 index 0000000..b3f43ae --- /dev/null +++ b/dump/WSUS_Scripts/new-Patch-WSUSGroup-4.ps1 @@ -0,0 +1,110 @@ +<# + +$ErrorActionPreference = "Ignore" +$WSUSGroup = Read-Host "Enter Target Group Name" +$servers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select Fulldomainname -ExpandProperty Fulldomainname +Foreach ($server in $servers) {Install-WindowsUpdate -ComputerName $server -AsJob} + +#Function Restart {# Force Reboot of Group (when auto failed) un-rem and run line below. +#Foreach ($server in $servers) {Restart-Computer -ComputerName $server -Force}} + +#Write-Host "Type Restart and press enter to reboot the $WSUSGroup WSUS Computer Group" +Read-Host -Prompt "Press Enter to exit" +#> + +################################################################################################################################# +#$ErrorActionPreference = "Ignore" + +#$servers = "W2012A","W2012B","slfkjsdl" +#$WSUSGroup = "Test GGroupppppp" +################################################################################################################################# +If(Test-Path E:\WSUS_Scripts\Lock_Script.txt) { + Write-Host "The Script is locked for protection. If you are not running it by mistake - Delete the file (E:\WSUS_Scripts\Lock_Script.txt) and run the Script again" -ForegroundColor Yellow + Break +} +Else { New-Item -Path E:\WSUS_Scripts -Name Lock_Script.txt -ItemType File } +################################################################################################################################# + +Get-Job | Remove-Job + +$Location = Split-Path $MyInvocation.MyCommand.Path -Parent +############################################################ +#$WSUSGroup = gc H:\Scripts\Patching\_Group-Config-File\Config-WSUS-Group.txt +$Current_Month = (Get-Date -UFormat %B) + +############################################################ +$Dte = Get-Date -UFormat %m-%d-%Y +$Collect_Jobs = @() +$Patch_Job = @() +$Failed_Jobs = @() +$Receive_Jobs = @() + +If(!(Test-Path E:\WSUS_Scripts\Patching-Day\$WSUSGroup-$Current_Month-Patching)) { New-Item -Path "E:\WSUS_Scripts\Patching-Day" -ItemType Directory -Name $WSUSGroup-$Current_Month-Patching } + +$servers = "" +$WSUSGroup = Read-Host "Enter Target Group Name" + +#$servers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select -ExpandProperty Fulldomainname +$Group_Folder = "$WSUSGroup-$Current_Month-Patching" + +#$Servers_Reboot_Only = Import-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\CCXQ1-November-Prep-Files\Manual-$WSUSGroup-OperatingSystems-$Current_Month.csv +$servers = Import-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Target-Group-Computers-$Current_Month.csv | select -ExpandProperty FullDomainName + +$servers = $servers | ? { $_ -notin $Servers_Reboot_Only.FullDomainName } + +#$Failed_Ping_Test = gc $Location\Files\$WSUSGroup-Ping-Failed-$Current_Month.txt +#$servers = $servers | ? { $_ -notin $Failed_Ping_Test } + +$servers | Out-File $Location\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Today-$Dte.txt +$servers | Out-File E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Today-Backup-$Dte.txt + +Foreach ($server in $servers) { + + New-EventLog -LogName Application -Source "Patching-Started" -ErrorAction SilentlyContinue -ComputerName $server -verbose + New-EventLog -LogName Application -Source "Patching-Finished" -ErrorAction SilentlyContinue -ComputerName $server -verbose + New-EventLog -LogName System -Source "Reboot-After-Patching" -ErrorAction SilentlyContinue -ComputerName $server -verbose + Write-EventLog -LogName Application -Source "Patching-Started" -EntryType Information -EventId 7890 -Message "Server Patching Started with Powershell - Remote" -ComputerName $server -ErrorAction SilentlyContinue -verbose + + $Patch_Job += Start-Job -ScriptBlock { Param($server) WindowsUpdate\Install-WindowsUpdate -ComputerName $server } -Name "$WSUSGroup-#$server#-Patching" -ArgumentList $server + + Invoke-Command $server -ErrorAction SilentlyContinue { + New-EventLog -LogName Application -Source "Patching-Started" -ErrorAction SilentlyContinue -verbose + New-EventLog -LogName Application -Source "Patching-Finished" -ErrorAction SilentlyContinue -verbose + New-EventLog -LogName System -Source "Reboot-After-Patching" -ErrorAction SilentlyContinue -verbose + Write-EventLog -LogName Application -Source "Patching-Started" -EntryType Information -EventId 7890 -Message "Server Patching Started with Powershell - Invoke" -verbose + }#endInvoke + +}#endForeach + +#Get-Job + +$Patch_Job | Export-Csv $Location\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Jobs-$Dte.csv -NoTypeInformation +$Patch_Job | Export-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Jobs-Backup-$Dte.csv -NoTypeInformation + +$Collect_Jobs = Get-Job | Export-Csv $Location\Patching-Day\$Group_Folder\$WSUSGroup-Collect-Patching-Jobs-$Dte.csv -NoTypeInformation +$Collect_Jobs = Get-Job | Export-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Collect-Patching-Jobs-Backup-$Dte.csv -NoTypeInformation + +$Patch_Job | Select @{n="Server";e={$_.Name.Split('-')[0]}},@{n="MainJobID";e={$_.ID}},@{n="MainJobName";e={$_.Name}},@{n="ChildJobID";e={$_.Childjobs.ID}},@{n="ChildJobState";e={$_.Childjobs.State}},PSBeginTime,PSEndTime,Command | Export-Csv $Location\Patching-Day\$Group_Folder\$WSUSGroup-Jobs-ChildJobs-$Dte.csv -NoTypeInformation +$Patch_Job | Select @{n="Server";e={$_.Name.Split('-')[0]}},@{n="MainJobID";e={$_.ID}},@{n="MainJobName";e={$_.Name}},@{n="ChildJobID";e={$_.Childjobs.ID}},@{n="ChildJobState";e={$_.Childjobs.State}},PSBeginTime,PSEndTime,Command | Export-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Jobs-ChildJobs-Backup-$Dte.csv -NoTypeInformation + + +<# + +$Failed_Jobs += $Patch_Job | ? { $_.State -eq "Failed" } + +$Failed_Jobs | ft -autosize + +$Failed_Jobs | Export-Csv "E:\WSUS_Scripts\Patching-Day\NCRA - Quality Assurance Servers-November-Patching\failed-jobs.csv" -NoTypeInformation + +#> + + +### Running Count +## ( $Patch_Job | ? { $_.State -eq "Running" } ).count + +## ( $Patch_Job | ? { $_.State -eq "Completed" } ).count + +## ( $Patch_Job | ? { $_.State -eq "Failed" } ).count + + + \ No newline at end of file diff --git a/dump/WSUS_Scripts/new-Reboot-WSUSGroup-3.ps1 b/dump/WSUS_Scripts/new-Reboot-WSUSGroup-3.ps1 new file mode 100644 index 0000000..6b29cc6 --- /dev/null +++ b/dump/WSUS_Scripts/new-Reboot-WSUSGroup-3.ps1 @@ -0,0 +1,67 @@ + +$Location = Split-Path $MyInvocation.MyCommand.Path -Parent +################################################################################################################################# +$Dte = Get-Date -UFormat %m-%d-%Y +$Current_Month = (Get-Date -UFormat %B) +#$WSUSGroup = gc H:\Scripts\Patching\_Group-Config-File\Config-WSUS-Group.txt +#$Group_Folder = "$WSUSGroup-$Current_Month-Patching" +#$Group = "NCRA - Development Servers" +################################################################################################################################# +$servers = "" +$WSUSGroup = Read-Host "Enter Target Group Name" +#$servers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select Fulldomainname -ExpandProperty Fulldomainname +$Group_Folder = "$WSUSGroup-$Current_Month-Patching" + +#$servers = Import-Csv E:\WSUS_Scripts\Patching-Day\December-2019\$Group_Folder\CCXQ1-November-Prep-Files\$WSUSGroup-Target-Group-Computers-$Current_Month.csv | select -ExpandProperty FullDomainName +$servers = Import-Csv E:\WSUS_Scripts\Patching-Day\December-2019\$WSUSGroup.csv | select -ExpandProperty FullDomainName + + +$servers | Out-File $Location\Patching-Day\$Group_Folder\$WSUSGroup-Servers-Rebooting-$Dte.txt -ErrorAction SilentlyContinue +$servers | Out-File E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Servers-Rebooting-Backup-$Dte.txt -ErrorAction SilentlyContinue + +#$servers = $servers | ? { $_ -ne "qadf001.ccx.carecentrix.com"} + +$Patch_Job | Export-Csv $Location\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Jobs-$Dte-Before-Reboot.csv -NoTypeInformation -ErrorAction SilentlyContinue +$Patch_Job | Export-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Jobs-$Dte-Before-Reboot-Backup.csv -NoTypeInformation -ErrorAction SilentlyContinue + +Get-Job | Export-Csv $Location\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Get-Jobs-$Dte-Before-Reboot.csv -NoTypeInformation -ErrorAction SilentlyContinue +Get-Job | Export-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Get-Jobs-$Dte-Before-Reboot-Backup.csv -NoTypeInformation -ErrorAction SilentlyContinue + +$Collect_Jobs = Get-Job | Export-Csv $Location\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Collect-Patching-Jobs-$Dte-Before-Reboot.csv -NoTypeInformation +$Collect_Jobs = Get-Job | Export-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Collect-Patching-Jobs-$Dte-Before-Reboot-Backup.csv -NoTypeInformation + +Foreach ($server in $servers) { + + Write-EventLog -LogName Application -Source "Patching-Finished" -EntryType Information -EventId 7891 -Message "Powershell-WSUS-Patching-Finished - Remote" -ComputerName $server -ErrorAction SilentlyContinue + Write-EventLog -LogName System -Source "Reboot-After-Patching" -EntryType Information -EventId 7892 -Message "Server Rebooting After Patching - Remote" -ComputerName $server -ErrorAction SilentlyContinue + + Invoke-Command $server -ErrorAction SilentlyContinue { + #New-EventLog -LogName Application -Source "Powershell-WSUS-Patching-Finished" -ErrorAction SilentlyContinue + #New-EventLog -LogName System -Source "Powershell-Reboot-After-Patching" -ErrorAction SilentlyContinue + Write-EventLog -LogName Application -Source "Patching-Finished" -EntryType Information -EventId 7891 -Message "Powershell-WSUS-Patching-Finished - Invoke" -ErrorAction SilentlyContinue + Write-EventLog -LogName System -Source "Reboot-After-Patching" -EntryType Information -EventId 7892 -Message "Server Rebooting After Patching - Invoke" -ErrorAction SilentlyContinue + }#endInvoke + Restart-Computer -ComputerName $server -Force -Verbose + +}#endForeach + + + +<# + +$servers | % { $T = Test-Connection -ComputerName $_ -Count 1 -ErrorAction SilentlyContinue + If($T) { Write-Host "Server $_ -- Responding" -ForegroundColor Green } Else { Write-Host "Server $_ -- Not Responding" -ForegroundColor Red } + } + + +#> + +# $Servers | % { Get-EventLog -LogName System -ComputerName $_.computer | ? { $_.EventID -eq '7893' } } + + +# $Servers | % { gwmi win32_operatingsystem -ComputerName $_ | select @{n="Server";e={$_.PSComputername}},@{n="LastBootup";e={$_.Converttodatetime($_.LastBootUpTime)}}} + + + + + diff --git a/dump/WmiExplorer_2.0.0.2/WmiExplorer.exe b/dump/WmiExplorer_2.0.0.2/WmiExplorer.exe new file mode 100644 index 0000000..91d958d Binary files /dev/null and b/dump/WmiExplorer_2.0.0.2/WmiExplorer.exe differ diff --git a/dump/_11PM-Production-Patching-File-Servers.txt b/dump/_11PM-Production-Patching-File-Servers.txt new file mode 100644 index 0000000..ed56ed6 Binary files /dev/null and b/dump/_11PM-Production-Patching-File-Servers.txt differ diff --git a/dump/_9PM-Production-Patching.txt b/dump/_9PM-Production-Patching.txt new file mode 100644 index 0000000..05c4666 Binary files /dev/null and b/dump/_9PM-Production-Patching.txt differ diff --git a/dump/_Get-SCCMSoftwareUpdateStatus.ps1 b/dump/_Get-SCCMSoftwareUpdateStatus.ps1 new file mode 100644 index 0000000..eed9825 --- /dev/null +++ b/dump/_Get-SCCMSoftwareUpdateStatus.ps1 @@ -0,0 +1,145 @@ +function Get-SCCMSoftwareUpdateStatus { +<# +.Synopsis + This will output the device status for the Software Update Deployments within SCCM. + For updated help and examples refer to -Online version. + + +.DESCRIPTION + This will output the device status for the Software Update Deployments within SCCM. + For updated help and examples refer to -Online version. + + +.NOTES + Name: Get-SCCMSoftwareUpdateStatus + Author: The Sysadmin Channel + Version: 1.0 + DateCreated: 2018-Nov-10 + DateUpdated: 2018-Nov-10 + +.LINK + https://thesysadminchannel.com/get-sccm-software-update-status-powershell - + + +.EXAMPLE + For updated help and examples refer to -Online version. + +#> + + [CmdletBinding()] + + param( + [Parameter()] + [switch] $DeploymentIDFromGUI, + + [Parameter(Mandatory = $false)] + [Alias('ID', 'AssignmentID')] + [string] $DeploymentID, + + [Parameter(Mandatory = $false)] + [ValidateSet('Success', 'InProgress', 'Error', 'Unknown')] + [Alias('Filter')] + [string] $Status + + + ) + + BEGIN { + $Site_Code = 'CCX' + $Site_Server = 'PNCRASCCM001' + $HasErrors = $False + + if ($Status -eq 'Success') { + $StatusType = 1 + } + + if ($Status -eq 'InProgress') { + $StatusType = 2 + } + + if ($Status -eq 'Unknown') { + $StatusType = 4 + } + + if ($Status -eq 'Error') { + $StatusType = 5 + } + + } + + PROCESS { + try { + if ($DeploymentID -and $DeploymentIDFromGUI) { + Write-Error "Select the DeploymentIDFromGUI or DeploymentID Parameter. Not Both" + $HasErrors = $True + throw + } + + if ($DeploymentIDFromGUI) { + $ShellLocation = Get-Location + Import-Module (Join-Path $(Split-Path $env:SMS_ADMIN_UI_PATH) ConfigurationManager.psd1) + + #Checking to see if module has been imported. If not abort. + if (Get-Module ConfigurationManager) { + Set-Location "$($Site_Code):\" + $DeploymentID = Get-CMSoftwareUpdateDeployment | select AssignmentID, AssignmentName | Out-GridView -OutputMode Single -Title "Select a Deployment and Click OK" | Select -ExpandProperty AssignmentID + Set-Location $ShellLocation + } else { + Write-Error "The SCCM Module wasn't imported successfully. Aborting." + $HasErrors = $True + throw + } + } + + if ($DeploymentID) { + $DeploymentNameWithID = Get-WMIObject -ComputerName $Site_Server -Namespace root\sms\site_$Site_Code -class SMS_SUMDeploymentAssetDetails -Filter "AssignmentID = $DeploymentID" | select AssignmentID, AssignmentName + $DeploymentName = $DeploymentNameWithID.AssignmentName | select -Unique + } else { + Write-Error "A Deployment ID was not specified. Aborting." + $HasErrors = $True + throw + } + + if ($Status) { + $Output = Get-WMIObject -ComputerName $Site_Server -Namespace root\sms\site_$Site_Code -class SMS_SUMDeploymentAssetDetails -Filter "AssignmentID = $DeploymentID and StatusType = $StatusType" | ` + select DeviceName, CollectionName, @{Name = 'StatusTime'; Expression = {$_.ConvertToDateTime($_.StatusTime) }}, @{Name = 'Status' ; Expression = {if ($_.StatusType -eq 1) {'Success'} elseif ($_.StatusType -eq 2) {'InProgress'} elseif ($_.StatusType -eq 5) {'Error'} elseif ($_.StatusType -eq 4) {'Unknown'} }} + + } else { + $Output = Get-WMIObject -ComputerName $Site_Server -Namespace root\sms\site_$Site_Code -class SMS_SUMDeploymentAssetDetails -Filter "AssignmentID = $DeploymentID" | ` + select DeviceName, CollectionName, @{Name = 'StatusTime'; Expression = {$_.ConvertToDateTime($_.StatusTime) }}, @{Name = 'Status' ; Expression = {if ($_.StatusType -eq 1) {'Success'} elseif ($_.StatusType -eq 2) {'InProgress'} elseif ($_.StatusType -eq 5) {'Error'} elseif ($_.StatusType -eq 4) {'Unknown'} }} + } + + if (-not $Output) { + Write-Error "A Deployment with ID: $($DeploymentID) is not valid. Aborting" + $HasErrors = $True + throw + + } + + } catch { + + + } finally { + if (($HasErrors -eq $false) -and ($Output)) { + Write-Output "" + Write-Output "Deployment Name: $DeploymentName" + Write-Output "Deployment ID: $DeploymentID" + Write-Output "" + Write-Output $Output | Sort-Object Status + } + } + } + + END {} + +} + + + + + +# $T = Get-SCCMSoftwareUpdateStatus -DeploymentID 16777850 + +# Get-SCCMSoftwareUpdateStatus -DeploymentIDFromGUI | ? { $_.Assignmentname -like "dsfsdfsd" } + +# Get-SCCMSoftwareUpdateStatus -DeploymentIDFromGUI diff --git a/dump/_Post-Patching-Steps.txt b/dump/_Post-Patching-Steps.txt new file mode 100644 index 0000000..8517fac --- /dev/null +++ b/dump/_Post-Patching-Steps.txt @@ -0,0 +1,11 @@ +One Note - Search Sop + +1. Log on to PAPP001 with Tidal/T1d@l$ Account and run locally as Administrator : \\PAPP001\Apps\CTP PDF Creator\ctppdfprocess.bat +batch file from PAPP001 locally if run remotely it will fail to create the log file they are looking for + + --- Open the following shortcut on PCCR001 desktop \\sharepoint@ssl\sites\rcm\cignaredirect. Close the window and close the session. + + +2. Login to PSRS004 as tidal/T1d@l$ user and close the session. + +3. Login to PWHD003, stop Webhelpdesk, then start webhelpdesk from start menu \ No newline at end of file diff --git a/dump/temp-tool1.ps1 b/dump/temp-tool1.ps1 new file mode 100644 index 0000000..9eab0bf --- /dev/null +++ b/dump/temp-tool1.ps1 @@ -0,0 +1,46 @@ +<# + +$Count = 0 +$W = $ServerName | % { $S = $_ + Write-host "Checking Server: $S" + $Count++ ;gci \\$S\c$\windows\ccmcache -ErrorAction SilentlyContinue | ? { $_.LastWriteTime -gt ((Get-Date).AddDays(-4))} | select -First 1 | select @{n="Num";e={$Count}},@{n="Server";e={$S}},Lastwritetime,Name } + + +$W | sort LastWritetime -Descending + +write-host "Collection Name: $DeviceCollection_Name" -ForegroundColor Yellow + + +#> + +<###################################################################### + +$Responding = @() +$NotResponding = @() + +$DeviceCollection_ServerNames.Name | % { + + If (Test-Connection $_ -Count 1 -ErrorAction SilentlyContinue ) { + Write-Host "Responding:---- $_ " -ForegroundColor Green + $Responding += $_ + + }#endIf + + Else { $NotResponding += $_ } + +}#end% + write-host "-------------------------------------------------------" + Write-host "$($Responding.count) / $($DeviceCollection_ServerNames.Name.count) -- Responding" -foregroundcolor Green + Write-host "$($NotResponding.count) / $($DeviceCollection_ServerNames.Name.count) -- NOT Responding" -foregroundcolor Red + + +Write-Host "Servers NOT Responding: $NotResponding " -ForegroundColor Red + + + + +$Responding | % { gwmi win32_operatingsystem -ComputerName $_ -ErrorAction SilentlyContinue | select @{n="Server";e={$_.PSComputername}},@{n="LastBootup";e={$_.Converttodatetime($_.LastBootUpTime)}}} | sort LastBootup -descending | ft -autosize + + + +#> diff --git a/dump/temp/collection-membership.ps1 b/dump/temp/collection-membership.ps1 new file mode 100644 index 0000000..203cbbe --- /dev/null +++ b/dump/temp/collection-membership.ps1 @@ -0,0 +1,20 @@ +$Dev = "w2012a","w2012b" +$Temp = @() +$Dev | % { $S = $_ + $W = (Get-WmiObject -ComputerName pncrasccm001 -Namespace root\SMS\site_ccx -Query "SELECT SMS_Collection.* FROM SMS_FullCollectionMembership, SMS_Collection where name = '$S' and SMS_FullCollectionMembership.CollectionID = SMS_Collection.CollectionID").name + + $W | % { + $Obj = New-Object -TypeName PSObject + $Obj | Add-Member -MemberType NoteProperty -Name Server -Value $S + $Obj | Add-Member -MemberType NoteProperty -Name Collection -Value $_ + $Obj + $Temp += $Obj + } + +}#end% + + + + + + #$Collections | select name \ No newline at end of file diff --git a/intune/Desktop Scripts/Force_Win11_Upgrade.ps1 b/intune/Desktop Scripts/Force_Win11_Upgrade.ps1 new file mode 100644 index 0000000..b415121 --- /dev/null +++ b/intune/Desktop Scripts/Force_Win11_Upgrade.ps1 @@ -0,0 +1,5 @@ +Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force +Set-PSRepository -Name PSGallery -InstallationPolicy Trusted +Install-Module pswindowsupdate +Import-Module pswindowsupdate +Get-WindowsUpdate -MicrosoftUpdate -Title "Windows 11, version 23H2" -AcceptAll -AutoReboot -Verbose -ForceDownload -ForceInstall \ No newline at end of file diff --git a/intune/Intune Platform Scripts/CheckForUpdates.ps1 b/intune/Intune Platform Scripts/CheckForUpdates.ps1 new file mode 100644 index 0000000..332cb8c --- /dev/null +++ b/intune/Intune Platform Scripts/CheckForUpdates.ps1 @@ -0,0 +1,4 @@ +Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force +Set-PSRepository -Name PSGallery -InstallationPolicy Trusted +Install-Module pswindowsupdate +Get-WindowsUpdate -KBArticleID KB5027397 -Download \ No newline at end of file diff --git a/intune/Intune Scripts/Correct-PrimaryUser.ps1 b/intune/Intune Scripts/Correct-PrimaryUser.ps1 new file mode 100644 index 0000000..5a1d3a4 --- /dev/null +++ b/intune/Intune Scripts/Correct-PrimaryUser.ps1 @@ -0,0 +1,292 @@ +#Get All Windows 10 Intune Managed Devices for the Tenant +function Get-AuthToken { + + <# + .SYNOPSIS + This function is used to authenticate with the Graph API REST interface + .DESCRIPTION + The function authenticate with the Graph API Interface with the tenant name + .EXAMPLE + Get-AuthToken + Authenticates you with the Graph API interface + .NOTES + NAME: Get-AuthToken + #> + + [cmdletbinding()] + + param + ( + [Parameter(Mandatory=$true)] + $User + ) + + $userUpn = New-Object "System.Net.Mail.MailAddress" -ArgumentList $User + + $tenant = $userUpn.Host + + Write-Host "Checking for AzureAD module..." + + $AadModule = Get-Module -Name "AzureAD" -ListAvailable + + if ($AadModule -eq $null) { + + Write-Host "AzureAD PowerShell module not found, looking for AzureADPreview" + $AadModule = Get-Module -Name "AzureADPreview" -ListAvailable + + } + + if ($AadModule -eq $null) { + write-host + write-host "AzureAD Powershell module not installed..." -f Red + write-host "Install by running 'Install-Module AzureAD' or 'Install-Module AzureADPreview' from an elevated PowerShell prompt" -f Yellow + write-host "Script can't continue..." -f Red + write-host + exit + } + + # Getting path to ActiveDirectory Assemblies + # If the module count is greater than 1 find the latest version + + if($AadModule.count -gt 1){ + + $Latest_Version = ($AadModule | select version | Sort-Object)[-1] + + $aadModule = $AadModule | ? { $_.version -eq $Latest_Version.version } + + # Checking if there are multiple versions of the same module found + + if($AadModule.count -gt 1){ + + $aadModule = $AadModule | select -Unique + + } + + $adal = Join-Path $AadModule.ModuleBase "Microsoft.IdentityModel.Clients.ActiveDirectory.dll" + $adalforms = Join-Path $AadModule.ModuleBase "Microsoft.IdentityModel.Clients.ActiveDirectory.Platform.dll" + + } + + else { + + $adal = Join-Path $AadModule.ModuleBase "Microsoft.IdentityModel.Clients.ActiveDirectory.dll" + $adalforms = Join-Path $AadModule.ModuleBase "Microsoft.IdentityModel.Clients.ActiveDirectory.Platform.dll" + + } + + [System.Reflection.Assembly]::LoadFrom($adal) | Out-Null + + [System.Reflection.Assembly]::LoadFrom($adalforms) | Out-Null + + $clientId = "d1ddf0e4-d672-4dae-b554-9d5bdfd93547" + + $redirectUri = "urn:ietf:wg:oauth:2.0:oob" + + $resourceAppIdURI = "https://graph.microsoft.com" + + $authority = "https://login.microsoftonline.com/$Tenant" + + try { + + $authContext = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext" -ArgumentList $authority + + # https://msdn.microsoft.com/en-us/library/azure/microsoft.identitymodel.clients.activedirectory.promptbehavior.aspx + # Change the prompt behaviour to force credentials each time: Auto, Always, Never, RefreshSession + + $platformParameters = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.PlatformParameters" -ArgumentList "Auto" + + $userId = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.UserIdentifier" -ArgumentList ($User, "OptionalDisplayableId") + + $authResult = $authContext.AcquireTokenAsync($resourceAppIdURI,$clientId,$redirectUri,$platformParameters,$userId).Result + + # If the accesstoken is valid then create the authentication header + + if($authResult.AccessToken){ + + # Creating header for Authorization token + + $authHeader = @{ + 'Content-Type'='application/json' + 'Authorization'="Bearer " + $authResult.AccessToken + 'ExpiresOn'=$authResult.ExpiresOn + } + + return $authHeader + + } + + else { + + Write-Host + Write-Host "Authorization Access Token is null, please re-run authentication..." -ForegroundColor Red + Write-Host + break + + } + + } + + catch { + + write-host $_.Exception.Message -f Red + write-host $_.Exception.ItemName -f Red + write-host + break + + } + + } + +function Get-Win10IntuneManagedDevice { + + <# + .SYNOPSIS + This gets information on Intune managed device + .DESCRIPTION + This gets information on Intune managed device + .EXAMPLE + Get-Win10IntuneManagedDevice + .NOTES + NAME: Get-Win10IntuneManagedDevice + #> + + [cmdletbinding()] + + param + ( + [parameter(Mandatory=$false)] + [ValidateNotNullOrEmpty()] + [string]$deviceName + ) + + $graphApiVersion = "beta" + + try { + + if($deviceName){ + + $Resource = "deviceManagement/managedDevices?`$filter=deviceName eq '$deviceName'" + $uri = "https://graph.microsoft.com/$graphApiVersion/$($Resource)" + + (Invoke-RestMethod -Uri $uri -Headers $authToken -Method Get).value + + } + + else { + + $Resource = "deviceManagement/managedDevices?`$filter=(((deviceType%20eq%20%27desktop%27)%20or%20(deviceType%20eq%20%27windowsRT%27)%20or%20(deviceType%20eq%20%27winEmbedded%27)%20or%20(deviceType%20eq%20%27surfaceHub%27)))" + $uri = "https://graph.microsoft.com/$graphApiVersion/$($Resource)" + + (Invoke-RestMethod -Uri $uri -Headers $authToken -Method Get).value + + } + + } catch { + $ex = $_.Exception + $errorResponse = $ex.Response.GetResponseStream() + $reader = New-Object System.IO.StreamReader($errorResponse) + $reader.BaseStream.Position = 0 + $reader.DiscardBufferedData() + $responseBody = $reader.ReadToEnd(); + Write-Host "Response content:`n$responseBody" -f Red + Write-Error "Request to $Uri failed with HTTP Status $($ex.Response.StatusCode) $($ex.Response.StatusDescription)" + throw "Get-IntuneManagedDevices error" + } + + } + +function Get-IntuneDevicePrimaryUser { + + <# + .SYNOPSIS + This lists the Intune device primary user + .DESCRIPTION + This lists the Intune device primary user + .EXAMPLE + Get-IntuneDevicePrimaryUser + .NOTES + NAME: Get-IntuneDevicePrimaryUser + #> + + [cmdletbinding()] + + param + ( + [Parameter(Mandatory=$true)] + [string] $deviceId + ) + + $graphApiVersion = "beta" + $Resource = "deviceManagement/managedDevices" + $uri = "https://graph.microsoft.com/$graphApiVersion/$($Resource)" + "/" + $deviceId + "/users" + + try { + + $primaryUser = Invoke-RestMethod -Uri $uri -Headers $authToken -Method Get + + return $primaryUser.value."id" + + } catch { + $ex = $_.Exception + $errorResponse = $ex.Response.GetResponseStream() + $reader = New-Object System.IO.StreamReader($errorResponse) + $reader.BaseStream.Position = 0 + $reader.DiscardBufferedData() + $responseBody = $reader.ReadToEnd(); + Write-Host "Response content:`n$responseBody" -f Red + Write-Error "Request to $Uri failed with HTTP Status $($ex.Response.StatusCode) $($ex.Response.StatusDescription)" + throw "Get-IntuneDevicePrimaryUser error" + } + } + +#$authtoken = Get-AuthToken -User andrew.amason@carecentrix.com + +$Devices = Get-Win10IntuneManagedDevice | where usersLoggedOn -ne $Null + +Foreach ($Device in $Devices) { + + Write-Host "Device name:" $device."deviceName" -ForegroundColor Cyan + $IntuneDevicePrimaryUser = Get-IntuneDevicePrimaryUser -deviceId $Device.id + + #Check if there is a Primary user set on the device already + if ($IntuneDevicePrimaryUser -eq $null) { + + Write-Host "No Intune Primary User Id set for Intune Managed Device" $Device."deviceName" -f Red + + } + + else { + $PrimaryAADUser = Get-AzureADUser -ObjectId $IntuneDevicePrimaryUser + Write-Host "Intune Device Primary User:" $PrimaryAADUser.displayName + + } + + #Get the objectID of the last logged in user for the device, which is the last object in the list of usersLoggedOn + $LastLoggedInUser = ($Device.usersLoggedOn[-1]).userId + + #Using the objectID, get the user from the Microsoft Graph for logging purposes + $User = Get-AzureADUser -ObjectId $LastLoggedInUser + + #Check if the current primary user of the device is the same as the last logged in user + if ($IntuneDevicePrimaryUser -notmatch $User.ObjectId) { + + #If the user does not match, then set the last logged in user as the new Primary User + $SetIntuneDevicePrimaryUser = Set-IntuneDevicePrimaryUser -IntuneDeviceId $Device.id -userId $User.id + + if ($SetIntuneDevicePrimaryUser -eq "") { + + Write-Host "User"$User.displayName"set as Primary User for device '$($Device.deviceName)'..." -ForegroundColor Green + + } + + } + + else { + #If the user is the same, then write to host that the primary user is already correct. + Write-Host "The user '$($User.displayName)' is already the Primary User on the device..." -ForegroundColor Yellow + + } + + Write-Host + +} diff --git a/intune/Intune Scripts/Disable_MSOnline.ps1 b/intune/Intune Scripts/Disable_MSOnline.ps1 new file mode 100644 index 0000000..89eeaa5 --- /dev/null +++ b/intune/Intune Scripts/Disable_MSOnline.ps1 @@ -0,0 +1,2 @@ +new-item -Path HKCU:\Software\Policies\Microsoft\Office\16.0\Common\Internet +New-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Office\16.0\Common\Internet -Name OnlineStorage -PropertyType DWORD -Value 3 \ No newline at end of file diff --git a/intune/Intune Scripts/rotate_all_bitlocker_keys.ps1 b/intune/Intune Scripts/rotate_all_bitlocker_keys.ps1 new file mode 100644 index 0000000..d04953d --- /dev/null +++ b/intune/Intune Scripts/rotate_all_bitlocker_keys.ps1 @@ -0,0 +1,67 @@ +<# +.SYNOPSIS + Rotates All BitLocker keys for all Windows devices in Intune using Graph API. + +.DESCRIPTION + This script connects to Intune via Graph API and rotates the BitLocker keys for all managed Windows devices. + +.NOTES + Author: Ugur Koc + GitHub: https://github.com/ugurkocde + Twitter: https://x.com/UgurKocDe + LinkedIn: https://www.linkedin.com/in/ugurkocde/ + + Version: 1.0 + Created: 07/20/2024 + Version: 1.1 (07/20/2024) + - Changed Authentication to Connect-MgGraph -Scopes only. + Version: 1.2 (07/20/2024) + - Added pagination. + - Moved the OS Filter to the top, to avoid unnecessary API calls. + +.REQUIREMENTS + - PowerShell 5.1 or later + - Microsoft.Graph.Authentication module + +.LINK + https://learn.microsoft.com/en-us/graph/api/intune-devices-manageddevice-rotatebitlockerkeys?view=graph-rest-beta + +.EXAMPLE + .\rotate_all_bitlocker_keys.ps1 + +.NOTES + Disclaimer: This script is provided AS IS without warranty of any kind. Use it at your own risk. +#> + +Connect-MgGraph -Scopes "DeviceManagementManagedDevices.ReadWrite.All" -NoWelcome + +# Get all managed Windows devices from Intune with pagination +$managedDevices = @() +$nextLink = "https://graph.microsoft.com/v1.0/deviceManagement/managedDevices?`$select=id,deviceName,operatingSystem&`$filter=operatingSystem eq 'Windows'" + +# This loop will get all managed devices from Intune with pagination +while ($nextLink) { + $response = Invoke-MgGraphRequest -Method GET -Uri $nextLink + $managedDevices += $response.value + $nextLink = $response.'@odata.nextLink' +} + +foreach ($device in $managedDevices) { + $deviceId = $device.id + $deviceName = $device.deviceName + + Write-Host "Processing device: $deviceName" -ForegroundColor Cyan + + # Attempt to rotate the BitLocker keys + try { + Invoke-MgGraphRequest -Method POST -Uri "https://graph.microsoft.com/beta/deviceManagement/managedDevices('$deviceId')/rotateBitLockerKeys" -ContentType "application/json" + + Write-Host "Successfully rotated BitLocker keys for device $deviceName" -ForegroundColor Green + } + catch { + Write-Host "Failed to rotate BitLocker keys for device $deviceName" -ForegroundColor Red + Write-Host "Error: $_" -ForegroundColor Red + } +} + +Write-Host "BitLocker key rotation process completed." -ForegroundColor Cyan diff --git a/intune/Proactive Remediations/Bitlocker_KeyRecovery/Bitlocker_KeyRecovery_detection.ps1 b/intune/Proactive Remediations/Bitlocker_KeyRecovery/Bitlocker_KeyRecovery_detection.ps1 new file mode 100644 index 0000000..382e652 --- /dev/null +++ b/intune/Proactive Remediations/Bitlocker_KeyRecovery/Bitlocker_KeyRecovery_detection.ps1 @@ -0,0 +1,33 @@ +### detection script ### +### look for Bitlocker Recovery Key Backup events of Systemdrive + +try +{ + ### obtain protected system volume + $BLSysVolume = Get-BitLockerVolume -MountPoint $env:SystemDrive -ErrorAction Stop + $BLRecoveryProtector = $BLSysVolume.KeyProtector | Where-Object { $_.KeyProtectorType -eq 'RecoveryPassword' } -ErrorAction Stop + $BLprotectorguid = $BLRecoveryProtector.KeyProtectorId + + + ### obtain backup event for System drive + $BLBackupEvent = Get-WinEvent -ProviderName Microsoft-Windows-BitLocker-API -FilterXPath "*[System[(EventID=845)] and EventData[Data[@Name='ProtectorGUID'] and (Data='$BLprotectorguid')]]" -MaxEvents 1 -ErrorAction Stop + + # Check for returned values, if null, write output and exit 1 + if ($BLBackupEvent -gt $null) + { + # Write eventmessage and set exit success + Write-Output $BLBackupEvent.Message + Exit 0 + } + else + { + Write-Output "Key-Backup Event for Bitlocker System drive not found" + Exit 1 + } +} +catch +{ + $errMsg = $_.Exception.Message + Write-Output $errMsg + exit 1 +} diff --git a/intune/Proactive Remediations/Bitlocker_KeyRecovery/Bitlocker_KeyRecovery_remediation.ps1 b/intune/Proactive Remediations/Bitlocker_KeyRecovery/Bitlocker_KeyRecovery_remediation.ps1 new file mode 100644 index 0000000..364cc97 --- /dev/null +++ b/intune/Proactive Remediations/Bitlocker_KeyRecovery/Bitlocker_KeyRecovery_remediation.ps1 @@ -0,0 +1,21 @@ +### remediation script ### +### backup recovery key of systemdrive + +try{ + + ### obtain protected system volume + $BLSysVolume = Get-BitLockerVolume -MountPoint $env:SystemDrive + $BLRecoveryProtector = $BLSysVolume.KeyProtector | Where-Object { $_.KeyProtectorType -eq 'RecoveryPassword' } + $BLprotectorguid = $BLRecoveryProtector.KeyProtectorId + + # Backup sysdrive recovery key to AAD + BackuptoAAD-BitLockerKeyProtector -MountPoint $env:SystemDrive -KeyProtectorId $BLRecoveryProtector.KeyProtectorID -ErrorAction Stop + Exit 0 +} +catch +{ + $errMsg = $_.Exception.Message + Write-Output $errMsg + exit 1 +} + diff --git a/intune/Proactive Remediations/CarbonBlack_AppControl/detect_CB_AP_Health.ps1 b/intune/Proactive Remediations/CarbonBlack_AppControl/detect_CB_AP_Health.ps1 new file mode 100644 index 0000000..5922d90 --- /dev/null +++ b/intune/Proactive Remediations/CarbonBlack_AppControl/detect_CB_AP_Health.ps1 @@ -0,0 +1,28 @@ + +try { + Test-Path -Path "C:\Program Files (x86)\Bit9\Parity Agent" +} +catch { + Write-Host "Carbon Black App Control Folder Does Not Exist" + exit 1 +} + +try { + Test-Path -Path "C:\Program Files (x86)\Bit9\Parity Agent\DasCLI.exe" +} +catch { + Write-Host "Carbon Black App Control is not installed" + exit 1 +} + +Set-Location "C:\Program Files (x86)\Bit9\Parity Agent" +$CBagentstatus = .\DasCLI.exe status + +if (((($CBagentstatus[55]).Split(":")[1])).Trimstart() -like "Healthy") { + Write-Host "Carbon Black agent is healthy" + Exit 0 +} +else { + Write-Host "Carbon Black App Control Status is unknown" ((($CBagentstatus[55]).Split(":")[1])).Trimstart() + exit 1 +} diff --git a/intune/Proactive Remediations/DellInc-DellCommandUpdate/Detect-DellCommandUpdate.ps1 b/intune/Proactive Remediations/DellInc-DellCommandUpdate/Detect-DellCommandUpdate.ps1 new file mode 100644 index 0000000..35b1048 --- /dev/null +++ b/intune/Proactive Remediations/DellInc-DellCommandUpdate/Detect-DellCommandUpdate.ps1 @@ -0,0 +1,86 @@ +<# +.SYNOPSIS + This script is used to detect and remediate built-in apps in Windows 11. + +.DESCRIPTION + The script provides two main functionalities: detection and remediation of built-in apps. By default, the script runs in detection mode, but it can also be configured to perform remediation. + The list of built-in apps to be detected and remediated can be customized by modifying the $appxPackageList array in the script. + +.NOTES + File Name : Detect-Remediate-DellCommandUpdate.ps1 + Author : Martin Bengtsson + Blog : https://www.imab.dk +#> + +param ( + [bool]$runDetection = $true, + [bool]$runRemediation = $false +) + +begin { + $appxPackageList = @( + "DellInc.DellCommandUpdate" + ) + function Test-InstalledAppxPackages() { + foreach ($app in $appxPackageList) { + try { + $isAppInstalled = Get-AppxPackage -Name $app -ErrorAction SilentlyContinue + if (-NOT[string]::IsNullOrEmpty($isAppInstalled)) { + Write-Output $app + } + } + catch { + Write-Output "[ERROR] Failed to retrieve the installed app: $_" + } + } + } + function Remove-InstalledAppxPackages() { + param ( + [string]$appxPackage + ) + try { + Get-AppxPackage -Name $appxPackage | Remove-AppxPackage + $global:remediationSuccess += $true + } + catch { + Write-Output "[ERROR] Failed to remove the app: $_" + } + } + if ($runDetection -eq $false) { + Write-Output "[ERROR] runDetection cannot be set to false. As a minimum runDetection must be set to true." + exit 1 + } +} + +process { + $global:needsRemediation = @() + $global:remediationSuccess = @() + $installedAppxPackages = Test-InstalledAppxPackages + if ($runDetection -eq $true) { + if (-NOT[string]::IsNullOrEmpty($installedAppxPackages)) { + foreach ($app in $installedAppxPackages) { + $global:needsRemediation += $true + if ($runRemediation -eq $true) { + Remove-InstalledAppxPackages -appxPackage $app + } + } + } + } +} + +end { + if ($runDetection -eq $true) { + if ($global:needsRemediation -contains $true -AND $global:remediationSuccess -notcontains $true) { + Write-Output "[WARNING] Built-in apps found installed. Remediation is needed." + exit 1 + } + elseif ($global:remediationSuccess -contains $true -AND $global:remediationSuccess -notcontains $false) { + Write-Output "[OK] Remediation was run successfully. Built-in apps were removed." + exit 0 + } + else { + Write-Output "[OK] No built-in apps found. Doing nothing." + exit 0 + } + } +} diff --git a/intune/Proactive Remediations/DellInc-DellCommandUpdate/Remediate-DellCommandUpdate.ps1 b/intune/Proactive Remediations/DellInc-DellCommandUpdate/Remediate-DellCommandUpdate.ps1 new file mode 100644 index 0000000..746a30d --- /dev/null +++ b/intune/Proactive Remediations/DellInc-DellCommandUpdate/Remediate-DellCommandUpdate.ps1 @@ -0,0 +1,86 @@ +<# +.SYNOPSIS + This script is used to detect and remediate built-in apps in Windows 11. + +.DESCRIPTION + The script provides two main functionalities: detection and remediation of built-in apps. By default, the script runs in detection mode, but it can also be configured to perform remediation. + The list of built-in apps to be detected and remediated can be customized by modifying the $appxPackageList array in the script. + +.NOTES + File Name : Detect-Remediate-DellCommandUpdate.ps1 + Author : Martin Bengtsson + Blog : https://www.imab.dk +#> + +param ( + [bool]$runDetection = $true, + [bool]$runRemediation = $true +) + +begin { + $appxPackageList = @( + "DellInc.DellCommandUpdate" + ) + function Test-InstalledAppxPackages() { + foreach ($app in $appxPackageList) { + try { + $isAppInstalled = Get-AppxPackage -Name $app -ErrorAction SilentlyContinue + if (-NOT[string]::IsNullOrEmpty($isAppInstalled)) { + Write-Output $app + } + } + catch { + Write-Output "[ERROR] Failed to retrieve the installed app: $_" + } + } + } + function Remove-InstalledAppxPackages() { + param ( + [string]$appxPackage + ) + try { + Get-AppxPackage -Name $appxPackage | Remove-AppxPackage + $global:remediationSuccess += $true + } + catch { + Write-Output "[ERROR] Failed to remove the app: $_" + } + } + if ($runDetection -eq $false) { + Write-Output "[ERROR] runDetection cannot be set to false. As a minimum runDetection must be set to true." + exit 1 + } +} + +process { + $global:needsRemediation = @() + $global:remediationSuccess = @() + $installedAppxPackages = Test-InstalledAppxPackages + if ($runDetection -eq $true) { + if (-NOT[string]::IsNullOrEmpty($installedAppxPackages)) { + foreach ($app in $installedAppxPackages) { + $global:needsRemediation += $true + if ($runRemediation -eq $true) { + Remove-InstalledAppxPackages -appxPackage $app + } + } + } + } +} + +end { + if ($runDetection -eq $true) { + if ($global:needsRemediation -contains $true -AND $global:remediationSuccess -notcontains $true) { + Write-Output "[WARNING] Built-in apps found installed. Remediation is needed." + exit 1 + } + elseif ($global:remediationSuccess -contains $true -AND $global:remediationSuccess -notcontains $false) { + Write-Output "[OK] Remediation was run successfully. Built-in apps were removed." + exit 0 + } + else { + Write-Output "[OK] No built-in apps found. Doing nothing." + exit 0 + } + } +} diff --git a/intune/Proactive Remediations/DellInc-DellCommandUpdate/notes.txt b/intune/Proactive Remediations/DellInc-DellCommandUpdate/notes.txt new file mode 100644 index 0000000..34c910b --- /dev/null +++ b/intune/Proactive Remediations/DellInc-DellCommandUpdate/notes.txt @@ -0,0 +1 @@ +This DellInc.DellCommandUpdate_5.1.31.0_neutral_~_htrsf667h5kn2 version is the AppxPackage removing script \ No newline at end of file diff --git a/intune/Proactive Remediations/DellInc-DellDigitalDelivery/Detect-DellDigitalDelivery.ps1 b/intune/Proactive Remediations/DellInc-DellDigitalDelivery/Detect-DellDigitalDelivery.ps1 new file mode 100644 index 0000000..7759c1e --- /dev/null +++ b/intune/Proactive Remediations/DellInc-DellDigitalDelivery/Detect-DellDigitalDelivery.ps1 @@ -0,0 +1,86 @@ +<# +.SYNOPSIS + This script is used to detect and remediate built-in apps in Windows 11. + +.DESCRIPTION + The script provides two main functionalities: detection and remediation of built-in apps. By default, the script runs in detection mode, but it can also be configured to perform remediation. + The list of built-in apps to be detected and remediated can be customized by modifying the $appxPackageList array in the script. + +.NOTES + File Name : Detect-Remediate-DellDigitalDelivery.ps1 + Author : Martin Bengtsson + Blog : https://www.imab.dk +#> + +param ( + [bool]$runDetection = $true, + [bool]$runRemediation = $false +) + +begin { + $appxPackageList = @( + "DellInc.DellDigitalDelivery" + ) + function Test-InstalledAppxPackages() { + foreach ($app in $appxPackageList) { + try { + $isAppInstalled = Get-AppxPackage -Name $app -ErrorAction SilentlyContinue + if (-NOT[string]::IsNullOrEmpty($isAppInstalled)) { + Write-Output $app + } + } + catch { + Write-Output "[ERROR] Failed to retrieve the installed app: $_" + } + } + } + function Remove-InstalledAppxPackages() { + param ( + [string]$appxPackage + ) + try { + Get-AppxPackage -Name $appxPackage | Remove-AppxPackage + $global:remediationSuccess += $true + } + catch { + Write-Output "[ERROR] Failed to remove the app: $_" + } + } + if ($runDetection -eq $false) { + Write-Output "[ERROR] runDetection cannot be set to false. As a minimum runDetection must be set to true." + exit 1 + } +} + +process { + $global:needsRemediation = @() + $global:remediationSuccess = @() + $installedAppxPackages = Test-InstalledAppxPackages + if ($runDetection -eq $true) { + if (-NOT[string]::IsNullOrEmpty($installedAppxPackages)) { + foreach ($app in $installedAppxPackages) { + $global:needsRemediation += $true + if ($runRemediation -eq $true) { + Remove-InstalledAppxPackages -appxPackage $app + } + } + } + } +} + +end { + if ($runDetection -eq $true) { + if ($global:needsRemediation -contains $true -AND $global:remediationSuccess -notcontains $true) { + Write-Output "[WARNING] Built-in apps found installed. Remediation is needed." + exit 1 + } + elseif ($global:remediationSuccess -contains $true -AND $global:remediationSuccess -notcontains $false) { + Write-Output "[OK] Remediation was run successfully. Built-in apps were removed." + exit 0 + } + else { + Write-Output "[OK] No built-in apps found. Doing nothing." + exit 0 + } + } +} diff --git a/intune/Proactive Remediations/DellInc-DellDigitalDelivery/Install.bat b/intune/Proactive Remediations/DellInc-DellDigitalDelivery/Install.bat new file mode 100644 index 0000000..9769e81 --- /dev/null +++ b/intune/Proactive Remediations/DellInc-DellDigitalDelivery/Install.bat @@ -0,0 +1,4 @@ +@echo off +pushd %~dp0 +powershell.exe -ExecutionPolicy Bypass -File "Detect-Remediate-Windows-11-Built-In-Apps.ps1" +popd \ No newline at end of file diff --git a/intune/Proactive Remediations/DellInc-DellDigitalDelivery/Remediate-DellDigitalDelivery.ps1 b/intune/Proactive Remediations/DellInc-DellDigitalDelivery/Remediate-DellDigitalDelivery.ps1 new file mode 100644 index 0000000..4154ff1 --- /dev/null +++ b/intune/Proactive Remediations/DellInc-DellDigitalDelivery/Remediate-DellDigitalDelivery.ps1 @@ -0,0 +1,86 @@ +<# +.SYNOPSIS + This script is used to detect and remediate built-in apps in Windows 11. + +.DESCRIPTION + The script provides two main functionalities: detection and remediation of built-in apps. By default, the script runs in detection mode, but it can also be configured to perform remediation. + The list of built-in apps to be detected and remediated can be customized by modifying the $appxPackageList array in the script. + +.NOTES + File Name : Detect-Remediate-DellDigitalDelivery.ps1 + Author : Martin Bengtsson + Blog : https://www.imab.dk +#> + +param ( + [bool]$runDetection = $true, + [bool]$runRemediation = $true +) + +begin { + $appxPackageList = @( + "DellInc.DellDigitalDelivery" + ) + function Test-InstalledAppxPackages() { + foreach ($app in $appxPackageList) { + try { + $isAppInstalled = Get-AppxPackage -Name $app -ErrorAction SilentlyContinue + if (-NOT[string]::IsNullOrEmpty($isAppInstalled)) { + Write-Output $app + } + } + catch { + Write-Output "[ERROR] Failed to retrieve the installed app: $_" + } + } + } + function Remove-InstalledAppxPackages() { + param ( + [string]$appxPackage + ) + try { + Get-AppxPackage -Name $appxPackage | Remove-AppxPackage + $global:remediationSuccess += $true + } + catch { + Write-Output "[ERROR] Failed to remove the app: $_" + } + } + if ($runDetection -eq $false) { + Write-Output "[ERROR] runDetection cannot be set to false. As a minimum runDetection must be set to true." + exit 1 + } +} + +process { + $global:needsRemediation = @() + $global:remediationSuccess = @() + $installedAppxPackages = Test-InstalledAppxPackages + if ($runDetection -eq $true) { + if (-NOT[string]::IsNullOrEmpty($installedAppxPackages)) { + foreach ($app in $installedAppxPackages) { + $global:needsRemediation += $true + if ($runRemediation -eq $true) { + Remove-InstalledAppxPackages -appxPackage $app + } + } + } + } +} + +end { + if ($runDetection -eq $true) { + if ($global:needsRemediation -contains $true -AND $global:remediationSuccess -notcontains $true) { + Write-Output "[WARNING] Built-in apps found installed. Remediation is needed." + exit 1 + } + elseif ($global:remediationSuccess -contains $true -AND $global:remediationSuccess -notcontains $false) { + Write-Output "[OK] Remediation was run successfully. Built-in apps were removed." + exit 0 + } + else { + Write-Output "[OK] No built-in apps found. Doing nothing." + exit 0 + } + } +} diff --git a/intune/Proactive Remediations/DellInc-DellDigitalDelivery/notes.txt b/intune/Proactive Remediations/DellInc-DellDigitalDelivery/notes.txt new file mode 100644 index 0000000..cd8650c --- /dev/null +++ b/intune/Proactive Remediations/DellInc-DellDigitalDelivery/notes.txt @@ -0,0 +1 @@ +This DellInc.DellDigitalDelivery_5.2.0.0_neutral_~_htrsf667h5kn2 is the AppxPackage removing script \ No newline at end of file diff --git a/intune/Proactive Remediations/DellInc-DellOptimizer/Detect-DellOptimizer.ps1 b/intune/Proactive Remediations/DellInc-DellOptimizer/Detect-DellOptimizer.ps1 new file mode 100644 index 0000000..2bab9bd --- /dev/null +++ b/intune/Proactive Remediations/DellInc-DellOptimizer/Detect-DellOptimizer.ps1 @@ -0,0 +1,86 @@ +<# +.SYNOPSIS + This script is used to detect and remediate built-in apps in Windows 11. + +.DESCRIPTION + The script provides two main functionalities: detection and remediation of built-in apps. By default, the script runs in detection mode, but it can also be configured to perform remediation. + The list of built-in apps to be detected and remediated can be customized by modifying the $appxPackageList array in the script. + +.NOTES + File Name : Detect-Remediate-DellOptimizer.ps1 + Author : Martin Bengtsson + Blog : https://www.imab.dk +#> + +param ( + [bool]$runDetection = $true, + [bool]$runRemediation = $false +) + +begin { + $appxPackageList = @( + "DellInc.DellOptimizer" + ) + function Test-InstalledAppxPackages() { + foreach ($app in $appxPackageList) { + try { + $isAppInstalled = Get-AppxPackage -Name $app -ErrorAction SilentlyContinue + if (-NOT[string]::IsNullOrEmpty($isAppInstalled)) { + Write-Output $app + } + } + catch { + Write-Output "[ERROR] Failed to retrieve the installed app: $_" + } + } + } + function Remove-InstalledAppxPackages() { + param ( + [string]$appxPackage + ) + try { + Get-AppxPackage -Name $appxPackage | Remove-AppxPackage + $global:remediationSuccess += $true + } + catch { + Write-Output "[ERROR] Failed to remove the app: $_" + } + } + if ($runDetection -eq $false) { + Write-Output "[ERROR] runDetection cannot be set to false. As a minimum runDetection must be set to true." + exit 1 + } +} + +process { + $global:needsRemediation = @() + $global:remediationSuccess = @() + $installedAppxPackages = Test-InstalledAppxPackages + if ($runDetection -eq $true) { + if (-NOT[string]::IsNullOrEmpty($installedAppxPackages)) { + foreach ($app in $installedAppxPackages) { + $global:needsRemediation += $true + if ($runRemediation -eq $true) { + Remove-InstalledAppxPackages -appxPackage $app + } + } + } + } +} + +end { + if ($runDetection -eq $true) { + if ($global:needsRemediation -contains $true -AND $global:remediationSuccess -notcontains $true) { + Write-Output "[WARNING] Built-in apps found installed. Remediation is needed." + exit 1 + } + elseif ($global:remediationSuccess -contains $true -AND $global:remediationSuccess -notcontains $false) { + Write-Output "[OK] Remediation was run successfully. Built-in apps were removed." + exit 0 + } + else { + Write-Output "[OK] No built-in apps found. Doing nothing." + exit 0 + } + } +} diff --git a/intune/Proactive Remediations/DellInc-DellOptimizer/Remediate-DellOptimizer.ps1 b/intune/Proactive Remediations/DellInc-DellOptimizer/Remediate-DellOptimizer.ps1 new file mode 100644 index 0000000..831f9bd --- /dev/null +++ b/intune/Proactive Remediations/DellInc-DellOptimizer/Remediate-DellOptimizer.ps1 @@ -0,0 +1,86 @@ +<# +.SYNOPSIS + This script is used to detect and remediate built-in apps in Windows 11. + +.DESCRIPTION + The script provides two main functionalities: detection and remediation of built-in apps. By default, the script runs in detection mode, but it can also be configured to perform remediation. + The list of built-in apps to be detected and remediated can be customized by modifying the $appxPackageList array in the script. + +.NOTES + File Name : Detect-Remediate-DellOptimizer.ps1 + Author : Martin Bengtsson + Blog : https://www.imab.dk +#> + +param ( + [bool]$runDetection = $true, + [bool]$runRemediation = $true +) + +begin { + $appxPackageList = @( + "DellInc.DellOptimizer" + ) + function Test-InstalledAppxPackages() { + foreach ($app in $appxPackageList) { + try { + $isAppInstalled = Get-AppxPackage -Name $app -ErrorAction SilentlyContinue + if (-NOT[string]::IsNullOrEmpty($isAppInstalled)) { + Write-Output $app + } + } + catch { + Write-Output "[ERROR] Failed to retrieve the installed app: $_" + } + } + } + function Remove-InstalledAppxPackages() { + param ( + [string]$appxPackage + ) + try { + Get-AppxPackage -Name $appxPackage | Remove-AppxPackage + $global:remediationSuccess += $true + } + catch { + Write-Output "[ERROR] Failed to remove the app: $_" + } + } + if ($runDetection -eq $false) { + Write-Output "[ERROR] runDetection cannot be set to false. As a minimum runDetection must be set to true." + exit 1 + } +} + +process { + $global:needsRemediation = @() + $global:remediationSuccess = @() + $installedAppxPackages = Test-InstalledAppxPackages + if ($runDetection -eq $true) { + if (-NOT[string]::IsNullOrEmpty($installedAppxPackages)) { + foreach ($app in $installedAppxPackages) { + $global:needsRemediation += $true + if ($runRemediation -eq $true) { + Remove-InstalledAppxPackages -appxPackage $app + } + } + } + } +} + +end { + if ($runDetection -eq $true) { + if ($global:needsRemediation -contains $true -AND $global:remediationSuccess -notcontains $true) { + Write-Output "[WARNING] Built-in apps found installed. Remediation is needed." + exit 1 + } + elseif ($global:remediationSuccess -contains $true -AND $global:remediationSuccess -notcontains $false) { + Write-Output "[OK] Remediation was run successfully. Built-in apps were removed." + exit 0 + } + else { + Write-Output "[OK] No built-in apps found. Doing nothing." + exit 0 + } + } +} diff --git a/intune/Proactive Remediations/DellInc-DellOptimizer/notes.txt b/intune/Proactive Remediations/DellInc-DellOptimizer/notes.txt new file mode 100644 index 0000000..02e672c --- /dev/null +++ b/intune/Proactive Remediations/DellInc-DellOptimizer/notes.txt @@ -0,0 +1 @@ +This DellInc.DellOptimizer_2024.327.925.0_neutral_~_htrsf667h5kn2 is the AppxPackage removing script \ No newline at end of file diff --git a/intune/Proactive Remediations/DellInc-DellSupportAssistforPCs/Detect-DellSupportAssistforPCs.ps1 b/intune/Proactive Remediations/DellInc-DellSupportAssistforPCs/Detect-DellSupportAssistforPCs.ps1 new file mode 100644 index 0000000..3817a31 --- /dev/null +++ b/intune/Proactive Remediations/DellInc-DellSupportAssistforPCs/Detect-DellSupportAssistforPCs.ps1 @@ -0,0 +1,86 @@ +<# +.SYNOPSIS + This script is used to detect and remediate built-in apps in Windows 11. + +.DESCRIPTION + The script provides two main functionalities: detection and remediation of built-in apps. By default, the script runs in detection mode, but it can also be configured to perform remediation. + The list of built-in apps to be detected and remediated can be customized by modifying the $appxPackageList array in the script. + +.NOTES + File Name : Detect-Remediate-DellSupportAssistforPCs.ps1 + Author : Martin Bengtsson + Blog : https://www.imab.dk +#> + +param ( + [bool]$runDetection = $true, + [bool]$runRemediation = $false +) + +begin { + $appxPackageList = @( + "DellInc.DellSupportAssistforPCs" + ) + function Test-InstalledAppxPackages() { + foreach ($app in $appxPackageList) { + try { + $isAppInstalled = Get-AppxPackage -Name $app -ErrorAction SilentlyContinue + if (-NOT[string]::IsNullOrEmpty($isAppInstalled)) { + Write-Output $app + } + } + catch { + Write-Output "[ERROR] Failed to retrieve the installed app: $_" + } + } + } + function Remove-InstalledAppxPackages() { + param ( + [string]$appxPackage + ) + try { + Get-AppxPackage -Name $appxPackage | Remove-AppxPackage + $global:remediationSuccess += $true + } + catch { + Write-Output "[ERROR] Failed to remove the app: $_" + } + } + if ($runDetection -eq $false) { + Write-Output "[ERROR] runDetection cannot be set to false. As a minimum runDetection must be set to true." + exit 1 + } +} + +process { + $global:needsRemediation = @() + $global:remediationSuccess = @() + $installedAppxPackages = Test-InstalledAppxPackages + if ($runDetection -eq $true) { + if (-NOT[string]::IsNullOrEmpty($installedAppxPackages)) { + foreach ($app in $installedAppxPackages) { + $global:needsRemediation += $true + if ($runRemediation -eq $true) { + Remove-InstalledAppxPackages -appxPackage $app + } + } + } + } +} + +end { + if ($runDetection -eq $true) { + if ($global:needsRemediation -contains $true -AND $global:remediationSuccess -notcontains $true) { + Write-Output "[WARNING] Built-in apps found installed. Remediation is needed." + exit 1 + } + elseif ($global:remediationSuccess -contains $true -AND $global:remediationSuccess -notcontains $false) { + Write-Output "[OK] Remediation was run successfully. Built-in apps were removed." + exit 0 + } + else { + Write-Output "[OK] No built-in apps found. Doing nothing." + exit 0 + } + } +} diff --git a/intune/Proactive Remediations/DellInc-DellSupportAssistforPCs/Remediate-DellSupportAssistforPCs.ps1 b/intune/Proactive Remediations/DellInc-DellSupportAssistforPCs/Remediate-DellSupportAssistforPCs.ps1 new file mode 100644 index 0000000..f089027 --- /dev/null +++ b/intune/Proactive Remediations/DellInc-DellSupportAssistforPCs/Remediate-DellSupportAssistforPCs.ps1 @@ -0,0 +1,86 @@ +<# +.SYNOPSIS + This script is used to detect and remediate built-in apps in Windows 11. + +.DESCRIPTION + The script provides two main functionalities: detection and remediation of built-in apps. By default, the script runs in detection mode, but it can also be configured to perform remediation. + The list of built-in apps to be detected and remediated can be customized by modifying the $appxPackageList array in the script. + +.NOTES + File Name : Detect-Remediate-DellSupportAssistforPCs.ps1 + Author : Martin Bengtsson + Blog : https://www.imab.dk +#> + +param ( + [bool]$runDetection = $true, + [bool]$runRemediation = $true +) + +begin { + $appxPackageList = @( + "DellInc.DellSupportAssistforPCs" + ) + function Test-InstalledAppxPackages() { + foreach ($app in $appxPackageList) { + try { + $isAppInstalled = Get-AppxPackage -Name $app -ErrorAction SilentlyContinue + if (-NOT[string]::IsNullOrEmpty($isAppInstalled)) { + Write-Output $app + } + } + catch { + Write-Output "[ERROR] Failed to retrieve the installed app: $_" + } + } + } + function Remove-InstalledAppxPackages() { + param ( + [string]$appxPackage + ) + try { + Get-AppxPackage -Name $appxPackage | Remove-AppxPackage + $global:remediationSuccess += $true + } + catch { + Write-Output "[ERROR] Failed to remove the app: $_" + } + } + if ($runDetection -eq $false) { + Write-Output "[ERROR] runDetection cannot be set to false. As a minimum runDetection must be set to true." + exit 1 + } +} + +process { + $global:needsRemediation = @() + $global:remediationSuccess = @() + $installedAppxPackages = Test-InstalledAppxPackages + if ($runDetection -eq $true) { + if (-NOT[string]::IsNullOrEmpty($installedAppxPackages)) { + foreach ($app in $installedAppxPackages) { + $global:needsRemediation += $true + if ($runRemediation -eq $true) { + Remove-InstalledAppxPackages -appxPackage $app + } + } + } + } +} + +end { + if ($runDetection -eq $true) { + if ($global:needsRemediation -contains $true -AND $global:remediationSuccess -notcontains $true) { + Write-Output "[WARNING] Built-in apps found installed. Remediation is needed." + exit 1 + } + elseif ($global:remediationSuccess -contains $true -AND $global:remediationSuccess -notcontains $false) { + Write-Output "[OK] Remediation was run successfully. Built-in apps were removed." + exit 0 + } + else { + Write-Output "[OK] No built-in apps found. Doing nothing." + exit 0 + } + } +} diff --git a/intune/Proactive Remediations/DellInc-DellSupportAssistforPCs/notes.txt b/intune/Proactive Remediations/DellInc-DellSupportAssistforPCs/notes.txt new file mode 100644 index 0000000..354c7fc --- /dev/null +++ b/intune/Proactive Remediations/DellInc-DellSupportAssistforPCs/notes.txt @@ -0,0 +1 @@ +This DellInc.DellSupportAssistforPCs_4.0.15.0_x64__htrsf667h5kn2 is the AppxPackage removing script \ No newline at end of file diff --git a/intune/Proactive Remediations/Detect Wifi Band Preference/Detect_PreferredBand.ps1 b/intune/Proactive Remediations/Detect Wifi Band Preference/Detect_PreferredBand.ps1 new file mode 100644 index 0000000..ba726c0 --- /dev/null +++ b/intune/Proactive Remediations/Detect Wifi Band Preference/Detect_PreferredBand.ps1 @@ -0,0 +1,18 @@ +$null = $AdapterBandPreference +$Adapter = "Wi-Fi" +$AdapterProperty = "Preferred Band" +$DisplayValue = "2. Prefer 2.4GHz band" + +Try { + $AdapterBandPreference = Get-NetAdapterAdvancedProperty -Name $Adapter -DisplayName $AdapterProperty + If ($AdapterBandPreference.DisplayValue -eq $DisplayValue){ + Write-Output "Compliant" + Exit 0 + } + Write-Warning "Not Compliant" + Exit 1 +} +Catch { + Write-Warning "Not Compliant" + Exit 1 +} \ No newline at end of file diff --git a/intune/Proactive Remediations/Detect Wifi Band Preference/Remediate_PreferredBand.ps1 b/intune/Proactive Remediations/Detect Wifi Band Preference/Remediate_PreferredBand.ps1 new file mode 100644 index 0000000..b9bda85 --- /dev/null +++ b/intune/Proactive Remediations/Detect Wifi Band Preference/Remediate_PreferredBand.ps1 @@ -0,0 +1,19 @@ +$null = $AdapterBandPreference +$Adapter = "Wi-Fi" +$AdapterProperty = "Preferred Band" +$DisplayValue = "2. Prefer 2.4GHz band" + +Try { + Set-NetAdapterAdvancedProperty -Name $Adapter -DisplayName $AdapterProperty -DisplayValue $DisplayValue + $AdapterBandPreference = Get-NetAdapterAdvancedProperty -Name $Adapter -DisplayName $AdapterProperty + If ($AdapterBandPreference.DisplayValue -eq $DisplayValue){ + Write-Output "Compliant" + Exit 0 + } + Write-Warning "Not Compliant" + Exit 1 +} +Catch { + Write-Warning "Not Compliant" + Exit 1 +} \ No newline at end of file diff --git a/intune/Proactive Remediations/Detect-Remediate-mDNS/Detection.ps1 b/intune/Proactive Remediations/Detect-Remediate-mDNS/Detection.ps1 new file mode 100644 index 0000000..d4d01d5 --- /dev/null +++ b/intune/Proactive Remediations/Detect-Remediate-mDNS/Detection.ps1 @@ -0,0 +1,10 @@ +$Reg = Get-ItemProperty -Path 'HKLM:\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters' -Name "EnableMDNS" -ErrorAction SilentlyContinue +if ($Reg -eq $Null){ + + Write-host "IPv6 prefix reg is not identified " + Exit 1 +} +else { + Write-Host "IPv6 prefix is identified" + Exit 0 +} diff --git a/intune/Proactive Remediations/Detect-Remediate-mDNS/Remediation.ps1 b/intune/Proactive Remediations/Detect-Remediate-mDNS/Remediation.ps1 new file mode 100644 index 0000000..9a47808 --- /dev/null +++ b/intune/Proactive Remediations/Detect-Remediate-mDNS/Remediation.ps1 @@ -0,0 +1,9 @@ +$Path = "HKLM:\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters" +$Name = "EnableMDNS" +$Type = "DWORD" +$Value = 0 + + +New-ItemProperty -Path $Path -Name $Name -PropertyType $Type -Value $Value -ErrorAction SilentlyContinue + +Set-ItemProperty -Path $Path -Name $Name -Type $Type -Value $Value -ErrorAction SilentlyContinue diff --git a/intune/Proactive Remediations/Detect-TenantAccessKey/Detect-TenantAccessKey.ps1 b/intune/Proactive Remediations/Detect-TenantAccessKey/Detect-TenantAccessKey.ps1 new file mode 100644 index 0000000..6630db2 --- /dev/null +++ b/intune/Proactive Remediations/Detect-TenantAccessKey/Detect-TenantAccessKey.ps1 @@ -0,0 +1,8 @@ +$TenantAssociationKey = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\cloud\office\16.0\Common\officesvcmanager" -name TenantAssociationKey).TenantAssociationKey +$desiredkeyvalue = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL2lkZW50aXR5L2NsYWltcy90ZW5hbnRpZCI6IjM0MjYxOWUwLTRhOWEtNDJlNC1hNjZmLTFmZjljODVkMDhkNiIsImFwcGlkIjoiZDM1OTBlZDYtNTJiMy00MTAyLWFlZmYtYWFkMjI5MmFiMDFjIiwiaXNzIjoiSXNzdWVyIiwiYXVkIjoiQXVkaWVuY2UifQ.D_YXC2f5Zy1ahkVMsAqViF98_B3M4yZ_ZTMIIPAZM6U" +if ($TenantAssociationKey = $desiredkeyvalue) { + return 0 +} +else { + return 1 +} \ No newline at end of file diff --git a/intune/Proactive Remediations/Disable LLMNR/Detect_LLMNR.ps1 b/intune/Proactive Remediations/Disable LLMNR/Detect_LLMNR.ps1 new file mode 100644 index 0000000..89155fa --- /dev/null +++ b/intune/Proactive Remediations/Disable LLMNR/Detect_LLMNR.ps1 @@ -0,0 +1,18 @@ +$Path = "HKLM:\Software\policies\Microsoft\Windows NT\DNSClient" +$Name = "EnableMulticast" +$Type = "DWORD" +$Value = 0 + +Try { + $Registry = Get-ItemProperty -Path $Path -Name $Name -ErrorAction Stop | Select-Object -ExpandProperty $Name + If ($Registry -eq $Value){ + Write-Output "Compliant" + Exit 0 + } + Write-Warning "Not Compliant" + Exit 1 +} +Catch { + Write-Warning "Not Compliant" + Exit 1 +} \ No newline at end of file diff --git a/intune/Proactive Remediations/Disable LLMNR/Remediate_LLMNR.ps1 b/intune/Proactive Remediations/Disable LLMNR/Remediate_LLMNR.ps1 new file mode 100644 index 0000000..177541a --- /dev/null +++ b/intune/Proactive Remediations/Disable LLMNR/Remediate_LLMNR.ps1 @@ -0,0 +1,15 @@ +$Path1 ="HKLM:\Software\policies\Microsoft\Windows NT" +$Path = "HKLM:\Software\policies\Microsoft\Windows NT\DNSClient" +$Name = "EnableMulticast" +$Type = "DWORD" +$Value = 0 + + +$DNSclient = (Get-ItemProperty $path1).psobject.properties.name -contains "dnsclient" + +If ($DNSclient -eq $false) + { + New-Item -Path $Path + } + +Set-ItemProperty -Path $Path -Name $Name -Type $Type -Value $Value \ No newline at end of file diff --git a/intune/Proactive Remediations/Disable Netbios/Remediate_NetBios.ps1 b/intune/Proactive Remediations/Disable Netbios/Remediate_NetBios.ps1 new file mode 100644 index 0000000..20b5a10 --- /dev/null +++ b/intune/Proactive Remediations/Disable Netbios/Remediate_NetBios.ps1 @@ -0,0 +1,6 @@ +$Path = "HKLM:\SYSTEM\CurrentControlSet\services\NetBT\Parameters\Interfaces\tcpip*" +$Name = "NetbiosOptions" +$Type = "DWORD" +$Value = 2 + +Set-ItemProperty -Path $Path -Name $Name -Type $Type -Value $Value \ No newline at end of file diff --git a/intune/Proactive Remediations/Disable Netbios/detect_NetBios.ps1 b/intune/Proactive Remediations/Disable Netbios/detect_NetBios.ps1 new file mode 100644 index 0000000..2518af7 --- /dev/null +++ b/intune/Proactive Remediations/Disable Netbios/detect_NetBios.ps1 @@ -0,0 +1,34 @@ +$Path = "HKLM:\SYSTEM\CurrentControlSet\services\NetBT\Parameters\Interfaces\tcpip*" +$Name = "NetbiosOptions" +$Type = "DWORD" +$Value = 2 + +Try { + $Registry = Get-ItemProperty -Path $Path -Name $Name -ErrorAction Stop | Select-Object -ExpandProperty $Name + $Counter = 0 + Foreach ($Entry in $Registry ) + { + If ($Entry -eq $Value) + { + $Counter+=0 + } + else + { + $Counter+=1 + } + } + if($Counter -eq 0) + { + Write-Output "Compliant" + Exit 0 + } + else + { + Write-Warning "Not Compliant" + exit 1 + } +} +Catch { + Write-Warning "Not Compliant" + Exit 1 +} \ No newline at end of file diff --git a/intune/Proactive Remediations/GP Issues/detect.ps1 b/intune/Proactive Remediations/GP Issues/detect.ps1 new file mode 100644 index 0000000..c7aa757 --- /dev/null +++ b/intune/Proactive Remediations/GP Issues/detect.ps1 @@ -0,0 +1,2 @@ +$GPLogs = $env:LOCALAPPDATA+"\Palo alto networks\GlobalProtect\PANGPA.log" +$logs = (Get-Content $GPLogs) | ConvertTo-Xml \ No newline at end of file diff --git a/intune/Proactive Remediations/MEM_RemoveSccmClient-main/Detect_SCCMclient.ps1 b/intune/Proactive Remediations/MEM_RemoveSccmClient-main/Detect_SCCMclient.ps1 new file mode 100644 index 0000000..caff1bc --- /dev/null +++ b/intune/Proactive Remediations/MEM_RemoveSccmClient-main/Detect_SCCMclient.ps1 @@ -0,0 +1,131 @@ +<# + +.Description + Script to detect if there is any trace of SCCM agent. + Will check for CcmExec service and registry keys for services, SMS Certs, and MDM Authority. + +.Notes + Source: https://github.com/robertomoir/remove-sccm/blob/master/remove-sccmagent.ps1 + Source: https://www.optimizationcore.com/deployment/sccm-client-complete-remove-uninstall-powershell-script/ + Source: https://jamesachambers.com/remove-microsoft-sccm-by-force/ + Source: https://github.com/ChadSimmons/Scripts/blob/default/ConfigMgr/Troubleshooting/Remove-ConfigMgrClient.ps1 + +#> + +#region Settings + +$Error.Clear() +$Result = 0 +$DetectSummary = "" + +#New lines, easier to read Agentexecutor Log file. +Write-Host "`n`n" + +#endregion Settings + +#region Functions +Function Test-IfServiceExistExit1 { + + Param + ( + [string]$ServiceName + ) + + $DetectSummary = "" + + $Service = Get-Service -Name $ServiceName -ErrorAction SilentlyContinue + + If ($null -eq $Service) { + Write-Host "Service $ServiceName was not found." + } + else { + Write-Warning "Service $ServiceName exists." + if (-not ($DetectSummary -eq "")) { $DetectSummary += ", " } + $DetectSummary += "$ServiceName service exists" + return 1, $DetectSummary + } + return 0, $DetectSummary +} + +Function Test-IfRegKeyExistExit1 { + + Param + ( + [string]$RegKeyPath + ) + + $DetectSummary = "" + + $RegKey = Get-Item -Path $RegKeyPath -ErrorAction SilentlyContinue + + if ($null -eq $RegKey) { + Write-Host "Registry Key $RegKeyPath was not found." + } + else { + Write-Warning "$RegKeyPath exists." + if (-not ($DetectSummary -eq "")) { $DetectSummary += ", " } + $DetectSummary += "$RegKeyPath exists" + return 1, $DetectSummary + } + return 0, $DetectSummary +} + +#endregion Functions + +#region Main + +#Look for the services related to SCCM client. +$Services = ("CcmExec", "CCMSetup", "smstsmgr", "CmRcService") + +foreach ($Serv in $Services) { + # Verify that services do not exist + $result, $serviceSummary = Test-IfServiceExistExit1 $Serv + if ($result -eq 1) { + $Result = 1 + } + $DetectSummary += $serviceSummary +} + +#Verify that all registry keys from SCCM agent do not exist. +$RegServicesPath = "HKLM:\SYSTEM\CurrentControlSet\Services" +$RegSoftwarePath = "HKLM:\SOFTWARE\Microsoft" +$RegSoftwareWowPath = "HKLM:\SOFTWARE\Wow6432Node\Microsoft" +$RegSmsCertsPath = "HKLM:\SOFTWARE\Microsoft\SystemCertificates\SMS\Certificates" + +$RegServices = ( + "$RegServicesPath\CcmExec", + "$RegServicesPath\CCMSetup", + "$RegServicesPath\smstsmgr", + "$RegServicesPath\CmRcService", + "$RegSoftwarePath\CCM", + "$RegSoftwarePath\CCMSetup", + "$RegSoftwarePath\SMS", + "$RegSoftwarePath\DeviceManageabilityCSP", + "$RegSoftwareWowPath\CCM", + "$RegSoftwareWowPath\CCMSetup", + "$RegSoftwareWowPath\SMS", + "$RegSmsCertsPath\*" + ) + +foreach ($RegService in $RegServices) { + # Verify that Registry Keys do not exist + $result, $regKeySummary = Test-IfRegKeyExistExit1 $RegService + if ($result -eq 1) { + $Result = 1 + } + $DetectSummary += $regKeySummary +} + +#New lines, easier to read Agentexecutor Log file. +Write-Host "`n`n" + +# Return result +if ($Result -eq 0) { + Write-Host "OK $([datetime]::Now) : SCCM not found." + Exit 0 +} else { + Write-Host "WARNING $([datetime]::Now) : $DetectSummary" + Exit 1 +} + +#endregion Main diff --git a/intune/Proactive Remediations/MEM_RemoveSccmClient-main/Fix_SCCMclient.ps1 b/intune/Proactive Remediations/MEM_RemoveSccmClient-main/Fix_SCCMclient.ps1 new file mode 100644 index 0000000..9fc269c --- /dev/null +++ b/intune/Proactive Remediations/MEM_RemoveSccmClient-main/Fix_SCCMclient.ps1 @@ -0,0 +1,612 @@ +<# + +.Description + Script to remove SCCM agent from PCs + + Completly based on James Chambers and Chad Simmons powershell scripts to remove the SCCM agent. + Updated with other scripts and testing. + + $ccmpath is path to SCCM Agent's own uninstall routine. + +.Notes + + Script created or based on the following: + + Source: https://github.com/robertomoir/remove-sccm/blob/master/remove-sccmagent.ps1 + Source: https://www.optimizationcore.com/deployment/sccm-client-complete-remove-uninstall-powershell-script/ + Source: https://jamesachambers.com/remove-microsoft-sccm-by-force/ + Source: https://github.com/ChadSimmons/Scripts/blob/default/ConfigMgr/Troubleshooting/Remove-ConfigMgrClient.ps1 + +#> + +#region Functions + +function Test-IsAdmin { + <# + .SYNOPSIS + Checks if the current user has administrative privileges. + + .DESCRIPTION + Function determines whether the current user has administrative privileges by attempting to create a new WindowsPrincipal object and checking the IsInRole method for the "Administrator" role. + If the check fails, it throws an exception indicating the lack of administrative privileges. + + .EXAMPLE + Test-IsAdmin + If the current user has administrative privileges, the function completes without any output. If not, it throws an exception. + + .NOTES + This function should be called at the beginning of scripts that require administrative privileges to ensure proper execution. + + #> + + try { + # Create a new WindowsPrincipal object for the current user + $currentUser = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent()) + + # Check if the current user is in the "Administrators" role + if (-not $currentUser.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { + throw "Script needs to run with Administrative privileges." + } + } catch { + throw "Must be run with Administrative priviliges." + } +} + +function Stop-WinService { + <# + .SYNOPSIS + Stops a specified Windows service if it exists and is running. + + .DESCRIPTION + Function checks if a specified Windows service exists and retrieves its status. If the service is running, + it attempts to stop it. Includes error handling to catch and throw any issues encountered, with specific messages + for services that do not exist. + + .PARAMETER ServiceName + The name of the Windows service to stop. + + .EXAMPLE + Stop-WinService -ServiceName "wuauserv" + Attempts to stop the Windows Update service if it exists and is running. + + .NOTES + This function requires administrative privileges to stop Windows services. + #> + + param ( + [Parameter(Mandatory = $true)] + [string]$ServiceName + ) + + try { + # Check if the service exists + $service = Get-Service -Name $ServiceName -ErrorAction SilentlyContinue + + if ($null -eq $service) { + throw "Service '$ServiceName' does not exist." + } + + # Check if the service is running + if ($service.Status -eq 'Running') { + # Attempt to stop the service + Write-Host "Stopping service '$ServiceName'..." + Stop-Service -Name $ServiceName -Force -ErrorAction Stop + Write-Host "Service '$ServiceName' stopped successfully." + } else { + Write-Host "Service '$ServiceName' is not running." + } + } catch { + throw "$_" + } +} + +function Remove-RegKey { + <# + .SYNOPSIS + Deletes a specified registry key and its subkeys. + + .DESCRIPTION + This function removes a specified registry key from the Windows Registry, including all its subkeys and values. + It includes error handling to catch and throw any issues encountered during the operation. + + .PARAMETER RegKeyPath + The path of the registry key to delete. + + .EXAMPLE + Remove-RegKey -RegKeyPath "HKLM:\SOFTWARE\MyApp" + Deletes the "MyApp" key and all its subkeys and values from the HKEY_LOCAL_MACHINE\SOFTWARE path. + + .NOTES + This function requires administrative privileges to modify the Windows Registry. + #> + + param ( + [Parameter(Mandatory = $true)] + [string]$RegKeyPath + ) + + try { + # Check if the registry key exists + if (Test-Path -Path $RegKeyPath) { + # Attempt to remove the registry key + Write-Host "Removing registry key '$RegKeyPath'..." + Remove-Item -Path $RegKeyPath -Recurse -Force -Confirm:$false -ErrorAction Stop + Write-Host "Registry key '$RegKeyPath' removed successfully." + } else { + Write-Host "Registry key '$RegKeyPath' does not exist." + } + } catch { + throw "Error removing registry key '$RegKeyPath'" + } +} + +function Clear-Files { + <# + .SYNOPSIS + Deletes specified files or folders, including subdirectories, and takes ownership if necessary. + + .DESCRIPTION + This function iterates through an array of file paths, taking ownership of each file or directory and then deleting it. + It ensures both files and subdirectories are removed, handling any errors encountered during the process. + + .PARAMETER FilePaths + An array of file paths to delete. These can be files or directories. + + .EXAMPLE + $filesToDelete = @("C:\Temp\File1.txt", "C:\Temp\Folder1") + Clear-Files -FilePaths $filesToDelete + + .NOTES + This function requires administrative privileges to take ownership and delete files or directories. + #> + param ( + [string[]]$FilePaths + ) + + foreach ($FilePath in $FilePaths) { + try { + # Take ownership of the file or folder + $null = takeown.exe /F "$FilePath" /R /A /D Y 2>&1 + + # Delete the file or folder, including subdirectories + Remove-Item -Path $FilePath -Force -Recurse -ErrorAction Stop + + Write-Host "Successfully deleted: $FilePath" + } catch { + Write-Host "Error deleting $($FilePath)" + } + } +} + +function Remove-WmiNamespace { + <# + .SYNOPSIS + Removes a specified WMI namespace. + + .DESCRIPTION + This function checks if a specified WMI namespace exists and removes it if found. It uses CIM (Common Information Model) cmdlets + to query and delete the WMI namespace. Errors are handled silently to ensure smooth execution. + + .PARAMETER WmiName + The name of the WMI namespace to be removed. + + .PARAMETER WmiNameSpace + The parent namespace where the specified WMI namespace resides. + + .EXAMPLE + Remove-WmiNamespace -WmiName "ccm" -WmiNameSpace "root\ccm" + + .NOTES + Ensure the script runs with administrative privileges to modify WMI namespaces. + + .SOURCE + References: + - https://learn.microsoft.com/en-us/powershell/scripting/overview?view=powershell-7.1 + - https://docs.microsoft.com/en-us/powershell/scripting/learn/deep-dives/everything-about-powershell-cim-cmdlets?view=powershell-7.1 + + #> + param ( + [string]$WmiName, + [string]$WmiNameSpace + ) + + try { + # Query for the specified WMI namespace + $WmiRepository = Get-CimInstance -query "SELECT * FROM __Namespace WHERE Name='$WmiName'" -Namespace "$WmiNameSpace" -ErrorAction SilentlyContinue + + # Check if the namespace exists + if ($null -ne $WmiRepository) { + Write-Host "Found WMI Repository $WmiName, removing..." + + # Remove the WMI namespace + Get-CimInstance -query "SELECT * FROM __Namespace WHERE Name='$WmiName'" -Namespace "$WmiNameSpace" | Remove-CimInstance -Confirm:$false -ErrorAction SilentlyContinue + } + else { + Write-Host "WMI Repository $WmiName not found" + } + } + catch { + throw "Error udpating WMI namespace." + } +} + + +function Verify-SccmClientDelete { + <# + .SYNOPSIS + Verifies the deletion of the SCCM client by checking for the absence of specific services and files. + + .DESCRIPTION + Checks if the SCCM (System Center Configuration Manager) client has been successfully deleted from the system. + It does this by verifying the absence of the SCCM client service (`CcmExec`) and the SCCM setup file (`ccmsetup.exe`). + If neither the service nor the setup file is found, the deletion is considered successful. + If either the service or the setup file still exists, appropriate warnings are issued, and the function sets an exit code indicating failure. + + .PARAMETER None + + .EXAMPLE + $exitCode = Verify-SccmClientDelete + Write-Host "Exit Code: $exitCode" + + .NOTES + This function requires administrative privileges to check the existence of services and files. + Ensure that the script is run with appropriate permissions to avoid errors. + + #> + # Variables to store the SCCM service name and file path + $SccmService = "CcmExec" + $SccmFilePath = "$Env:WinDir\ccmsetup\ccmsetup.exe" + $ExitCode = 0 + + try { + # Attempt to retrieve the SCCM service + $CCMexecService = Get-Service -Name $SccmService -ErrorAction SilentlyContinue + # Attempt to retrieve the SCCM setup file + $CCMexecSetupFile = Get-Item -Path $SccmFilePath -ErrorAction SilentlyContinue + + # Check if both the service and the setup file do not exist + if (($null -eq $CCMexecService) -and ($null -eq $CCMexecSetupFile)) { + # SCCM Client deletion confirmed. + Write-Host "Confirmation. SCCM client service does not exist!" + } + else { + # Check if the SCCM service still exists + if ($null -ne $CCMexecService) { + # Set exit code for existing service + $ExitCode = 90 # 0x431 ERROR_SERVICE_EXISTS / The specified service already exists. + Write-Warning "Service $CCMexecService still exists, completing with failure $ExitCode" + } + + # Check if the SCCM setup file still exists + if ($null -ne $CCMexecSetupFile) { + # Set exit code for existing file + $ExitCode = 91 # The specified file still exists. + Write-Warning "File $CCMexecSetupFile still exists, completing with failure $ExitCode" + } + } + } + catch { + # Handle any errors that occur during the check + throw "Error verifying SCCM client deletion." + } + + # Return the exit code + return $ExitCode +} + +function Start-CompleteIntuneSync { + <# + .SYNOPSIS + Initiates an Intune sync session and verifies its completion through Event Viewer logs. + + .DESCRIPTION + This function performs an Intune sync by creating and starting an MDM session using Windows.Management.MdmSessionManager. + It waits for 60 seconds to allow the sync process to initiate. It then checks for specific events in the Event Viewer + to confirm the sync's start and completion: Looks for events 208 and 209 in the "Applications and Services Logs > Microsoft > Windows > DeviceManagement-Enterprise-Diagnostics-Provider > Admin". + The function returns the time these events were logged, or "Not found" if the events are not present. + + The Journey: + Initial approach used `intunemanagementextension://syncapp` protocol as suggested by Jannik Reinhard's blog (https://jannikreinhard.com/2022/07/31/summary-of-the-intune-management-extension/). However, this method did not yield consistent results across different devices + Focus then shifted to leveraging the `Windows.Management.MdmSessionManager` class, known for managing Mobile Device Management (MDM) sessions. The use of `[Windows.Management.MdmSessionManager,Windows.Management,ContentType=WindowsRuntime]` to create and start an MDM session was adopted based on documentation and community blogs: + - https://oofhours.com/2024/03/30/when-does-a-windows-client-sync-with-intune/ + + Note: There was an initial attempt to use `Add-Type -AssemblyName "Windows.Management"` which resulted in an error indicating the assembly could not be found. This led to the realization that direct referencing and instantiation of the Windows Runtime type was necessary. + + .REFERENCES + - "Intune Management Extension" by Jannik Reinhard: https://jannikreinhard.com/2022/07/31/summary-of-the-intune-management-extension/ + - "When Does a Windows Client Sync with Intune?" by Michael Niehaus: https://oofhours.com/2024/03/30/when-does-a-windows-client-sync-with-intune/ + + .PARAMETER None + + .EXAMPLE + Start-CompleteIntuneSync + + .NOTES + This function requires administrative privileges to access Event Viewer logs. + Make sure to run this script with appropriate permissions. + #> + + # Initialize variables for event checking + $eventLog = "Microsoft-Windows-DeviceManagement-Enterprise-Diagnostics-Provider/Admin" + $syncStartEventID = 208 + $syncCompleteEventID = 209 + $syncStartTime = Get-Date + + # Log the start of the sync attempt + Write-Host "Starting Intune sync at $syncStartTime" + + try { + # Create and start the MDM session using Windows.Management.MdmSessionManager + [Windows.Management.MdmSessionManager,Windows.Management,ContentType=WindowsRuntime] > $null + $session = [Windows.Management.MdmSessionManager]::TryCreateSession() + $session.StartAsync() | Out-Null + + # Wait for 60 seconds to allow the sync to initiate + Start-Sleep -Seconds 60 + + # Check for the sync start event in Event Viewer + $syncStartEvent = Get-WinEvent -LogName $eventLog | Where-Object { $_.Id -eq $syncStartEventID -and $_.TimeCreated -ge $syncStartTime } + if ($syncStartEvent) { + Write-Host "Sync start event (ID $syncStartEventID) found." + $syncStartEventTime = $syncStartEvent.TimeCreated + } else { + Write-Host "Sync start event (ID $syncStartEventID) not found." + $syncStartEventTime = "Not found" + } + + # Check for the sync complete event in Event Viewer + $syncCompleteEvent = Get-WinEvent -LogName $eventLog | Where-Object { $_.Id -eq $syncCompleteEventID -and $_.TimeCreated -ge $syncStartTime } + if ($syncCompleteEvent) { + Write-Host "Sync complete event (ID $syncCompleteEventID) found." + $syncCompleteEventTime = $syncCompleteEvent.TimeCreated + } else { + Write-Host "Sync complete event (ID $syncCompleteEventID) not found." + $syncCompleteEventTime = "Not found" + } + + # Return details of the sync process + return @{ + SyncStartEvent = $syncStartEventTime + SyncCompleteEvent = $syncCompleteEventTime + SyncStartTime = $syncStartTime + } + } catch { + throw "Error during Intune sync process. " + } +} + +function WriteAndExitWithSummary { + <# + .SYNOPSIS + Writes a summary of the script's execution to the console and then exits the script with a specified status code. + + .DESCRIPTION + The function takes a status code and a summary string as parameters. It writes the summary along with the current date and time to the console using Write-Host. + After writing the summary, it exits the script with the given status code. If the given status code is below 0 (negative) it changes exit status code to 0. + + .PARAMETER StatusCode + The exit status code to be used when exiting the script. + 0: OK + 1: FAIL + Other: WARNING + + .PARAMETER Summary + The summary string that describes the script's execution status. This will be written to the console. + + .EXAMPLE + WriteAndExitWithSummary -StatusCode 0 -Summary "All operations completed successfully." + + .EXAMPLE + WriteAndExitWithSummary -StatusCode 1 -Summary "Error: SCCM client removal failed." + + .NOTES + Last Modified: August 27, 2023 + Author: Manuel Nieto + #> + + param ( + [int]$StatusCode, + [string]$Summary + ) + + # Combine the summary with the current date and time. + $finalSummary = "$([datetime]::Now) = $Summary" + + # Determine the prefix based on the status code. + $prefix = switch ($StatusCode) { + 0 { "OK" } + 1 { "FAIL" } + default { "WARNING" } + } + + # Easier to read in log file + Write-Host "`n`n" + + # Write the final summary to the console. + Write-Host "$prefix $finalSummary" + + # Easier to read in log file + Write-Host "`n`n" + + # Exit the script with the given status code. + if ($StatusCode -lt 0) {$StatusCode = 0} + Exit $StatusCode +} + +#endregion + +#region Main + +# Initialize +$Error.Clear() # Clear any previous errors. +$t = Get-Date # Get current date and time. +$CCMpath = "$Env:WinDir\ccmsetup\ccmsetup.exe" # Path to SCCM setup executable. +$verifyBeginResult # Variable to store beginning SCCM verification result. +$verifyEndResult # Variable to store ending SCCM verification result. +$summary = "" # Initialize summary string. +$StatusCode = 0 # Initialize status code to zero. + +# New lines, easier to read Agentexecutor Log file. +Write-Host "`n`n" +#Log start time. +Write-Host "SCCM Agent cleanup start time: $t" + +try { + #Test Admin rights + Test-IsAdmin + + # Confirm if SCCM client is present. + $verifyBeginResult = Verify-SccmClientDelete + + # Only execute if we have confirmation that SCCM client exists. + if ($verifyBeginResult -gt 0) { + + # Stopping SCCM services. + try { + #Stop SCCM services. + Stop-WinService CcmExec + Stop-WinService ccmsetup + Stop-WinService smstsmgr + Stop-WinService CmRcService + $summary += "SCCM services stopped. " + } catch { + $summary += "Error stopping SCCM services: $_ " + $StatusCode = -2 + } + + # Remove SCCM client. + try { + # Remove SCCM client. + if (Test-Path $CCMpath) { + Write-Host "Found $CCMpath, Uninstalling SCCM agent. `n" + #Start Uninstall, Included -WorkingDirectory to Start-Process cmdlet as Workaround to error when working directory has characters "[" "]" + Start-Process -WorkingDirectory $Env:WinDir -FilePath $CCMpath -ArgumentList "/uninstall" -Wait -NoNewWindow + # wait for exit + $CCMProcess = Get-Process ccmsetup -ErrorAction SilentlyContinue + try { + $CCMProcess.WaitForExit() + } catch {} + $summary += "SCCM client removed. " + } + else { + $summary += "SCCM client not found. " + } + } catch { + $summary += "Error removing SCCM client. " + $StatusCode = -2 + } + + # Removing services from registry + try { + # Remove Services from Registry. + $CurrentPath = "HKLM:\SYSTEM\CurrentControlSet\Services" + Remove-RegKey "$CurrentPath\CcmExec" + Remove-RegKey "$CurrentPath\CCMSetup" + Remove-RegKey "$CurrentPath\smstsmgr" + Remove-RegKey "$CurrentPath\CmRcService" + $summary += "SCCM services removed from registry. " + } catch { + $summary += "Error removing SCCM services from registry: $_. " + $StatusCode = -2 + } + + try { + # Remove SCCM Client from Registry + $CurrentPath = "HKLM:\SOFTWARE\Microsoft" + Remove-RegKey "$CurrentPath\CCM" + Remove-RegKey "$CurrentPath\CCMSetup" + Remove-RegKey "$CurrentPath\SMS" + $CurrentPath = "HKLM:\SOFTWARE\Wow6432Node\Microsoft" + Remove-RegKey "$CurrentPath\CCM" + Remove-RegKey "$CurrentPath\CCMSetup" + Remove-RegKey "$CurrentPath\SMS" + $summary += "SCCM client registry keys removed. " + } catch { + $summary += "Error removing SCCM client registry keys: $_. " + $StatusCode = -2 + } + + try { + # Remove WMI Namespaces + Remove-WmiNamespace "ccm" "root" + Remove-WmiNamespace "sms" "root\cimv2" + $summary += "SCCM WMI namespaces removed. " + } catch { + $summary += "Error removing SCCM WMI namespaces: $_. " + $StatusCode = -2 + } + + try { + # Reset MDM Authority + Write-Host "MDM Authority, reviewing and deleting registry key if necessary" + $CurrentPath = "HKLM:\SOFTWARE\Microsoft" + Remove-RegKey "$CurrentPath\DeviceManageabilityCSP" + $summary += "MDM authority reset. " + } catch { + $summary += "Error resetting MDM authority. " + $StatusCode = -2 + } + + try { + # Remove Folders and Files + $CurrentPath = "$Env:WinDir" + Clear-Files "$CurrentPath\CCM" + Clear-Files "$CurrentPath\ccmsetup" + Clear-Files "$CurrentPath\ccmcache" + Clear-Files "$CurrentPath\SMSCFG.ini" + Clear-Files "$CurrentPath\SMS*.mif" + $summary += "SCCM related files and folders removed. " + } catch { + $summary += "Error removing SCCM files and folders: $_. " + $StatusCode = -2 + } + + try { + # Remove SCCM certificates + $CurrentPath = "HKLM:\SOFTWARE\Microsoft\SystemCertificates\SMS\Certificates" + Remove-RegKey "$CurrentPath\*" + $summary += "SCCM certificates removed. " + } catch { + $summary += "Error removing SCCM certificates: $_. " + $StatusCode = -2 + } + + try { + # Confirm if SCCM client was removed. + $verifyEndResult = Verify-SccmClientDelete + if ($verifyEndResult -eq 0) { + $summary += "SCCM client removal verified. " + } else { + $StatusCode = $verifyEndResult + $summary += "SCCM client removal failed with code $verifyEndResult. " + } + } catch { + $summary += "Error verifying SCCM client removal: $_. " + $StatusCode = -2 + } + + } + +} +catch { + # Log error and set status code to failure + $summary += "Execution Error: $_ " + $StatusCode = 1 +} + +# Perform Intune sync and log the result. Only if no errors. +if ($StatusCode -le 0) { + try { + $syncDetails = Start-CompleteIntuneSync + $summary += "Intune sync request: $($syncDetails.SyncStartTime), Start: $($syncDetails.SyncStartEvent), Completed: $($syncDetails.SyncCompleteEvent). " + } catch { + $summary += "Error during Intune sync. " + } +} + +# Write the summary and exit with the appropriate status code +WriteAndExitWithSummary -StatusCode $StatusCode -Summary $summary + +#Finished! + +#endregion diff --git a/intune/Proactive Remediations/MEM_RemoveSccmClient-main/README.md b/intune/Proactive Remediations/MEM_RemoveSccmClient-main/README.md new file mode 100644 index 0000000..60e4e64 --- /dev/null +++ b/intune/Proactive Remediations/MEM_RemoveSccmClient-main/README.md @@ -0,0 +1,22 @@ +

SCCM Agent remove via Proactive Remediations v1.0

+ +Removes SCCM Client via MEM Intune Proactive Remediation. +I used it to move co-managed devices to Intune managed devices in an environment where SCCM was no longer present. + +This script is based on the original work from the following sources: + + remove-sccmagent.ps1 + Author: Robert M. + source: https://github.com/robertomoir/remove-sccm/blob/master/remove-sccmagent.ps1 + + Remove-ConfigMgrClient.ps1 + Author: Chad Simmons + Source: https://github.com/ChadSimmons/Scripts/blob/default/ConfigMgr/Troubleshooting/Remove-ConfigMgrClient.ps1 + + Remove All Traces of Microsoft SCCM w/ PowerShell (By Force) + Author: James A. chambers + Source: https://jamesachambers.com/remove-microsoft-sccm-by-force/ + + SCCM Client Complete Uninstall / Remove + Powershell Script + Source: https://www.optimizationcore.com/deployment/sccm-client-complete-remove-uninstall-powershell-script/ + diff --git a/intune/Proactive Remediations/MS-Remove-DevHome/Detect-DevHome-Built-In-Apps.ps1 b/intune/Proactive Remediations/MS-Remove-DevHome/Detect-DevHome-Built-In-Apps.ps1 new file mode 100644 index 0000000..8b77b8b --- /dev/null +++ b/intune/Proactive Remediations/MS-Remove-DevHome/Detect-DevHome-Built-In-Apps.ps1 @@ -0,0 +1,86 @@ +<# +.SYNOPSIS + This script is used to detect and remediate built-in apps in Windows 11. + +.DESCRIPTION + The script provides two main functionalities: detection and remediation of built-in apps. By default, the script runs in detection mode, but it can also be configured to perform remediation. + The list of built-in apps to be detected and remediated can be customized by modifying the $appxPackageList array in the script. + +.NOTES + File Name : Detect-Remediate-Windows-11-Built-In-Apps.ps1 + Author : Martin Bengtsson + Blog : https://www.imab.dk +#> + +param ( + [bool]$runDetection = $true, + [bool]$runRemediation = $false +) + +begin { + $appxPackageList = @( + "Microsoft.Windows.DevHome" + ) + function Test-InstalledAppxPackages() { + foreach ($app in $appxPackageList) { + try { + $isAppInstalled = Get-AppxPackage -Name $app -ErrorAction SilentlyContinue + if (-NOT[string]::IsNullOrEmpty($isAppInstalled)) { + Write-Output $app + } + } + catch { + Write-Output "[ERROR] Failed to retrieve the installed app: $_" + } + } + } + function Remove-InstalledAppxPackages() { + param ( + [string]$appxPackage + ) + try { + Get-AppxPackage -Name $appxPackage | Remove-AppxPackage + $global:remediationSuccess += $true + } + catch { + Write-Output "[ERROR] Failed to remove the app: $_" + } + } + if ($runDetection -eq $false) { + Write-Output "[ERROR] runDetection cannot be set to false. As a minimum runDetection must be set to true." + exit 1 + } +} + +process { + $global:needsRemediation = @() + $global:remediationSuccess = @() + $installedAppxPackages = Test-InstalledAppxPackages + if ($runDetection -eq $true) { + if (-NOT[string]::IsNullOrEmpty($installedAppxPackages)) { + foreach ($app in $installedAppxPackages) { + $global:needsRemediation += $true + if ($runRemediation -eq $true) { + Remove-InstalledAppxPackages -appxPackage $app + } + } + } + } +} + +end { + if ($runDetection -eq $true) { + if ($global:needsRemediation -contains $true -AND $global:remediationSuccess -notcontains $true) { + Write-Output "[WARNING] Built-in apps found installed. Remediation is needed." + exit 1 + } + elseif ($global:remediationSuccess -contains $true -AND $global:remediationSuccess -notcontains $false) { + Write-Output "[OK] Remediation was run successfully. Built-in apps were removed." + exit 0 + } + else { + Write-Output "[OK] No built-in apps found. Doing nothing." + exit 0 + } + } +} diff --git a/intune/Proactive Remediations/MS-Remove-DevHome/Install.bat b/intune/Proactive Remediations/MS-Remove-DevHome/Install.bat new file mode 100644 index 0000000..20e587c --- /dev/null +++ b/intune/Proactive Remediations/MS-Remove-DevHome/Install.bat @@ -0,0 +1,4 @@ +@echo off +pushd %~dp0 +powershell.exe -ExecutionPolicy Bypass -File "Remediate-DevHome-Built-In-Apps.ps1" +popd \ No newline at end of file diff --git a/intune/Proactive Remediations/MS-Remove-DevHome/Remediate-DevHome-Built-In-Apps.ps1 b/intune/Proactive Remediations/MS-Remove-DevHome/Remediate-DevHome-Built-In-Apps.ps1 new file mode 100644 index 0000000..c63f48e --- /dev/null +++ b/intune/Proactive Remediations/MS-Remove-DevHome/Remediate-DevHome-Built-In-Apps.ps1 @@ -0,0 +1,86 @@ +<# +.SYNOPSIS + This script is used to detect and remediate built-in apps in Windows 11. + +.DESCRIPTION + The script provides two main functionalities: detection and remediation of built-in apps. By default, the script runs in detection mode, but it can also be configured to perform remediation. + The list of built-in apps to be detected and remediated can be customized by modifying the $appxPackageList array in the script. + +.NOTES + File Name : Detect-Remediate-Windows-11-Built-In-Apps.ps1 + Author : Martin Bengtsson + Blog : https://www.imab.dk +#> + +param ( + [bool]$runDetection = $true, + [bool]$runRemediation = $true +) + +begin { + $appxPackageList = @( + "Microsoft.Windows.DevHome" + ) + function Test-InstalledAppxPackages() { + foreach ($app in $appxPackageList) { + try { + $isAppInstalled = Get-AppxPackage -Name $app -ErrorAction SilentlyContinue + if (-NOT[string]::IsNullOrEmpty($isAppInstalled)) { + Write-Output $app + } + } + catch { + Write-Output "[ERROR] Failed to retrieve the installed app: $_" + } + } + } + function Remove-InstalledAppxPackages() { + param ( + [string]$appxPackage + ) + try { + Get-AppxPackage -Name $appxPackage | Remove-AppxPackage + $global:remediationSuccess += $true + } + catch { + Write-Output "[ERROR] Failed to remove the app: $_" + } + } + if ($runDetection -eq $false) { + Write-Output "[ERROR] runDetection cannot be set to false. As a minimum runDetection must be set to true." + exit 1 + } +} + +process { + $global:needsRemediation = @() + $global:remediationSuccess = @() + $installedAppxPackages = Test-InstalledAppxPackages + if ($runDetection -eq $true) { + if (-NOT[string]::IsNullOrEmpty($installedAppxPackages)) { + foreach ($app in $installedAppxPackages) { + $global:needsRemediation += $true + if ($runRemediation -eq $true) { + Remove-InstalledAppxPackages -appxPackage $app + } + } + } + } +} + +end { + if ($runDetection -eq $true) { + if ($global:needsRemediation -contains $true -AND $global:remediationSuccess -notcontains $true) { + Write-Output "[WARNING] Built-in apps found installed. Remediation is needed." + exit 1 + } + elseif ($global:remediationSuccess -contains $true -AND $global:remediationSuccess -notcontains $false) { + Write-Output "[OK] Remediation was run successfully. Built-in apps were removed." + exit 0 + } + else { + Write-Output "[OK] No built-in apps found. Doing nothing." + exit 0 + } + } +} diff --git a/intune/Proactive Remediations/MS-Remove-DevHome/notes.txt b/intune/Proactive Remediations/MS-Remove-DevHome/notes.txt new file mode 100644 index 0000000..121961c --- /dev/null +++ b/intune/Proactive Remediations/MS-Remove-DevHome/notes.txt @@ -0,0 +1 @@ +This New Outlook is the AppxPackage removing script \ No newline at end of file diff --git a/intune/Proactive Remediations/MS-Remove-MicrosoftTeams/Detect-MicrosoftTeams.ps1 b/intune/Proactive Remediations/MS-Remove-MicrosoftTeams/Detect-MicrosoftTeams.ps1 new file mode 100644 index 0000000..33d027d --- /dev/null +++ b/intune/Proactive Remediations/MS-Remove-MicrosoftTeams/Detect-MicrosoftTeams.ps1 @@ -0,0 +1,86 @@ +<# +.SYNOPSIS + This script is used to detect and remediate built-in apps in Windows 11. + +.DESCRIPTION + The script provides two main functionalities: detection and remediation of built-in apps. By default, the script runs in detection mode, but it can also be configured to perform remediation. + The list of built-in apps to be detected and remediated can be customized by modifying the $appxPackageList array in the script. + +.NOTES + File Name : Detect-Remediate-MicrosoftTeams.ps1 + Author : Martin Bengtsson + Blog : https://www.imab.dk +#> + +param ( + [bool]$runDetection = $true, + [bool]$runRemediation = $false +) + +begin { + $appxPackageList = @( + "MicrosoftTeams" + ) + function Test-InstalledAppxPackages() { + foreach ($app in $appxPackageList) { + try { + $isAppInstalled = Get-AppxPackage -Name $app -ErrorAction SilentlyContinue + if (-NOT[string]::IsNullOrEmpty($isAppInstalled)) { + Write-Output $app + } + } + catch { + Write-Output "[ERROR] Failed to retrieve the installed app: $_" + } + } + } + function Remove-InstalledAppxPackages() { + param ( + [string]$appxPackage + ) + try { + Get-AppxPackage -Name $appxPackage | Remove-AppxPackage + $global:remediationSuccess += $true + } + catch { + Write-Output "[ERROR] Failed to remove the app: $_" + } + } + if ($runDetection -eq $false) { + Write-Output "[ERROR] runDetection cannot be set to false. As a minimum runDetection must be set to true." + exit 1 + } +} + +process { + $global:needsRemediation = @() + $global:remediationSuccess = @() + $installedAppxPackages = Test-InstalledAppxPackages + if ($runDetection -eq $true) { + if (-NOT[string]::IsNullOrEmpty($installedAppxPackages)) { + foreach ($app in $installedAppxPackages) { + $global:needsRemediation += $true + if ($runRemediation -eq $true) { + Remove-InstalledAppxPackages -appxPackage $app + } + } + } + } +} + +end { + if ($runDetection -eq $true) { + if ($global:needsRemediation -contains $true -AND $global:remediationSuccess -notcontains $true) { + Write-Output "[WARNING] Built-in apps found installed. Remediation is needed." + exit 1 + } + elseif ($global:remediationSuccess -contains $true -AND $global:remediationSuccess -notcontains $false) { + Write-Output "[OK] Remediation was run successfully. Built-in apps were removed." + exit 0 + } + else { + Write-Output "[OK] No built-in apps found. Doing nothing." + exit 0 + } + } +} diff --git a/intune/Proactive Remediations/MS-Remove-MicrosoftTeams/Install.bat b/intune/Proactive Remediations/MS-Remove-MicrosoftTeams/Install.bat new file mode 100644 index 0000000..9769e81 --- /dev/null +++ b/intune/Proactive Remediations/MS-Remove-MicrosoftTeams/Install.bat @@ -0,0 +1,4 @@ +@echo off +pushd %~dp0 +powershell.exe -ExecutionPolicy Bypass -File "Detect-Remediate-Windows-11-Built-In-Apps.ps1" +popd \ No newline at end of file diff --git a/intune/Proactive Remediations/MS-Remove-MicrosoftTeams/Remediate-MicrosoftTeams.ps1 b/intune/Proactive Remediations/MS-Remove-MicrosoftTeams/Remediate-MicrosoftTeams.ps1 new file mode 100644 index 0000000..c9eebb6 --- /dev/null +++ b/intune/Proactive Remediations/MS-Remove-MicrosoftTeams/Remediate-MicrosoftTeams.ps1 @@ -0,0 +1,86 @@ +<# +.SYNOPSIS + This script is used to detect and remediate built-in apps in Windows 11. + +.DESCRIPTION + The script provides two main functionalities: detection and remediation of built-in apps. By default, the script runs in detection mode, but it can also be configured to perform remediation. + The list of built-in apps to be detected and remediated can be customized by modifying the $appxPackageList array in the script. + +.NOTES + File Name : Detect-Remediate-MicrosoftTeams.ps1 + Author : Martin Bengtsson + Blog : https://www.imab.dk +#> + +param ( + [bool]$runDetection = $true, + [bool]$runRemediation = $true +) + +begin { + $appxPackageList = @( + "MicrosoftTeams" + ) + function Test-InstalledAppxPackages() { + foreach ($app in $appxPackageList) { + try { + $isAppInstalled = Get-AppxPackage -Name $app -ErrorAction SilentlyContinue + if (-NOT[string]::IsNullOrEmpty($isAppInstalled)) { + Write-Output $app + } + } + catch { + Write-Output "[ERROR] Failed to retrieve the installed app: $_" + } + } + } + function Remove-InstalledAppxPackages() { + param ( + [string]$appxPackage + ) + try { + Get-AppxPackage -Name $appxPackage | Remove-AppxPackage + $global:remediationSuccess += $true + } + catch { + Write-Output "[ERROR] Failed to remove the app: $_" + } + } + if ($runDetection -eq $false) { + Write-Output "[ERROR] runDetection cannot be set to false. As a minimum runDetection must be set to true." + exit 1 + } +} + +process { + $global:needsRemediation = @() + $global:remediationSuccess = @() + $installedAppxPackages = Test-InstalledAppxPackages + if ($runDetection -eq $true) { + if (-NOT[string]::IsNullOrEmpty($installedAppxPackages)) { + foreach ($app in $installedAppxPackages) { + $global:needsRemediation += $true + if ($runRemediation -eq $true) { + Remove-InstalledAppxPackages -appxPackage $app + } + } + } + } +} + +end { + if ($runDetection -eq $true) { + if ($global:needsRemediation -contains $true -AND $global:remediationSuccess -notcontains $true) { + Write-Output "[WARNING] Built-in apps found installed. Remediation is needed." + exit 1 + } + elseif ($global:remediationSuccess -contains $true -AND $global:remediationSuccess -notcontains $false) { + Write-Output "[OK] Remediation was run successfully. Built-in apps were removed." + exit 0 + } + else { + Write-Output "[OK] No built-in apps found. Doing nothing." + exit 0 + } + } +} diff --git a/intune/Proactive Remediations/MS-Remove-MicrosoftTeams/notes.txt b/intune/Proactive Remediations/MS-Remove-MicrosoftTeams/notes.txt new file mode 100644 index 0000000..bc26f90 --- /dev/null +++ b/intune/Proactive Remediations/MS-Remove-MicrosoftTeams/notes.txt @@ -0,0 +1 @@ +This MicrosoftTeams version is the AppxPackage removing script \ No newline at end of file diff --git a/intune/Proactive Remediations/MS-Remove-NewOutook/Detect-NewOutlook-Built-In-Apps.ps1 b/intune/Proactive Remediations/MS-Remove-NewOutook/Detect-NewOutlook-Built-In-Apps.ps1 new file mode 100644 index 0000000..694f823 --- /dev/null +++ b/intune/Proactive Remediations/MS-Remove-NewOutook/Detect-NewOutlook-Built-In-Apps.ps1 @@ -0,0 +1,86 @@ +<# +.SYNOPSIS + This script is used to detect and remediate built-in apps in Windows 11. + +.DESCRIPTION + The script provides two main functionalities: detection and remediation of built-in apps. By default, the script runs in detection mode, but it can also be configured to perform remediation. + The list of built-in apps to be detected and remediated can be customized by modifying the $appxPackageList array in the script. + +.NOTES + File Name : Detect-Remediate-Windows-11-Built-In-Apps.ps1 + Author : Martin Bengtsson + Blog : https://www.imab.dk +#> + +param ( + [bool]$runDetection = $true, + [bool]$runRemediation = $false +) + +begin { + $appxPackageList = @( + "Microsoft.OutlookForWindows" + ) + function Test-InstalledAppxPackages() { + foreach ($app in $appxPackageList) { + try { + $isAppInstalled = Get-AppxPackage -Name $app -ErrorAction SilentlyContinue + if (-NOT[string]::IsNullOrEmpty($isAppInstalled)) { + Write-Output $app + } + } + catch { + Write-Output "[ERROR] Failed to retrieve the installed app: $_" + } + } + } + function Remove-InstalledAppxPackages() { + param ( + [string]$appxPackage + ) + try { + Get-AppxPackage -Name $appxPackage | Remove-AppxPackage + $global:remediationSuccess += $true + } + catch { + Write-Output "[ERROR] Failed to remove the app: $_" + } + } + if ($runDetection -eq $false) { + Write-Output "[ERROR] runDetection cannot be set to false. As a minimum runDetection must be set to true." + exit 1 + } +} + +process { + $global:needsRemediation = @() + $global:remediationSuccess = @() + $installedAppxPackages = Test-InstalledAppxPackages + if ($runDetection -eq $true) { + if (-NOT[string]::IsNullOrEmpty($installedAppxPackages)) { + foreach ($app in $installedAppxPackages) { + $global:needsRemediation += $true + if ($runRemediation -eq $true) { + Remove-InstalledAppxPackages -appxPackage $app + } + } + } + } +} + +end { + if ($runDetection -eq $true) { + if ($global:needsRemediation -contains $true -AND $global:remediationSuccess -notcontains $true) { + Write-Output "[WARNING] Built-in apps found installed. Remediation is needed." + exit 1 + } + elseif ($global:remediationSuccess -contains $true -AND $global:remediationSuccess -notcontains $false) { + Write-Output "[OK] Remediation was run successfully. Built-in apps were removed." + exit 0 + } + else { + Write-Output "[OK] No built-in apps found. Doing nothing." + exit 0 + } + } +} diff --git a/intune/Proactive Remediations/MS-Remove-NewOutook/Install.bat b/intune/Proactive Remediations/MS-Remove-NewOutook/Install.bat new file mode 100644 index 0000000..61a9e24 --- /dev/null +++ b/intune/Proactive Remediations/MS-Remove-NewOutook/Install.bat @@ -0,0 +1,4 @@ +@echo off +pushd %~dp0 +powershell.exe -ExecutionPolicy Bypass -File "Remediate-NewOutlook-Built-In-Apps.ps1" +popd \ No newline at end of file diff --git a/intune/Proactive Remediations/MS-Remove-NewOutook/Remediate-NewOutlook-Built-In-Apps.ps1 b/intune/Proactive Remediations/MS-Remove-NewOutook/Remediate-NewOutlook-Built-In-Apps.ps1 new file mode 100644 index 0000000..e6a7afc --- /dev/null +++ b/intune/Proactive Remediations/MS-Remove-NewOutook/Remediate-NewOutlook-Built-In-Apps.ps1 @@ -0,0 +1,86 @@ +<# +.SYNOPSIS + This script is used to detect and remediate built-in apps in Windows 11. + +.DESCRIPTION + The script provides two main functionalities: detection and remediation of built-in apps. By default, the script runs in detection mode, but it can also be configured to perform remediation. + The list of built-in apps to be detected and remediated can be customized by modifying the $appxPackageList array in the script. + +.NOTES + File Name : Detect-Remediate-Windows-11-Built-In-Apps.ps1 + Author : Martin Bengtsson + Blog : https://www.imab.dk +#> + +param ( + [bool]$runDetection = $true, + [bool]$runRemediation = $true +) + +begin { + $appxPackageList = @( + "Microsoft.OutlookForWindows" + ) + function Test-InstalledAppxPackages() { + foreach ($app in $appxPackageList) { + try { + $isAppInstalled = Get-AppxPackage -Name $app -ErrorAction SilentlyContinue + if (-NOT[string]::IsNullOrEmpty($isAppInstalled)) { + Write-Output $app + } + } + catch { + Write-Output "[ERROR] Failed to retrieve the installed app: $_" + } + } + } + function Remove-InstalledAppxPackages() { + param ( + [string]$appxPackage + ) + try { + Get-AppxPackage -Name $appxPackage | Remove-AppxPackage + $global:remediationSuccess += $true + } + catch { + Write-Output "[ERROR] Failed to remove the app: $_" + } + } + if ($runDetection -eq $false) { + Write-Output "[ERROR] runDetection cannot be set to false. As a minimum runDetection must be set to true." + exit 1 + } +} + +process { + $global:needsRemediation = @() + $global:remediationSuccess = @() + $installedAppxPackages = Test-InstalledAppxPackages + if ($runDetection -eq $true) { + if (-NOT[string]::IsNullOrEmpty($installedAppxPackages)) { + foreach ($app in $installedAppxPackages) { + $global:needsRemediation += $true + if ($runRemediation -eq $true) { + Remove-InstalledAppxPackages -appxPackage $app + } + } + } + } +} + +end { + if ($runDetection -eq $true) { + if ($global:needsRemediation -contains $true -AND $global:remediationSuccess -notcontains $true) { + Write-Output "[WARNING] Built-in apps found installed. Remediation is needed." + exit 1 + } + elseif ($global:remediationSuccess -contains $true -AND $global:remediationSuccess -notcontains $false) { + Write-Output "[OK] Remediation was run successfully. Built-in apps were removed." + exit 0 + } + else { + Write-Output "[OK] No built-in apps found. Doing nothing." + exit 0 + } + } +} diff --git a/intune/Proactive Remediations/MS-Remove-NewOutook/notes.txt b/intune/Proactive Remediations/MS-Remove-NewOutook/notes.txt new file mode 100644 index 0000000..121961c --- /dev/null +++ b/intune/Proactive Remediations/MS-Remove-NewOutook/notes.txt @@ -0,0 +1 @@ +This New Outlook is the AppxPackage removing script \ No newline at end of file diff --git a/intune/Proactive Remediations/MS-Remove-QuickAssist/Detect-Windows-11-Built-In-Apps.ps1 b/intune/Proactive Remediations/MS-Remove-QuickAssist/Detect-Windows-11-Built-In-Apps.ps1 new file mode 100644 index 0000000..9b7a564 --- /dev/null +++ b/intune/Proactive Remediations/MS-Remove-QuickAssist/Detect-Windows-11-Built-In-Apps.ps1 @@ -0,0 +1,86 @@ +<# +.SYNOPSIS + This script is used to detect and remediate built-in apps in Windows 11. + +.DESCRIPTION + The script provides two main functionalities: detection and remediation of built-in apps. By default, the script runs in detection mode, but it can also be configured to perform remediation. + The list of built-in apps to be detected and remediated can be customized by modifying the $appxPackageList array in the script. + +.NOTES + File Name : Detect-Remediate-Windows-11-Built-In-Apps.ps1 + Author : Martin Bengtsson + Blog : https://www.imab.dk +#> + +param ( + [bool]$runDetection = $true, + [bool]$runRemediation = $false +) + +begin { + $appxPackageList = @( + "MicrosoftCorporationII.QuickAssist" + ) + function Test-InstalledAppxPackages() { + foreach ($app in $appxPackageList) { + try { + $isAppInstalled = Get-AppxPackage -Name $app -ErrorAction SilentlyContinue + if (-NOT[string]::IsNullOrEmpty($isAppInstalled)) { + Write-Output $app + } + } + catch { + Write-Output "[ERROR] Failed to retrieve the installed app: $_" + } + } + } + function Remove-InstalledAppxPackages() { + param ( + [string]$appxPackage + ) + try { + Get-AppxPackage -Name $appxPackage | Remove-AppxPackage + $global:remediationSuccess += $true + } + catch { + Write-Output "[ERROR] Failed to remove the app: $_" + } + } + if ($runDetection -eq $false) { + Write-Output "[ERROR] runDetection cannot be set to false. As a minimum runDetection must be set to true." + exit 1 + } +} + +process { + $global:needsRemediation = @() + $global:remediationSuccess = @() + $installedAppxPackages = Test-InstalledAppxPackages + if ($runDetection -eq $true) { + if (-NOT[string]::IsNullOrEmpty($installedAppxPackages)) { + foreach ($app in $installedAppxPackages) { + $global:needsRemediation += $true + if ($runRemediation -eq $true) { + Remove-InstalledAppxPackages -appxPackage $app + } + } + } + } +} + +end { + if ($runDetection -eq $true) { + if ($global:needsRemediation -contains $true -AND $global:remediationSuccess -notcontains $true) { + Write-Output "[WARNING] Built-in apps found installed. Remediation is needed." + exit 1 + } + elseif ($global:remediationSuccess -contains $true -AND $global:remediationSuccess -notcontains $false) { + Write-Output "[OK] Remediation was run successfully. Built-in apps were removed." + exit 0 + } + else { + Write-Output "[OK] No built-in apps found. Doing nothing." + exit 0 + } + } +} diff --git a/intune/Proactive Remediations/MS-Remove-QuickAssist/Install.bat b/intune/Proactive Remediations/MS-Remove-QuickAssist/Install.bat new file mode 100644 index 0000000..9769e81 --- /dev/null +++ b/intune/Proactive Remediations/MS-Remove-QuickAssist/Install.bat @@ -0,0 +1,4 @@ +@echo off +pushd %~dp0 +powershell.exe -ExecutionPolicy Bypass -File "Detect-Remediate-Windows-11-Built-In-Apps.ps1" +popd \ No newline at end of file diff --git a/intune/Proactive Remediations/MS-Remove-QuickAssist/Remediate-Windows-11-Built-In-Apps.ps1 b/intune/Proactive Remediations/MS-Remove-QuickAssist/Remediate-Windows-11-Built-In-Apps.ps1 new file mode 100644 index 0000000..90b4d50 --- /dev/null +++ b/intune/Proactive Remediations/MS-Remove-QuickAssist/Remediate-Windows-11-Built-In-Apps.ps1 @@ -0,0 +1,86 @@ +<# +.SYNOPSIS + This script is used to detect and remediate built-in apps in Windows 11. + +.DESCRIPTION + The script provides two main functionalities: detection and remediation of built-in apps. By default, the script runs in detection mode, but it can also be configured to perform remediation. + The list of built-in apps to be detected and remediated can be customized by modifying the $appxPackageList array in the script. + +.NOTES + File Name : Detect-Remediate-Windows-11-Built-In-Apps.ps1 + Author : Martin Bengtsson + Blog : https://www.imab.dk +#> + +param ( + [bool]$runDetection = $true, + [bool]$runRemediation = $true +) + +begin { + $appxPackageList = @( + "MicrosoftCorporationII.QuickAssist" + ) + function Test-InstalledAppxPackages() { + foreach ($app in $appxPackageList) { + try { + $isAppInstalled = Get-AppxPackage -Name $app -ErrorAction SilentlyContinue + if (-NOT[string]::IsNullOrEmpty($isAppInstalled)) { + Write-Output $app + } + } + catch { + Write-Output "[ERROR] Failed to retrieve the installed app: $_" + } + } + } + function Remove-InstalledAppxPackages() { + param ( + [string]$appxPackage + ) + try { + Get-AppxPackage -Name $appxPackage | Remove-AppxPackage + $global:remediationSuccess += $true + } + catch { + Write-Output "[ERROR] Failed to remove the app: $_" + } + } + if ($runDetection -eq $false) { + Write-Output "[ERROR] runDetection cannot be set to false. As a minimum runDetection must be set to true." + exit 1 + } +} + +process { + $global:needsRemediation = @() + $global:remediationSuccess = @() + $installedAppxPackages = Test-InstalledAppxPackages + if ($runDetection -eq $true) { + if (-NOT[string]::IsNullOrEmpty($installedAppxPackages)) { + foreach ($app in $installedAppxPackages) { + $global:needsRemediation += $true + if ($runRemediation -eq $true) { + Remove-InstalledAppxPackages -appxPackage $app + } + } + } + } +} + +end { + if ($runDetection -eq $true) { + if ($global:needsRemediation -contains $true -AND $global:remediationSuccess -notcontains $true) { + Write-Output "[WARNING] Built-in apps found installed. Remediation is needed." + exit 1 + } + elseif ($global:remediationSuccess -contains $true -AND $global:remediationSuccess -notcontains $false) { + Write-Output "[OK] Remediation was run successfully. Built-in apps were removed." + exit 0 + } + else { + Write-Output "[OK] No built-in apps found. Doing nothing." + exit 0 + } + } +} diff --git a/intune/Proactive Remediations/MS-Remove-QuickAssist/notes.txt b/intune/Proactive Remediations/MS-Remove-QuickAssist/notes.txt new file mode 100644 index 0000000..deb41a1 --- /dev/null +++ b/intune/Proactive Remediations/MS-Remove-QuickAssist/notes.txt @@ -0,0 +1 @@ +This QuickAssist version is the AppxPackage removing script \ No newline at end of file diff --git a/intune/Proactive Remediations/TNS_ADMIN/Install.bat b/intune/Proactive Remediations/TNS_ADMIN/Install.bat new file mode 100644 index 0000000..1ef890b --- /dev/null +++ b/intune/Proactive Remediations/TNS_ADMIN/Install.bat @@ -0,0 +1,4 @@ +@echo off +pushd %~dp0 +powershell.exe -ExecutionPolicy Bypass -File "TNS_ADMIN-Detection.ps1" +popd \ No newline at end of file diff --git a/intune/Proactive Remediations/TNS_ADMIN/TNS_ADMIN-Detection.ps1 b/intune/Proactive Remediations/TNS_ADMIN/TNS_ADMIN-Detection.ps1 new file mode 100644 index 0000000..6973620 --- /dev/null +++ b/intune/Proactive Remediations/TNS_ADMIN/TNS_ADMIN-Detection.ps1 @@ -0,0 +1,30 @@ +# Discovery + +# path to the directory that TNS_ADMIN should point towards +# Make sure its the same in both the remediation and discovery scripts +$value = "\\ccx.carecentrix.com\public\oracle" + +try { + + # create the TNS_ADMIN directory if it doesn't exist, no need to use a remediation to do that + if ( (Test-Path -Path $value -ErrorAction stop) -eq $false ) { + Write-Host "$value directory missing" + exit 1 + } + + # check the TNS_ADMIN environmental variable + $TNS_ADMINVar = [System.Environment]::GetEnvironmentVariable('TNS_ADMIN', 'Machine') + if ($TNS_ADMINVar -ne $value) { + Write-Host "failure, TNS_ADMIN is set to $TNS_ADMINVar" + exit 1 + } + + Write-Host "TNS_ADMIN Variables set correctly" + exit 0 + +} +catch { + $errMsg = $_.Exception.Message + Write-Host $errMsg + exit 1 +} \ No newline at end of file diff --git a/intune/Proactive Remediations/TNS_ADMIN/TNS_ADMIN-Remediation.ps1 b/intune/Proactive Remediations/TNS_ADMIN/TNS_ADMIN-Remediation.ps1 new file mode 100644 index 0000000..4beaa99 --- /dev/null +++ b/intune/Proactive Remediations/TNS_ADMIN/TNS_ADMIN-Remediation.ps1 @@ -0,0 +1,24 @@ +# Remediation + +# path to the directory that TNS_ADMIN should point towards +# Make sure its the same in both the remediation and discovery scripts +$value = "\\ccx.carecentrix.com\public\oracle" + +try { + + # create the TNS_ADMIN directory if it doesn't exist + if ( (Test-Path -Path $value) -eq $false ) { + New-Item -Path $value -ItemType Directory + } + + # set the variables + [System.Environment]::SetEnvironmentVariable('TNS_ADMIN','\\ccx.carecentrix.com\public\oracle','Machine') + + Write-Host "TNS_ADMIN Machine variables Changed" + exit 0 +} +catch { + $errMsg = $_.Exception.Message + Write-Host $errMsg + exit 1 +} \ No newline at end of file diff --git a/intune/Proactive Remediations/Tenable-AgentStatus/Remediate-Serverslist.ps1 b/intune/Proactive Remediations/Tenable-AgentStatus/Remediate-Serverslist.ps1 new file mode 100644 index 0000000..9674aad --- /dev/null +++ b/intune/Proactive Remediations/Tenable-AgentStatus/Remediate-Serverslist.ps1 @@ -0,0 +1,12 @@ +$serverlist = Import-Csv '.\intune\Proactive Remediations\Tenable-AgentStatus\servers.csv' + +foreach ($server in $serverlist) { + $serverName = $server.ServerName + $cred = $server.Credential + $session = New-PSSession -ComputerName $serverName -Credential $cred + Invoke-Command -Session $session -ScriptBlock { + param($serverName) + .\intune\Proactive Remediations\Tenable-AgentStatus\remediate-agent.ps1 + } -ArgumentList $serverName + Remove-PSSession -Session $session +} diff --git a/intune/Proactive Remediations/Tenable-AgentStatus/detect.ps1 b/intune/Proactive Remediations/Tenable-AgentStatus/detect.ps1 new file mode 100644 index 0000000..d4e1a87 --- /dev/null +++ b/intune/Proactive Remediations/Tenable-AgentStatus/detect.ps1 @@ -0,0 +1,24 @@ +cd "C:\Program Files\Tenable\Nessus Agent" +$NessusStatus = .\nessuscli agent status +$NessusStatusString = $NessusStatus | out-string + +if ($nessusstatus[2].Contains("disconnected")) { + Write-Host "Nessus Agent is Disconnected and requires remediation "$nessusstatus[2] + exit 1 +} +elseif ($nessusstatus[2].Contains("authentication error")) { + Write-Host "Nessus Agent is in authorization error state and requires remediation "$nessusstatus[2] + exit 1 +} +elseif ($nessusstatus[2].Contains("Not linked to a manager")) { + Write-Host "Nessus Agent is Not linked to a manager "$nessusstatus[2] + exit 1 +} +elseif ($nessusstatus[2].Contains("Link status: Connected to paptennm001.ccx.carecentrix.com:8834")) { + Write-Host "Nessus Agent is connected and healthy "$nessusstatus[2] + exit 0 +} +else { + Write-Host "Nessus Agent in an unknown status "$nessusstatus[2] + exit 1 +} \ No newline at end of file diff --git a/intune/Proactive Remediations/Tenable-AgentStatus/remediate-desktops.ps1 b/intune/Proactive Remediations/Tenable-AgentStatus/remediate-desktops.ps1 new file mode 100644 index 0000000..4e1f2c1 --- /dev/null +++ b/intune/Proactive Remediations/Tenable-AgentStatus/remediate-desktops.ps1 @@ -0,0 +1,54 @@ +cd "C:\Program Files\Tenable\Nessus Agent" +$nessusstatus = .\nessuscli.exe agent status + +$ServiceName = "Tenable Nessus Agent" +Write-Host "Stopping Nessus Agent" +Stop-Service $ServiceName +Start-Sleep -Seconds 5 +$service = (Get-Service -Name $ServiceName -ErrorAction Stop) + +if ($service.Status -eq "Stopped") { + + if ($nessusstatus[2].Contains("disconnected")) { + .\Nessuscli.exe plugins --reset + start-Service $ServiceName + Start-Sleep -Seconds 600 + $pluginstatus = (.\Nessuscli.exe plugins --info) | Out-String + $nessusstatus = .\nessuscli.exe agent status + Write-Host "Plugin Reset and Agent Started: "$nessusstatus[2] + + exit 0 + } + elseif ($nessusstatus[2].Contains("authentication error")) { + .\Nessuscli.exe agent link --key=0f0147f977db9a4ea74c34b2a24221cdac7715a36665525537718f48e5edafd5 --host=paptennm001.ccx.carecentrix.com --port=8834 --groups="Agent - VPN - GlobalProtect" + .\Nessuscli.exe plugins --reset + Start-Service $ServiceName + Start-Sleep -Seconds 600 + $nessusstatus = .\nessuscli.exe agent status + Write-Host "Agent Re-Linked: "$nessusstatus[2] + exit 0 + } + elseif ($nessusstatus[2].Contains("Not linked to a manager")) { + .\Nessuscli.exe agent link --key=0f0147f977db9a4ea74c34b2a24221cdac7715a36665525537718f48e5edafd5 --host=paptennm001.ccx.carecentrix.com --port=8834 --groups="Agent - VPN - GlobalProtect" + Start-Service $ServiceName + Start-Sleep -Seconds 600 + $nessusstatus = .\nessuscli.exe agent status + Write-Host "Agent Re-Linked: "$nessusstatus[2] + exit 0 + } + elseif ($nessusstatus[2].Contains("Connected to paptennm001.ccx.carecentrix.com:8834")) { + Write-Host "Nessus Agent is connected and healthy: "$nessusstatus[2] + Start-Service $ServiceName + exit 0 + } + else { + Write-Host "Unknown Remediation Required: "$nessusstatus[2] + Start-Service $ServiceName + exit 1 + } + +} +else { + Write-Host "Nessus Agent Not Stopped" + exit 1 +} \ No newline at end of file diff --git a/intune/Proactive Remediations/Tenable-AgentStatus/remediate-servers.ps1 b/intune/Proactive Remediations/Tenable-AgentStatus/remediate-servers.ps1 new file mode 100644 index 0000000..79dd0cd --- /dev/null +++ b/intune/Proactive Remediations/Tenable-AgentStatus/remediate-servers.ps1 @@ -0,0 +1,55 @@ + +cd "C:\Program Files\Tenable\Nessus Agent" +$nessusstatus = .\nessuscli.exe agent status + +$ServiceName = "Tenable Nessus Agent" +Write-Host "Stopping Nessus Agent" +Stop-Service $ServiceName +Start-Sleep -Seconds 5 +$service = (Get-Service -Name $ServiceName -ErrorAction Stop) + +if ($service.Status -eq "Stopped") { + + if ($nessusstatus[2].Contains("disconnected")) { + .\Nessuscli.exe plugins --reset + start-Service $ServiceName + Start-Sleep -Seconds 600 + $pluginstatus = (.\Nessuscli.exe plugins --info) | Out-String + $nessusstatus = .\nessuscli.exe agent status + Write-Host "Plugin Reset and Agent Started: "$nessusstatus[2] + + return true + } + elseif ($nessusstatus[2].Contains("authentication error")) { + .\nessuscli.exe agent link --key=0f0147f977db9a4ea74c34b2a24221cdac7715a36665525537718f48e5edafd5 --host=paptennm001.ccx.carecentrix.com --port=8834 --groups="Agent - Windows Servers" + .\Nessuscli.exe plugins --reset + Start-Sleep -Seconds 600 + $nessusstatus = .\nessuscli.exe agent status + Write-Host "Agent Re-Linked: "$nessusstatus[2] + Start-Service $ServiceName + return true + } + elseif ($nessusstatus[2].Contains("Not linked to a manager")) { + .\nessuscli.exe agent link --key=0f0147f977db9a4ea74c34b2a24221cdac7715a36665525537718f48e5edafd5 --host=paptennm001.ccx.carecentrix.com --port=8834 --groups="Agent - Windows Servers" + Start-Service $ServiceName + Start-Sleep -Seconds 600 + $nessusstatus = .\nessuscli.exe agent status + Write-Host "Agent Re-Linked: "$nessusstatus[2] + return true + } + elseif ($nessusstatus[2].Contains("Connected to paptennm001.ccx.carecentrix.com:8834")) { + Write-Host "Nessus Agent is connected and healthy: "$nessusstatus[2] + Start-Service $ServiceName + return true + } + else { + Write-Host "Unknown Remediation Required: "$nessusstatus[2] + Start-Service $ServiceName + return false + } + +} +else { + Write-Host "Nessus Agent Not Stopped" + return false +} diff --git a/intune/Proactive Remediations/Tenable-AgentStatus/servers.csv b/intune/Proactive Remediations/Tenable-AgentStatus/servers.csv new file mode 100644 index 0000000..c0750c9 --- /dev/null +++ b/intune/Proactive Remediations/Tenable-AgentStatus/servers.csv @@ -0,0 +1,64 @@ +DNCRADOPSSQL02 +DNCRANICEAPI01 +DNCRARDSUIR01 +DNCRAREDIS01 +DNCRASECTEST01 +DRAWSDC01 +DRAWSDC02 +FLT2PSQL021 +PAWSZVM01 +PFAX021 +PMDA014 +PMDA017 +PMON005 +PNCRAAPPSQL01 +PNCRABIZSQL11 +PNCRABIZSQL12 +PNCRABIZSQL21 +PNCRABIZSQL22 +PNCRABIZSQLQ11 +PNCRABIZSQLQ21 +PNCRACBAC01 +PNCRACMX01 +PNCRADOPSSQL01 +PNCRADOPSSQL02 +PNCRADOPSSQL03 +PNCRADOPSSQLQ01 +PNCRAEDITAB01 +PNCRAEISSQL01 +PNCRAFSSQL01 +PNCRAMISCSQL01 +PNCRANICEAPI01 +PNCRANICESQL01 +PNCRAPSPT002 +PNCRARDSUIS01 +PNCRASCCMSUP01 +PNCRASPWFE01 +PNCRASSIS02 +PNCRATABL003 +PNCRAVAR03 +PNCRAVB01 +PNCRAVBT01 +PNCRAVDIFS02 +PNCRAVJB01 +PNCRAVPRXY001 +PNCRAVPRXY002 +PNCRAWFM02 +PNCRAWFM05 +PNCRAWFM06 +PSQL026 +PSQL030A +PSQL030B +Q1NCRASSIS02 +QCMX001 +QNCRACMX01 +QNCRARDS11 +QNCRARDSJB03 +QSIS010 +VLANTESTING +VLANTESTING2 +VM-SCCMDANE-01 +VM-SCCMOSD-01 +VM-SCCMOSD-02 +VM-SCCMOSD-03 +VM-SCCMOSD-06 \ No newline at end of file diff --git a/intune/Proactive Remediations/WIndows11-UpgradeRemediation/Detect-Win11.ps1 b/intune/Proactive Remediations/WIndows11-UpgradeRemediation/Detect-Win11.ps1 new file mode 100644 index 0000000..cebea30 --- /dev/null +++ b/intune/Proactive Remediations/WIndows11-UpgradeRemediation/Detect-Win11.ps1 @@ -0,0 +1,23 @@ +Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force +Set-PSRepository -Name PSGallery -InstallationPolicy Trusted +Install-Module pswindowsupdate +Import-Module pswindowsupdate + +$scheduledTaskState = (Get-ScheduledTask -TaskName "PSWindowsUpdate").state + +try { + if (((Get-WindowsUpdate -Title "Windows 11, version 23H2").status -eq "-D-----") -and ($scheduledTaskState.value -ne "Ready")) { + Write-Host "Update Downloaded but not scheduled" + Exit 1 + } + elseif ($scheduledTaskState.value -eq "Ready") { + Write-Host "Update Downloaded and Scheduled" + Exit 0 + } + Write-Host "Not Compliant" + Exit 1 +} +catch { + Write-Host "Not Compliant - Catch" + Exit 1 +} \ No newline at end of file diff --git a/intune/Proactive Remediations/WIndows11-UpgradeRemediation/Remediate-Win11.ps1 b/intune/Proactive Remediations/WIndows11-UpgradeRemediation/Remediate-Win11.ps1 new file mode 100644 index 0000000..2a4f6fd --- /dev/null +++ b/intune/Proactive Remediations/WIndows11-UpgradeRemediation/Remediate-Win11.ps1 @@ -0,0 +1,27 @@ +Import-Module PSWindowsUpdate +if ($null -eq (Get-Module PSWindowsUpdate)) { + Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force + Set-PSRepository -Name PSGallery -InstallationPolicy Trusted + Install-Module pswindowsupdate + Import-Module pswindowsupdate +} +$scheduledTaskState = (Get-ScheduledTask -TaskName "PSWindowsUpdate").state +if ($scheduledTaskState.value -eq "Ready") { + Write-Host "Update Already Scheduled" + Exit 0 +} +else { + # Get-WindowsUpdate -MicrosoftUpdate -Title "Windows 11, version 23H2" -ScheduleJob (get-date((Get-Date).AddDays(1)) -Hour 01 -Minute 0 -Second 0) -Install -AcceptAll -AutoReboot -Verbose +# Monday's Update + Get-WindowsUpdate -MicrosoftUpdate -Title "Windows 11, version 23H2" -ScheduleJob (get-date((get-date 2025-01-23)) -Hour 01 -Minute 0 -Second 0) -Install -AcceptAll -AutoReboot -Verbose + $scheduledTaskState = (Get-ScheduledTask -TaskName "PSWindowsUpdate").state + if ($scheduledTaskState.value -eq "Ready") { + Write-Host "Update Scheduled" + Exit 0 + + else { + Write-Host "Update Failed to Schedule" + Exit 1 + } +} +} \ No newline at end of file diff --git a/intune/Proactive Remediations/Win11 Left Start Menu/Move-Windows11Taskbar-Detection.ps1 b/intune/Proactive Remediations/Win11 Left Start Menu/Move-Windows11Taskbar-Detection.ps1 new file mode 100644 index 0000000..4a6c14d --- /dev/null +++ b/intune/Proactive Remediations/Win11 Left Start Menu/Move-Windows11Taskbar-Detection.ps1 @@ -0,0 +1,47 @@ +<# +Version: 1.0 +Author: Jannik Reinhard (jannikreinhard.com) +Script: Move-Windows11Taskbar +Description: +Change the tastkbar alignment +Release notes: +Version 1.0: Init +#> + + +function Test-RegistryValue { + param ( + [parameter(Mandatory=$true)] + [ValidateNotNullOrEmpty()]$Path, + + [parameter(Mandatory=$true)] + [ValidateNotNullOrEmpty()]$Value + ) + + try { + Get-ItemProperty -Path $Path | Select-Object -ExpandProperty $Value -ErrorAction Stop | Out-Null + return $true + }catch { + return $false + } +} + + +$path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" +$value = "TaskbarAl" + + +if(-not (Get-CimInstance Win32_OperatingSystem -Property *).Caption -like "*Windows 11*"){ + Exit 0 +} + + +if((Test-RegistryValue -Path $path -Value $value)){ + if((Get-ItemProperty -path $path -name $value).TaskbarAl -eq "0"){ + Exit 0 + } +}else { + Exit 1 +} + + diff --git a/intune/Proactive Remediations/Win11 Left Start Menu/Move-Windows11Taskbar-Remediation.ps1 b/intune/Proactive Remediations/Win11 Left Start Menu/Move-Windows11Taskbar-Remediation.ps1 new file mode 100644 index 0000000..2f826a9 --- /dev/null +++ b/intune/Proactive Remediations/Win11 Left Start Menu/Move-Windows11Taskbar-Remediation.ps1 @@ -0,0 +1,41 @@ +<# +Version: 1.0 +Author: Jannik Reinhard (jannikreinhard.com) +Script: Move-Windows11Taskbar +Description: +Change the tastkbar alignment +Release notes: +Version 1.0: Init +#> + + +function Test-RegistryValue { + param ( + [parameter(Mandatory=$true)] + [ValidateNotNullOrEmpty()]$Path, + + [parameter(Mandatory=$true)] + [ValidateNotNullOrEmpty()]$Value + ) + + try { + Get-ItemProperty -Path $Path | Select-Object -ExpandProperty $Value -ErrorAction Stop | Out-Null + return $true + }catch { + return $false + } +} + +$path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" +$value = "TaskbarAl" + +if(Test-Path $path){ + try{ + Set-ItemProperty -Path $path -Name $value -Value 0 -Force + Exit 0 + }catch{ + Exit 1 + } +}else{ + Exit 1 +} diff --git a/intune/SystemRenamer/IntuneWinAppUtil.exe b/intune/SystemRenamer/IntuneWinAppUtil.exe new file mode 100644 index 0000000..5b21dd7 Binary files /dev/null and b/intune/SystemRenamer/IntuneWinAppUtil.exe differ diff --git a/intune/SystemRenamer/LICENSE b/intune/SystemRenamer/LICENSE new file mode 100644 index 0000000..79087f5 --- /dev/null +++ b/intune/SystemRenamer/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Michael Niehaus + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/intune/SystemRenamer/README.md b/intune/SystemRenamer/README.md new file mode 100644 index 0000000..0fb1dc6 --- /dev/null +++ b/intune/SystemRenamer/README.md @@ -0,0 +1,20 @@ +# RenameComputer +Sample app for renaming a Hybrid Azure AD joined (AD-joined) device after an Autopilot deployment. Note that you will probably want to customize the RenameComputer.ps1 script to add your own naming logic, then build a new RenameComputer.intunewin package by running the "makeapp.cmd" file from a command prompt. + +To set up the RenameComputer app in Intune, perform the following steps. + +Add the UpdateOS.intunewin app to Intune and specify the following command line: + +powershell.exe -noprofile -executionpolicy bypass -file .\RenameComputer.ps1 + +To "uninstall" the app, the following can be used (for example, to get the app to re-install): + +cmd.exe /c del %ProgramData%\Microsoft\RenameComputer\RenameComputer.ps1.tag + +Specify the platforms and minimum OS version that you want to support. + +For a detection rule, specify the path and file and "File or folder exists" detection method: + +%ProgramData%\Microsoft\RenameComputer RenameComputer.ps1.tag + +Deploy the app as a required app to an appropriate set of devices. \ No newline at end of file diff --git a/intune/SystemRenamer/RenameComputer.intunewin b/intune/SystemRenamer/RenameComputer.intunewin new file mode 100644 index 0000000..865518f Binary files /dev/null and b/intune/SystemRenamer/RenameComputer.intunewin differ diff --git a/intune/SystemRenamer/RenameComputer/RenameComputer.ps1 b/intune/SystemRenamer/RenameComputer/RenameComputer.ps1 new file mode 100644 index 0000000..87d5775 --- /dev/null +++ b/intune/SystemRenamer/RenameComputer/RenameComputer.ps1 @@ -0,0 +1,154 @@ + +<#PSScriptInfo + +.VERSION 1.0 + +.GUID 3b42d8c8-cda5-4411-a623-90d812a8e29e + +.AUTHOR Michael Niehaus + +.COMPANYNAME Microsoft + +.COPYRIGHT + +.TAGS + +.LICENSEURI + +.PROJECTURI + +.ICONURI + +.EXTERNALMODULEDEPENDENCIES + +.REQUIREDSCRIPTS + +.EXTERNALSCRIPTDEPENDENCIES + +.RELEASENOTES +Version 1.0: Initial version. + +.PRIVATEDATA + +#> + +<# + +.DESCRIPTION + Rename the computer + +#> + +Param() + + +# If we are running as a 32-bit process on an x64 system, re-launch as a 64-bit process +if ("$env:PROCESSOR_ARCHITEW6432" -ne "ARM64") +{ + if (Test-Path "$($env:WINDIR)\SysNative\WindowsPowerShell\v1.0\powershell.exe") + { + & "$($env:WINDIR)\SysNative\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -ExecutionPolicy bypass -File "$PSCommandPath" + Exit $lastexitcode + } +} + +# Create a tag file just so Intune knows this was installed +if (-not (Test-Path "$($env:ProgramData)\Microsoft\RenameComputer")) +{ + Mkdir "$($env:ProgramData)\Microsoft\RenameComputer" +} +Set-Content -Path "$($env:ProgramData)\Microsoft\RenameComputer\RenameComputer.ps1.tag" -Value "Installed" + +# Initialization +$dest = "$($env:ProgramData)\Microsoft\RenameComputer" +if (-not (Test-Path $dest)) +{ + mkdir $dest +} +Start-Transcript "$dest\RenameComputer.log" -Append + +# Make sure we are already domain-joined +$goodToGo = $true +$details = Get-ComputerInfo +if (-not $details.CsPartOfDomain) +{ + Write-Host "Not part of a domain." + $goodToGo = $false +} + +# Make sure we have connectivity +$dcInfo = [ADSI]"LDAP://RootDSE" +if ($dcInfo.dnsHostName -eq $null) +{ + Write-Host "No connectivity to the domain." + $goodToGo = $false +} + +if ($goodToGo) +{ + # Get the new computer name + + #get system serial #: + $SystemSerial = Get-WmiObject win32_bios | select Serialnumber + + #Ignore original naming Convention + #$newName = Invoke-RestMethod -Method GET -Uri "https://generatename.azurewebsites.net/api/HttpTrigger1?prefix=AD-" + + $newName = $SystemSerial.Serialnumber + + # Set the computer name + Write-Host "Renaming computer to $($SystemSerial.Serialnumber)" + Rename-Computer -NewName $SystemSerial.Serialnumber + + # Remove the scheduled task + Disable-ScheduledTask -TaskName "RenameComputer" -ErrorAction Ignore + Unregister-ScheduledTask -TaskName "RenameComputer" -Confirm:$false -ErrorAction Ignore + Write-Host "Scheduled task unregistered." + + # Make sure we reboot if still in ESP/OOBE by reporting a 1641 return code (hard reboot) + if ($details.CsUserName -match "defaultUser") + { + Write-Host "Exiting during ESP/OOBE with return code 1641" + Stop-Transcript + Exit 1641 + } + else { + Write-Host "Initiating a restart in 10 minutes" + & shutdown.exe /g /t 600 /f /c "Restarting the computer due to a computer name change. Save your work." + Stop-Transcript + Exit 0 + } +} +else +{ + # Check to see if already scheduled + $existingTask = Get-ScheduledTask -TaskName "RenameComputer" -ErrorAction SilentlyContinue + if ($existingTask -ne $null) + { + Write-Host "Scheduled task already exists." + Stop-Transcript + Exit 0 + } + + # Copy myself to a safe place if not already there + if (-not (Test-Path "$dest\RenameComputer.ps1")) + { + Copy-Item $PSCommandPath "$dest\RenameComputer.PS1" + } + + # Create the scheduled task action + $action = New-ScheduledTaskAction -Execute "Powershell.exe" -Argument "-NoProfile -ExecutionPolicy bypass -WindowStyle Hidden -File $dest\RenameComputer.ps1" + + # Create the scheduled task trigger + $timespan = New-Timespan -minutes 5 + $triggers = @() + $triggers += New-ScheduledTaskTrigger -Daily -At 9am + $triggers += New-ScheduledTaskTrigger -AtLogOn -RandomDelay $timespan + $triggers += New-ScheduledTaskTrigger -AtStartup -RandomDelay $timespan + + # Register the scheduled task + Register-ScheduledTask -User SYSTEM -Action $action -Trigger $triggers -TaskName "RenameComputer" -Description "RenameComputer" -Force + Write-Host "Scheduled task created." +} + +Stop-Transcript diff --git a/intune/SystemRenamer/SystemRenamer-Remediation/RenameComputer-Detect.ps1 b/intune/SystemRenamer/SystemRenamer-Remediation/RenameComputer-Detect.ps1 new file mode 100644 index 0000000..3b84e59 --- /dev/null +++ b/intune/SystemRenamer/SystemRenamer-Remediation/RenameComputer-Detect.ps1 @@ -0,0 +1,30 @@ +Try { + $details = Get-ComputerInfo + if (-not $details.CsPartOfDomain) { + Write-Output 'Not Domain Joined' + Exit 0 + } + + $serial = Get-WmiObject Win32_bios | Select-Object -ExpandProperty SerialNumber + $newName = $serial + + + + $newName = $newName.Replace(' ', '') + if ($newName.Length -ge 15) { + $newName = $newName.substring(0, 15) + } + + If ($details.CsName -ne $newName) { + Write-Warning "Existing Computer name $($details.CsName) should be $newName" + Exit 1 + } + Else { + Write-Output "Computer has correct name: $($details.CsName)" + Exit 0 + } +} +Catch { + Write-Error $_.Exception + Exit 2000 +} diff --git a/intune/SystemRenamer/SystemRenamer-Remediation/RenameComputer-Remediate.ps1 b/intune/SystemRenamer/SystemRenamer-Remediation/RenameComputer-Remediate.ps1 new file mode 100644 index 0000000..9472202 --- /dev/null +++ b/intune/SystemRenamer/SystemRenamer-Remediation/RenameComputer-Remediate.ps1 @@ -0,0 +1,33 @@ +$domain = 'ccx.carecentrix.com' +$waitTime = '45' + +Try { + + $dcInfo = [ADSI]"LDAP://$domain" + if ($null -eq $dcInfo.Path) { + Write-Error "No connectivity to $domain" + } + + $serial = Get-WmiObject Win32_bios | Select-Object -ExpandProperty SerialNumber + If (Get-WmiObject -Class win32_battery) { + $newName = $serial + } + Else { + $newName = $serial + } + + $newName = $newName.Replace(' ', '') + if ($newName.Length -ge 15) { + $newName = $newName.substring(0, 15) + } + + Rename-Computer -NewName $newName + $waitSeconds = (New-TimeSpan -Minutes $waitTime).TotalSeconds + Write-Host "Initiating a restart in $waitime minutes" + & shutdown.exe /g /t $waitSeconds /f /c "Your system requires are reboot due to a computer name change. Please save your work and either reboot now or your system will reboot in $waitTime minutes." + Write-Output "Computer renamed from $($details.CsName) to $newName" +} +Catch { + Write-Error $_.Exception + Exit 2000 +} \ No newline at end of file diff --git a/intune/SystemRenamer/debug.log b/intune/SystemRenamer/debug.log new file mode 100644 index 0000000..fc794fd --- /dev/null +++ b/intune/SystemRenamer/debug.log @@ -0,0 +1 @@ +[0609/152259.905:ERROR:registration_protocol_win.cc(106)] CreateFile: The system cannot find the file specified. (0x2) diff --git a/intune/SystemRenamer/makeapp.cmd b/intune/SystemRenamer/makeapp.cmd new file mode 100644 index 0000000..4e379e2 --- /dev/null +++ b/intune/SystemRenamer/makeapp.cmd @@ -0,0 +1 @@ +intunewinapputil.exe -c RenameComputer -s RenameComputer.ps1 -o .\ -q