Skip to content

Instantly share code, notes, and snippets.

Created June 20, 2016 17:48
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/e58fd278723dc44d8eee9437b3937621 to your computer and use it in GitHub Desktop.
Save anonymous/e58fd278723dc44d8eee9437b3937621 to your computer and use it in GitHub Desktop.
Admin-i-nator
# ==============================================================================================
# ==============================================================================================
# =============================== Admin-i-Nator V2 Update 2 ====================================
# ============= This version has been updated to reflect permission changes with new ===========
# ============= Admin accounts; all account creation tools have been commented out =============
# ==============================================================================================
# ============= Recent Changes: ================
# ============= 16 December 2015 - Added button to install updated flash ================
# ============= 16 December 2015 - Removed Office install option ================
# ==============================================================================================
# ==============================================================================================
# ===================Set up the form ===========================================================
# =============This area is for setting up the elements of the form ============================
# =============All elements will go here =======================================================
# =============Order is: =======================================================
# ============= Form =======================================================
# ============= Listboxes =======================================================
# ============= Textboxes =======================================================
# ============= Buttons =======================================================
# ============= Functions =======================================================
# ==============================================================================================
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
import-module ActiveDirectory
$objForm = New-Object System.Windows.Forms.Form
$objForm.Text = "Admin-i-Nator V2 - Now with more IT-ness"
$objForm.Size = New-Object System.Drawing.Size(600,500)
$objForm.StartPosition = "CenterScreen"
$objForm.KeyPreview = $True
# =========================== End of Initial form creation ====================================
# ==============================================================================================
# ==============================================================================================
# =========================== Listboxes ====================================
# ==============================================================================================
# ==============================================================================================
# =============== Add the listbox containing the Computer accounts =============================
$objComputersListlabel = New-Object System.Windows.Forms.Label
$objComputersListlabel.Location = New-Object System.Drawing.Size(420,40)
$objComputersListlabel.Size = New-Object System.Drawing.Size(140,20)
$objComputersListlabel.Text = "Computers in OU"
$objForm.Controls.Add($objComputersListlabel)
$objComputersListbox = New-Object System.Windows.Forms.Listbox
$objComputersListbox.Location = New-Object System.Drawing.Size(400,60)
$objComputersListbox.Size = New-Object System.Drawing.Size(140,350)
$objForm.Controls.Add($objComputersListbox)
$Computers = Invoke-Expression "Get-ADComputer -Filter * -SearchBase 'OU=Computers,OU=Site,DC=contoso,DC=com'" | Sort-Object
foreach ($item in $Computers)
{
[void] $objComputersListbox.Items.Add($item.name)
}
# ============================= End of Computer Listbox =========================================
# ============================= Add Expired Listbox =========================================
# ==================================== Commented out due to change in account permissions =========
<#
$objExpiredListlabel = New-Object System.Windows.Forms.Label
$objExpiredListlabel.Location = New-Object System.Drawing.Size(45,420)
$objExpiredListlabel.Size = New-Object System.Drawing.Size(140,20)
$objExpiredListlabel.Text = "Expired Accounts in OU"
$objForm.Controls.Add($objExpiredListlabel)
$objExpiredaccountsListbox = New-Object System.Windows.Forms.Listbox
$objExpiredaccountsListbox.Location = New-Object System.Drawing.Size(45,440)
$objExpiredaccountsListbox.Size = New-Object System.Drawing.Size(140,260)
$objForm.Controls.Add($objExpiredaccountsListbox)
$Expiredaccounts = Invoke-Expression "Search-ADAccount -SearchBase 'OU=Users,OU=site,DC=contoso,DC=com' -AccountExpired"
foreach ($item in $Expiredaccounts)
{
[void] $objExpiredaccountsListbox.Items.Add($item.Name)
}
#>
# =================== End of Listbox containing expired accounts ================================
# ===================Add the listbox containing the locked accounts =============================
# ==================================== Commented out due to change in account permissions =========
<#
$objLockedListlabel = New-Object System.Windows.Forms.Label
$objLockedListlabel.Location = New-Object System.Drawing.Size(230,600)
$objLockedListlabel.Size = New-Object System.Drawing.Size(140,20)
$objLockedListlabel.Text = "Locked Accounts in OU"
$objForm.Controls.Add($objLockedListlabel)
$objLockedaccountsListbox = New-Object System.Windows.Forms.Listbox
$objLockedaccountsListbox.Location = New-Object System.Drawing.Size(225,620)
$objLockedaccountsListbox.Size = New-Object System.Drawing.Size(140,80)
$objForm.Controls.Add($objLockedaccountsListbox)
$lockedaccounts = Invoke-Expression "Search-ADAccount -SearchBase 'OU=Users,OU=site,DC=contoso,DC=com' -LockedOut"
foreach ($item in $lockedaccounts)
{
[void] $objLockedaccountsListbox.Items.Add($item.Name)
}
#>
# ============================== End of Locked Accounts Listbox ===============================
# ================Add the listbox containing the Disabled accounts =============================
# ==================================== Commented out due to change in account permissions =========
<#
$objDisabledListlabel = New-Object System.Windows.Forms.Label
$objDisabledListlabel.Location = New-Object System.Drawing.Size(405,420)
$objDisabledListlabel.Size = New-Object System.Drawing.Size(140,20)
$objDisabledListlabel.Text = "Disabled Accounts in OU"
$objForm.Controls.Add($objDisabledListlabel)
$objDisabledaccountsListbox = New-Object System.Windows.Forms.Listbox
$objDisabledaccountsListbox.Location = New-Object System.Drawing.Size(400,440)
$objDisabledaccountsListbox.Size = New-Object System.Drawing.Size(140,260)
$objForm.Controls.Add($objDisabledaccountsListbox)
$disabledaccounts = Invoke-Expression "Search-ADAccount -AccountDisabled -SearchBase 'OU=Users,OU=site,DC=contoso,DC=com'"
foreach ($item in $disabledaccounts)
{
[void] $objDisabledaccountsListbox.Items.Add($item.Name)
}
#>
# ============================ End of Disabled Accounts Listbox ================================
# ==============================================================================================
# ==============================================================================================
# =========================== Buttons ====================================
# ==============================================================================================
# ==============================================================================================
# =========================== Add CMD button =============================================
$CMDButton = New-Object System.Windows.Forms.Button
$CMDButton.Size = New-Object System.Drawing.Size (100,30)
$CMDButton.Location = New-Object System.Drawing.Size (45,60)
$CMDButton.Text = "CMD"
$objForm.Controls.Add($CMDButton)
$CMDButton.Add_Click({computerCMD})
# =========================== End of CMD button ==========================================
# =========================== Add verify User button ==========================================
$VerifyUserButton = New-Object System.Windows.Forms.Button
$VerifyUserButton.Size = New-Object System.Drawing.Size (100,30)
$VerifyUserButton.Location = New-Object System.Drawing.Size (45,100)
$VerifyUserButton.Text = "Verify User"
$objForm.Controls.Add($VerifyUserButton)
$VerifyUserButton.Add_Click({VerifyUser})
# =========================== End of verify User button =======================================
# =========================== Add verify sccm button ==========================================
$VerifySCCMButton = New-Object System.Windows.Forms.Button
$VerifySCCMButton.Size = New-Object System.Drawing.Size (100,30)
$VerifySCCMButton.Location = New-Object System.Drawing.Size (45,140)
$VerifySCCMButton.Text = "Verify CCM"
$objForm.Controls.Add($VerifySCCMButton)
$VerifySCCMButton.Add_Click({sccmVerify})
# ========================== End of verify sccm button =======================================
# ========================== Add FreeSpace button ==============================================
$FreeSpaceButton = New-Object System.Windows.Forms.Button
$FreeSpaceButton.Size = New-Object System.Drawing.Size (100,30)
$FreeSpaceButton.Location = New-Object System.Drawing.Size (45,220)
$FreeSpaceButton.Text = "Free Space?"
$objForm.Controls.Add($FreeSpaceButton)
$FreeSpaceButton.Add_Click({freeSpaceC})
# ========================== End of FreeSpace button =============================================
# ========================== Add InstallFlash button ==============================================
$InstallFlashButton = New-Object System.Windows.Forms.Button
$InstallFlashButton.Size = New-Object System.Drawing.Size (100,30)
$InstallFlashButton.Location = New-Object System.Drawing.Size (45,260)
$InstallFlashButton.Text = "Install Flash 20"
$objForm.Controls.Add($InstallFlashButton)
$InstallFlashButton.Add_Click({InstallFlash})
# ========================== End of InstallFlash button =============================================
# ========================== Add InstallJava button ==============================================
$InstallJavaButton = New-Object System.Windows.Forms.Button
$InstallJavaButton.Size = New-Object System.Drawing.Size (100,30)
$InstallJavaButton.Location = New-Object System.Drawing.Size (45,300)
$InstallJavaButton.Text = "Install Java 8u71"
$objForm.Controls.Add($InstallJavaButton)
$InstallJavaButton.Add_Click({InstallJava})
# ========================== End of InstallJava button =============================================
# ========================== Add Explore button ===============================================
$ExploreComputerButton = New-Object System.Windows.Forms.Button
$ExploreComputerButton.Size = New-Object System.Drawing.Size (100,30)
$ExploreComputerButton.Location = New-Object System.Drawing.Size (45,180)
$ExploreComputerButton.Text = "Explore"
$objForm.Controls.Add($ExploreComputerButton)
$ExploreComputerButton.Add_Click({computerExplore})
# ========================== End of Explore button =============================================
# ==========================Add Google Earth install button ====================================
$EarthButton = New-Object System.Windows.Forms.Button
$EarthButton.Size = New-Object System.Drawing.Size (100,30)
$EarthButton.Location = New-Object System.Drawing.Size (175,60)
$EarthButton.Text = "Earth"
$objForm.Controls.Add($EarthButton)
$EarthButton.Add_Click({googleEarthInstall})
# =========================== End of Google Earth install Button ===============================
# =========================== Add notepad++ install button ====================================
$NotepadButton = New-Object System.Windows.Forms.Button
$NotepadButton.Size = New-Object System.Drawing.Size (100,30)
$NotepadButton.Location = New-Object System.Drawing.Size (175,100)
$NotepadButton.Text = "Notepad++"
$objForm.Controls.Add($NotepadButton)
$NotepadButton.Add_Click({notepadInstall})
# ========================== End of Notepad++ install button ===================================
# ========================== Add firefox install button ========================================
$FirefoxInstallButton = New-Object System.Windows.Forms.Button
$FirefoxInstallButton.Size = New-Object System.Drawing.Size (100,30)
$FirefoxInstallButton.Location = New-Object System.Drawing.Size (175,140)
$FirefoxInstallButton.Text = "Install Firefox"
$objForm.Controls.Add($FirefoxInstallButton)
$FirefoxInstallButton.Add_Click({firefoxInstall})
# ========================== End of Firefox install button =====================================
# ========================== Add Office install button =========================================
$OfficeButton = New-Object System.Windows.Forms.Button
$OfficeButton.Size = New-Object System.Drawing.Size (100,30)
$OfficeButton.Location = New-Object System.Drawing.Size (175,180)
$OfficeButton.Text = "Office 2013"
$objForm.Controls.Add($OfficeButton)
$OfficeButton.Add_Click({oneNoteInstall})
# ========================== End of Office install button ======================================
# ========================== Add FitProgram button =================================================
$FitProgramButton = New-Object System.Windows.Forms.Button
$FitProgramButton.Size = New-Object System.Drawing.Size (100,30)
$FitProgramButton.Location = New-Object System.Drawing.Size (175,220)
$FitProgramButton.Text = "Install FitProgram"
$objForm.Controls.Add($FitProgramButton)
$FitProgramButton.Add_Click({FitProgramInstall})
# ========================== End of FitProgram button ==============================================
# ========================== Add reinstall sccm button =========================================
$ReinstallSCCMButton = New-Object System.Windows.Forms.Button
$ReinstallSCCMButton.Size = New-Object System.Drawing.Size (100,30)
$ReinstallSCCMButton.Location = New-Object System.Drawing.Size (175,260)
$ReinstallSCCMButton.Text = "Reinstall SCCM"
$objForm.Controls.Add($ReinstallSCCMButton)
$ReinstallSCCMButton.Add_Click({sccmReinstall})
# ========================== End of SCCM button ================================================
# ========================== Add Check updates button =========================================
$CheckUpdatesButton = New-Object System.Windows.Forms.Button
$CheckUpdatesButton.Size = New-Object System.Drawing.Size (100,30)
$CheckUpdatesButton.Location = New-Object System.Drawing.Size (175,300)
$CheckUpdatesButton.Text = "Check Updates"
$objForm.Controls.Add($CheckUpdatesButton)
$CheckUpdatesButton.Add_Click({Get-PendingUpdates})
# ========================== End of Check updates button ================================================
# ========================== Add Create Account Button =========================================
# ==================================== Commented out due to change in account permissions =========
<#
$CreateAccountButton = New-Object System.Windows.Forms.Button
$CreateAccountButton.Size = New-Object System.Drawing.Size (100,30)
$CreateAccountButton.Location = New-Object System.Drawing.Size (190,440)
$CreateAccountButton.Text = "Create Account"
$objForm.Controls.Add($CreateAccountButton)
$CreateAccountButton.Add_Click(
{
Invoke-Expression "c:\temp\itguyV2\CreateAccount.ps1"
}
)
#>
# ============================ End of Create Account Button =====================================
# ========================== Add UDS Button =====================================================
# ==================================== Commented out due to change in account permissions =========
<#
$UDSButton = New-Object System.Windows.Forms.Button
$UDSButton.Size = New-Object System.Drawing.Size (100,30)
$UDSButton.Location = New-Object System.Drawing.Size (190,480)
$UDSButton.Text = "UDS Fix"
$objForm.Controls.Add($UDSButton)
$UDSButton.Add_Click(
{
Invoke-Expression "c:\temp\itguyV2\UDS.ps1"
}
)
#>
# ============================ End of UDS Button ================================================
# ============================ Add unlock button ===============================================
# ==================================== Commented out due to change in account permissions =========
#$UnlockAccountButton = New-Object System.Windows.Forms.Button
#$UnlockAccountButton.Size = New-Object System.Drawing.Size (100,30)
#$UnlockAccountButton.Location = New-Object System.Drawing.Size (235,700)
#$UnlockAccountButton.Text = "Unlock Account"
#$objForm.Controls.Add($UnlockAccountButton)
#$UnlockAccountButton.Add_Click({unlockAccount})
#============================= End of Unlock Button =============================================
# ============================ Add Enable button ===============================================
# ==================================== Commented out due to change in account permissions =========
#$EnableAccountButton = New-Object System.Windows.Forms.Button
#$EnableAccountButton.Size = New-Object System.Drawing.Size (100,30)
#$EnableAccountButton.Location = New-Object System.Drawing.Size (425,700)
#$EnableAccountButton.Text = "Enable Account"
#$objForm.Controls.Add($EnableAccountButton)
#$EnableAccountButton.Add_Click({EnableAccount})
#============================= End of Enable Button =============================================
# ============================ Add Extend Account Button ========================================
# ==================================== Commented out due to change in account permissions =========
#$ExtendAccountButton = New-Object System.Windows.Forms.Button
#$ExtendAccountButton.Size = New-Object System.Drawing.Size (100,30)
#$ExtendAccountButton.Location = New-Object System.Drawing.Size (70,700)
#$ExtendAccountButton.Text = "Extend Account"
#$objForm.Controls.Add($ExtendAccountButton)
#$ExtendAccountButton.Add_Click(
#{
#Invoke-Expression "c:\temp\itguyV2\ExpiredAccounts.ps1"
#}
#)
# ============================ End of Extend Account Button =====================================
# ==============================================================================================
# ==============================================================================================
# =========================== Functions ====================================
# ==============================================================================================
# ==============================================================================================
# =========================== Function to control computer =====================================
function computerControl {
$computer=$objComputersListbox.SelectedItem
$command = "C:\Program Files\Microsoft Configuration Manager Console\AdminUI\bin\i386\RC.exe"
$realComputer = "1 \\$computer"
Start-Process $command $realComputer
}
# =========================== End of Computer Control Function =================================
# =========================== Function to explore computer =====================================
function computerExplore {
$computer=$objComputersListbox.SelectedItem
Invoke-Expression "explorer \\$computer\c$"
}
# =========================== End of Computer Explore Function ================================
# ============================ Function to see free space on c: ===============================
function freeSpaceC {
$computer=$objComputersListbox.Text
$disk = Get-WmiObject Win32_LogicalDisk -ComputerName $computer -Filter "DeviceID='C:'" |
Select-Object Size,FreeSpace
$total = $disk.Size / 1000000000
$free = $disk.FreeSpace / 1000000000
Write-Host Total = $total GB, FreeSpace = $free GB
}
# =========================== End of function to check free space on C: =======================
# =========================== Function to check updates on computer ==============================
Function Get-PendingUpdates {
<#
.SYNOPSIS
Retrieves the updates waiting to be installed from WSUS
.DESCRIPTION
Retrieves the updates waiting to be installed from WSUS
.PARAMETER Computer
Computer or computers to find updates for.
.EXAMPLE
Get-PendingUpdates
Description
-----------
Retrieves the updates that are available to install on the local system
.NOTES
Author: Boe Prox
Date Created: 05Mar2011
#>
#Requires -version 2.0
#[CmdletBinding(
# DefaultParameterSetName = 'computer'
# )]
#param(
# [Parameter(
# Mandatory = $False,
# ParameterSetName = '',
# ValueFromPipeline = $False)]
# [string[]]$Computer
# )
Begin {
$ComputerName=$objComputersListbox.SelectedItem
$scriptdir = { Split-Path $MyInvocation.ScriptName -Parent }
Write-Verbose "Location of function is: $(&$scriptdir)"
$psBoundParameters.GetEnumerator() | ForEach-Object { Write-Verbose "Parameter: $_" }
If (!$PSBoundParameters['computer']) {
Write-Verbose "No computer name given, using local computername"
[string[]]$computer = $Env:Computername
}
#Create container for Report
Write-Verbose "Creating report collection"
$report = @()
}
Process {
Write-Verbose "Computer: $($ComputerName)"
If (Test-Connection -ComputerName $ComputerName -Count 1 -Quiet) {
Try {
#Create Session COM object
Write-Verbose "Creating COM object for WSUS Session"
$updatesession = [activator]::CreateInstance([type]::GetTypeFromProgID("Microsoft.Update.Session",$ComputerName))
}
Catch {
Write-Warning "$($Error[0])"
Break
}
#Configure Session COM Object
Write-Verbose "Creating COM object for WSUS update Search"
$updatesearcher = $updatesession.CreateUpdateSearcher()
#Configure Searcher object to look for Updates awaiting installation
Write-Verbose "Searching for WSUS updates on client"
$searchresult = $updatesearcher.Search("IsInstalled=0")
#Verify if Updates need installed
Write-Verbose "Verifing that updates are available to install"
If ($searchresult.Updates.Count -gt 0) {
#Updates are waiting to be installed
Write-Verbose "Found $($searchresult.Updates.Count) update\s!"
#Cache the count to make the For loop run faster
$ComputerNameount = $searchresult.Updates.Count
#Begin iterating through Updates available for installation
Write-Verbose "Iterating through list of updates"
For ($i=0; $i -lt $ComputerNameount; $i++) {
#Create object holding update
$update = $searchresult.Updates.Item($i)
#Verify that update has been downloaded
Write-Verbose "Checking to see that update has been downloaded"
If ($update.IsDownLoaded -eq "True") {
Write-Verbose "Auditing updates"
$temp = "" | Select Computer, Title, KB,IsDownloaded
$temp.Computer = $ComputerName
$temp.Title = ($update.Title -split('\('))[0]
$temp.KB = (($update.title -split('\('))[1] -split('\)'))[0]
$temp.IsDownloaded = "True"
$report += $temp
}
Else {
Write-Verbose "Update has not been downloaded yet!"
$temp = "" | Select Computer, Title, KB,IsDownloaded
$temp.Computer = $ComputerName
$temp.Title = ($update.Title -split('\('))[0]
$temp.KB = (($update.title -split('\('))[1] -split('\)'))[0]
$temp.IsDownloaded = "False"
$report += $temp
}
}
}
Else {
#Nothing to install at this time
Write-Verbose "No updates to install."
#Create Temp collection for report
$temp = "" | Select Computer, Title, KB,IsDownloaded
$temp.Computer = $ComputerName
$temp.Title = "NA"
$temp.KB = "NA"
$temp.IsDownloaded = "NA"
$report += $temp
}
}
Else {
#Nothing to install at this time
Write-Warning "$($ComputerName): Offline"
#Create Temp collection for report
$temp = "" | Select Computer, Title, KB,IsDownloaded
$temp.Computer = $ComputerName
$temp.Title = "NA"
$temp.KB = "NA"
$temp.IsDownloaded = "NA"
$report += $temp
}
}
End {
Write-Output $report
}
}
# =========================== Function to check updates on computer ==============================
# =========================== Function to check user on computer ==============================
function VerifyUser {
$computer=$objComputersListbox.Text
Get-WmiObject Win32_UserProfile -ComputerName $computer | Sort-Object LastUseTime -Descending | select -First 1 | select LocalPath, @{N="LastUseTime";E={$_.ConvertToDateTime($_.LastUseTime) | Write-Host}}
Get-WmiObject win32_computersystem -computer $computer | select username | Write-Host
}
# ============================ End of VerifyUser Function ====================================
# ============================ Function to reinstall sccm on computer ========================
function sccmReinstall {
$computer=$objComputersListbox.Text
$command = "c:\temp\itguyV2\psexec.exe"
$realComputer = "\\$computer cmd.exe /c c:\temp\ccm_reinstall.bat"
Copy-Item -Path c:\temp\itguyV2\ccm_reinstall.bat -Destination "\\$computer\C$\temp"
Start-Process $command $realComputer
}
# =========================== End of SCCM Reinstall Function ==================================
# =========================== Function to install Firefox =====================================
function firefoxInstall {
$computer=$objComputersListbox.Text
$command = "c:\temp\itguyV2\psexec.exe"
$realComputer = "\\$computer cmd.exe /c c:\temp\installMozillaFirefox40STIGdNIPR.bat"
Copy-Item -Path c:\temp\itguyV2\InstallFiles\Firefox\installMozillaFirefox40STIGdNIPR.bat -Destination "\\$computer\C$\temp"
Copy-Item -Path c:\temp\itguyV2\InstallFiles\Firefox\*.* -Destination "\\$computer\C$\temp"
Start-Process $command $realComputer
}
# ============================ End of function to install Firefox =============================
# =========================== Function to install Java =====================================
function InstallJava {
$computer=$objComputersListbox.Text
$command = "c:\temp\itguyV2\psexec.exe"
$realComputer = "\\$computer cmd.exe /c c:\temp\InstallJava8u71.bat"
Copy-Item -Path c:\temp\itguyV2\InstallFiles\Java8u71\*.* -Destination "\\$computer\C$\temp"
Start-Process $command $realComputer
}
# ============================ End of function to install Java =============================
# =========================== Function to install Flash =====================================
function InstallFlash {
$computer=$objComputersListbox.Text
$command = "c:\temp\itguyV2\psexec.exe"
$realComputer = "\\$computer cmd.exe /c c:\temp\installFlash.bat"
Copy-Item -Path c:\temp\itguyV2\InstallFiles\Flash\installFlash.bat -Destination "\\$computer\C$\temp"
Copy-Item -Path c:\temp\itguyV2\InstallFiles\Flash\*.* -Destination "\\$computer\C$\temp"
Start-Process $command $realComputer
}
# ============================ End of function to install Flash =============================
# ============================ Function to install FitProgram =====================================
function FitProgramInstall {
$computer=$objComputersListbox.Text
$command = "c:\temp\itguyV2\psexec.exe"
$realComputer = "\\$computer cmd.exe /c c:\temp\InstallFitProgram.bat"
Copy-Item -Path c:\temp\itguyV2\InstallFiles\InstallFitProgram.bat -Destination "\\$computer\C$\temp"
Copy-Item -Path c:\temp\itguyV2\InstallFiles\FitProgram\*.* -Destination "\\$computer\C$\temp"
Start-Process $command $realComputer
}
# ============================ End of function to install FitProgram ==============================
# ============================ Function to install GoogleEarth ==============================
function googleEarthInstall {
$computer=$objComputersListbox.Text
$command = "c:\temp\itguyV2\psexec.exe"
$realComputer = "\\$computer cmd.exe /c c:\temp\installGE.bat"
Copy-Item -Path c:\temp\itguyV2\InstallFiles\installGE.bat -Destination "\\$computer\C$\temp"
Copy-Item -Path c:\temp\itguyV2\InstallFiles\GoogleEarth-Win-EC.exe -Destination "\\$computer\C$\temp"
Start-Process $command $realComputer
}
# =========================== End of function to install GoogleEarth ========================
# =========================== Function to install Microsoft Office 2013 ========================
function oneNoteInstall {
$computer=$objComputersListbox.Text
$command = "c:\temp\itguyV2\psexec.exe"
$realComputer = "\\$computer cmd.exe /c c:\temp\betterInstall.bat"
$command2 = "c:\temp\itguyV2\xcopyStuff.bat"
$command2parm = $computer
Start-Process $command2 $command2parm -Wait
Start-Process $command $realComputer
}
# ============================= End of function to install Microsoft Office 2013 =================
# ============================= Function to install notepad++ on computer ========================
function notepadInstall {
$computer=$objComputersListbox.Text
$command = "c:\temp\itguyV2\psexec.exe"
$realComputer = "\\$computer cmd.exe /c c:\temp\installNPP.bat"
Copy-Item -Path c:\temp\itguyV2\InstallFiles\installNPP.bat -Destination "\\$computer\C$\temp"
Copy-Item -Path c:\temp\itguyV2\InstallFiles\npp.6.6.9.Installer.exe -Destination "\\$computer\C$\temp"
Start-Process $command $realComputer
}
# ============================= End of function to install Notepad ++ ===========================
# ============================= Function for Remote CMD ==========================================
function computerCMD {
$computer=$objComputersListbox.Text
$command = "c:\temp\itguyV2\psexec.exe"
$realComputer = "\\$computer cmd.exe"
Start-Process $command $realComputer
}
# ============================= End of function for Remote CMD ==================================
# ============================ Function to verify SCCM on computer ===============================
function sccmVerify {
$computer=$objComputersListbox.Text
if (Test-Connection -cn $computer -count 1 -BufferSize 16 -quiet)
{
#Ensure that updates are being downoaded
if (gci \\$computer\c$\windows\system32\ccm\)
{
$updatesTime = gci \\$computer\c$\windows\system32\ccm\cache | Sort-Object lastWriteTime | select -expand lastWriteTime | Select-Object -Last 1
$updates = (gci \\$computer\c$\windows\system32\ccm\cache).count
#Validates that the client was re-installed today
if ($updates -ge "10" -and ($updatesTime.Date -eq [datetime]::Today))
{
Write-Host "$computer is pulling updates"
#Validates that it's hitting the WUSA server without issues
if (gc \\$computer\c$\windows\system32\ccm\logs\WUAHandler.log | Select-String "Successfully completed synchronous searching of updates.")
{
Write-Host "$computer is currently downloading $updates updates"
#Validates that the updates are successfully being applied
if (gc \\$computer\c$\windows\system32\ccm\logs\WUAHandler.log | Select-String "Installation of updates completed.")
{
"$computer is currently installing updates"
}
else{Write-Host "$computer is attempting to pull $updates updates"}
}
else{Write-Host "$computer is attempting to pull $updates updates"}
}
#If client wasn't reinstalled today then it will validate when the last update was applied.
else
{
$lastReinstall = gci \\$computer\c$\windows\system32\ccmsetup\ccmsetup.log | select -expand lastWriteTime
Write-Host "$computer Client was installed on $lastReinstall and the last update was pulled on $updatesTime"
}
}
}
}
# ==================================== End of function for SCCM Verify =============================
# ==================================== Function to unlock accounts =================================
# ==================================== Commented out due to change in account permissions =========
#function unlockAccount {
#$user = $objLockedaccountsListbox.SelectedItem
#$userSam = Invoke-Expression "Unlock-ADAccount -Identity $user"
# }
# ==================================== Function to re-enable account ==============================
# ==================================== Commented out due to change in account permissions =========
#function enableAccount {
#$user = $objDisabledaccountsListbox.SelectedItem
#$userSam = Invoke-Expression "Enable-ADAccount -Identity $user"
# }
# ==============================================================================================
# ==============================================================================================
# =========================== Activate Form ====================================
# ==============================================================================================
# ==============================================================================================
$objForm.Add_Shown({$objForm.Activate()})
[void] $objForm.ShowDialog()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment