Intune Initial Scripts Backup

This commit is contained in:
2025-04-21 14:21:38 -04:00
commit 71764cd10f
241 changed files with 28218 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
"Server","ClientInstalled","CollectionName"
"W2012A","True","Nabil - Test Collection"
"W2012B","True","Nabil - Test Collection"
1 Server ClientInstalled CollectionName
2 W2012A True Nabil - Test Collection
3 W2012B True Nabil - Test Collection

Binary file not shown.

Binary file not shown.

View File

@@ -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

View File

@@ -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

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -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()

View File

@@ -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

View File

@@ -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
}

View File

@@ -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

View File

@@ -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()

View File

@@ -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()

View File

@@ -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()

View File

@@ -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
}

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -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()

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -0,0 +1,3 @@
"Server","ClientInstalled","CollectionName"
"W2012A","True","Nabil - Test Collection"
"W2012B","True","Nabil - Test Collection"
1 Server ClientInstalled CollectionName
2 W2012A True Nabil - Test Collection
3 W2012B True Nabil - Test Collection

View File

@@ -0,0 +1,5 @@
 $T = Get-CMDeployment | ? { $_.deploymenttime -gt ((Get-Date).AddDays(-30)) }

View File

@@ -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
<a class="vglnk" href="https://thesysadminchannel.com/get-sccm-software-update-status-powershell" rel="nofollow"><span>https</span><span>://</span><span>thesysadminchannel</span><span>.</span><span>com</span><span>/</span><span>get</span><span>-</span><span>sccm</span><span>-</span><span>software</span><span>-</span><span>update</span><span>-</span><span>status</span><span>-</span><span>powershell</span></a> -
.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

View File

@@ -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

26
dump/SCCM-Tool/test1.ps1 Normal file
View File

@@ -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