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 MorePowershell: Get file- and foldersize for given path
Posted by frank on May 11, 2016Quick 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 MoreWindows: Server stuck in shutdown after installing patches
Posted by frank on March 31, 2016One 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 MoreWindows: Modify Automatic (Delayed start) windows service thresholds
Posted by frank on February 24, 2016I 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 MoreWindows: Autologon for Domain User
Posted by frank on February 24, 2016I 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 MorePowershell: Convert string to date
Posted by frank on January 27, 2016The 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 MoreSCOM: DeltaSynchronization Error
Posted by frank on December 22, 2015This 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 MoreSCOM: Get Subscriber in Subscription
Posted by frank on November 30, 2015This 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 MoreSCOM: Get Maintenance Mode History
Posted by frank on November 20, 2015I 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 MoreUseful SQL queries for OpsMgr DB
Posted by frank on October 19, 2015Here 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