Powershell: Test connection on computer port


I use this if telnet is not layin’ around – mainly to test if a computer is reachable on a specific TCPport. try { $portquery = New-Object System.Net.Sockets.TcpClient(“SERVERNAME”, PORTNUMBER) $portquery.Close() return $true } catch [system.exception] { return $false } F

Read More

Powershell: Get file- and foldersize for given path


Quick and dirty little thing I use to get the file- and foldersize for any given path. # Get-pathsize.ps1 # Use: C:scriptsget-pathsize.ps1 -path <your-path> param ( $path ) try { Get-ChildItem $path -Hidden -ErrorAction Stop } catch { $_.exception break } $colItems = (Get-ChildItem $path -recurse | Measure-Object -property length -sum) [int]$size = [math]::round($colItems.sum /1MB,…

Read More

Windows: Server stuck in shutdown after installing patches


One of my servers in my labenvironment refused to gently reboot after installing a ton of patches that I.. uhm.. forgot to install. The “restart-computer -computername DC1” cmdlet wouldn’t do anything, as it returns with : Restart-Computer : Failed to restart the computer dc1 with the following message: A system shutdown is in progress. Figures,…

Read More

Windows: Modify Automatic (Delayed start) windows service thresholds


I wanted to modify the delayed start time threshold for one of my services. If you want to tweak your delaytime, do the following in regedit: 1. Open Regedit. 2. Navigate to your service, in my case it was HKLMSYSTEMCurrentControlSetservicesPlexService You should see that the “DelayedAutostart is set to 1. 3. To increase the default…

Read More

Windows: Autologon for Domain User


I have some machines in my lab at home that, due to heavy testing and other stuff, reboots often. Some of my applications are dependent on the user beeing logged on to function properly – so instead of manually logging on each time my server boots, I fiddled around in registry to make the domain…

Read More

Powershell: Convert string to date


The string: $datestring = “27. januar 2016 04:20:17” Convert this to date: $date = [datetime]::ParseExact(“$datestring”,”dd.MM.yyyy hh:mm:ss”,$null) – F

Read More

SCOM: DeltaSynchronization Error


This error appeared in out environment recently, and didn’t go away until we changed some configuration settings in a config file on all the management servers. Symptoms: EventID 29181 in the OpsMgr eventlog. Newly pushed agents show up as “Not Monitored” Changes you do to a Management Pack, ex. overriding a rule, does not work….

Read More

SCOM: Get Subscriber in Subscription


This little thing will search through, and get all subscribers containing your searchword in any subscription you may have set up in SCOM. param( [String]$searchword ) $sub = Get-SCOMNotificationSubscription | select displayname,torecipients write-host “Searchword: “”$searchword”” exists in the following subscriptions:” foreach ($s in $sub){ $recipient = $s.torecipients.name if ($recipient -like “$searchword”){ write-host “”$s.displayname”” } }…

Read More

SCOM: Get Maintenance Mode History


I use this query whenever I need to investigate Maintenace Mode history for SCOM agents. USE OperationsManagerDW SELECT ManagedEntity.DisplayName, MaintenanceModeHistory.* FROM ManagedEntity WITH (NOLOCK) INNER JOIN MaintenanceMode ON ManagedEntity.ManagedEntityRowId = MaintenanceMode.ManagedEntityRowId INNER JOIN MaintenanceModeHistory ON MaintenanceMode.MaintenanceModeRowId = MaintenanceModeHistory.MaintenanceModeRowId where DisplayName Like ‘%SERVERNAME%’ order by ScheduledEndDateTime – F

Read More

Useful SQL queries for OpsMgr DB


Here are some of the SQL scripts I usually use in case of… whatever. Many of these must be credited to Kevin Holman Set ALL agents to Remotely Managable UPDATE MT_HealthService SET IsManuallyInstalled=0 WHERE IsManuallyInstalled=1 Get Agents not Remotely Managable select bme.DisplayName from MT_HealthService mths INNER JOIN BaseManagedEntity bme on bme.BaseManagedEntityId = mths.BaseManagedEntityId where IsManuallyInstalled…

Read More

← OLDER POSTS NEWER POSTS →