Skip to content

Instantly share code, notes, and snippets.

View DarkAllien's full-sized avatar

Octavian Cordos DarkAllien

View GitHub Profile
[CmdletBinding()]
Param(
[Parameter(Mandatory = $True, Position = 1)]
[string] $ApplicationName
)
Try {
Import-Module "$($ENV:SMS_ADMIN_UI_PATH)\..\ConfigurationManager.psd1" -ErrorAction "Stop"
}
Catch {
Write-host -Message 'Importing SCCM PSH module - Failed!'
<ActionDescription Class="Group" DisplayName="RC Tools" MnemonicDisplayName="RC Tools" Description="Created by Octavian Cordos" SqmDataPoint="53" SelectionMode="Both">
<ShowOn>
<string>ContextMenu</string>
</ShowOn>
<ActionGroups>
<ActionDescription Class ="Executable" DisplayName="Remove old Revisions" MnemonicDisplayName="Remove old Revisions" Description="Not a required value">
<ShowOn>
<string>ContextMenu</string>
</ShowOn>
<Executable>
SELECT [amp].[Name] AS [Antimalware_Policy],
[collection].[CollectionName] AS [Deployed_To],
[amps].[PropertyName],
[col].[query]('.').value('.', 'nvarchar(max)') AS [Property]
FROM [vSMS_AntimalwareConfig] [amps]
RIGHT JOIN [vSMS_AntimalwareSettings] [amp] ON [amp].[ID] = [amps].[SettingsID]
LEFT JOIN [vSMS_AmPolicySummary] [collection] ON [amp].[ID] = [collection].[ClientSettingsID]
CROSS APPLY [XmlValue].[nodes]('/StringArrayXML/Value') AS [Tbl]([col])
WHERE [amps].[XmlValue].value('(/StringArrayXML//Value/node())[1]', 'nvarchar(max)') IS NOT NULL
AND [amps].[xmlvalue] IS NOT NULL
SELECT [s].[Name0],
[s].[Full_Domain_Name0],
[sp].*
FROM [dbo].[v_HS_sqlpatching] [sp]
LEFT JOIN [dbo].[v_R_System] [s] ON [s].[ResourceID] = [sp].[resourceid]
ORDER BY [s].[name0],
[sp].[querytime0];
--or
SELECT [s].[Name0],
[s].[Full_Domain_Name0],
Function Check_MW_Go {
#getting maintenance windows of type 1 (All deployments)
#https://msdn.microsoft.com/library/jj155419.aspx
$CCMServiceWindows = Get-WmiObject -Namespace root\ccm\clientsdk -Class CCM_ServiceWindow -Filter 'Type=1'
$Checker = $false
#parsing maintenance windows to determine if we are in one
foreach ($CCMServiceWindow in $CCMServiceWindows) {
$StartTime = $CCMServiceWindow.StartTime.Substring(0, 12)
$EndTime = $CCMServiceWindow.EndTime.Substring(0, 12)
Function Reboot_Pending {
<#
.SYNOPSIS
The function is checking if there is a reboot pending.
.DESCRIPTION
The function is checking if there is a reboot pending.
#>
$Reboot = $false
$SCCMUpdate = get-wmiobject -query "SELECT * FROM CCM_SoftwareUpdate" -namespace "ROOT\ccm\ClientSDK"
$Reboot = $Reboot -or ([wmiclass]'ROOT\ccm\ClientSDK:CCM_ClientUtilities').DetermineIfRebootPending().RebootPending
Function Check_MW_Go {
#getting maintenance windows of type 1 (All deployments)
#https://msdn.microsoft.com/library/jj155419.aspx
$CCMServiceWindows = Get-WmiObject -Namespace root\ccm\clientsdk -Class CCM_ServiceWindow -Filter 'Type=1'
$Checker = $false
#parsing maintenance windows to determine if we are in one
foreach ($CCMServiceWindow in $CCMServiceWindows) {
$StartTime = $CCMServiceWindow.StartTime.Substring(0, 12)
$EndTime = $CCMServiceWindow.EndTime.Substring(0, 12)
Function Detect_Application_Updates {
$flag = $false
$Applications = Get-CimInstance -ClassName CCM_application -Namespace root\ccm\clientsdk | Select-Object InstallState, Name, ID, ApplicabilityState
foreach ($app in $Applications) {
if (($app.InstallState -ne "Installed") -and ($app.ApplicabilityState -eq "Applicable")) {
if ($app.Name -like "*SQL*") {
$flag = $true
}
}
}
Function Check_MW_Go {
#getting maintenance windows of type 1 (All deployments)
#https://msdn.microsoft.com/library/jj155419.aspx
$CCMServiceWindows = Get-WmiObject -Namespace root\ccm\clientsdk -Class CCM_ServiceWindow -Filter 'Type=1'
$Checker = $false
#parsing maintenance windows to determine if we are in one
foreach ($CCMServiceWindow in $CCMServiceWindows) {
$StartTime = $CCMServiceWindow.StartTime.Substring(0, 12)
$EndTime = $CCMServiceWindow.EndTime.Substring(0, 12)
Function Installation_InProgress {
<#
.SYNOPSIS
The function will check if there are updates in progress
.DESCRIPTION
#>
$Installing = $False
$installing_app = $False
$SCCMUpdate = get-wmiobject -query "SELECT * FROM CCM_SoftwareUpdate" -namespace "ROOT\ccm\ClientSDK"
if (@($SCCMUpdate | Where-Object {($_.EvaluationState -ge 2 -and $_.EvaluationState -le 7) -or $_.EvaluationState -eq 11 }).length -ne 0) { $installing = $true } else { $installing = $false }