Skip to content

Instantly share code, notes, and snippets.

@hpmmatuska
hpmmatuska / Test-MultiConnection.ps1
Last active August 29, 2015 14:14
Test Connection with multiple features
Function Test-Ping {
<#
.Synopsis
Do a simple conncetion test (ping) to specified hosts.
.Description
The command will run "test-connection" again hosts defined in variable. If Single host is specified,
there will run continuos ping, otherwise one packet will be send to all hosts in paralel. The pipe input is supported.
.Parameter ComputerName
The destination name or IP addresses
alias: name, cn
@hpmmatuska
hpmmatuska / Get-UptimeParallel.ps1
Last active August 29, 2015 14:14
Get Uptime for list of computers with basic errorhandling. It's processed in parallel.
Function Get-Uptime {
<#
.Synopsis
Get computer uptime.
.Description
This command will query the Win32_OperatingSystem class using Get-CimInstance and write an uptime object to the pipeline.
The function is calling workflow to parallely process all inputs to save some time.
.Parameter Computername
The name of the computer(s) to query. This parameter has an alias of CN. The Input can be piped.
@hpmmatuska
hpmmatuska / Get-FolderSize.ps1
Last active August 29, 2015 14:14
Get folder sizes with recourse. The output is list of first level directory structure under specified path.
Function mms-FolderSize {
<#
.Synopsis
The function will return folder size and list of first level subfolders size.
.Description
The function is simmilar to reskit command "diruse" or unix tool "du". The output is sum value of file sizes
in specified folder and summary siza for each first level subfolder. The function is build up on top of
get-childitem function.
@hpmmatuska
hpmmatuska / Get-SPWorkflowExecutionStatus
Last active August 29, 2015 14:15
The function will query the SharePoint web applications or the Site Collection for all the workflows and the result codes. It's useful to have overview about all running workflows due to build-in limits.
Function mms-SPRunningWorkflows {
<#
.Synopsis
List of running workflows for the site
.Description
Due to running worfklows you can face to various .Net compilation errors. The most know are:
- Could not write to output file ... The Directory is invalid
- The workflow can not run and will be saved only
- etc.
@hpmmatuska
hpmmatuska / SQL_validation.ps1
Last active August 29, 2015 14:20
The function validate input file (SQL script) for potential dangerous commands. Optional is report and trigger execution.
Function ExecuteSQLscript {
<#
.Synopsis
Execute SQL script
.Description
will trigger sqlexec.exe and display output
.INPUTS
-SQLscript <[System.IO.FileInfo]string>
@hpmmatuska
hpmmatuska / get-ServiceStatus.ps1
Last active August 29, 2015 14:20
List services, their startup type and current status; optionally action for qeuery results
function Get-ServiceStatus {
<#
.Synopsis
List services, their startup type and current status.
.Description
This command will query the Win32_Service class using Get-WmiObject and return list of services.
.Parameter
Computername - The name of the computer to query. This parameter has an alias of CN. The Input can be piped.
Service - query for service name, supports wildcards
@hpmmatuska
hpmmatuska / telnet.ps1
Last active August 29, 2015 14:21
Will create sample connection to remote machine on specified port (as classic telnet client)
Function Test-Port {
<#
.Synopsis
Do a test for open ports against remote machine
.Description
Will create sample connection to remote machine on specified port (as classic telnet client)
.Parameter Computername
The name of the computer to query. The Input can be piped, it is default 1st parameter
@hpmmatuska
hpmmatuska / Get-RemoteAccessFarmUsage.ps1
Last active March 17, 2020 16:16
Get active remote connection thru RRAS and RDS Gateway for the specified servers.
function mms-RAFarm {
<#
.Synopsis
Get active remote connection thru RRAS and RDS Gateway for the specified servers.
.Description
This command will query the Win32_TSGatewayConnection class using RPC and root/Microsoft/Windows/RemoteAccess using WinRM
and write summary object to the pipeline.
.Parameter Computername
The name of the computer(s) to query. This parameter has an alias of CN. The Input can be piped.
@hpmmatuska
hpmmatuska / Nagios_Cluster.ps1
Last active January 5, 2022 14:51
Cluster Monitoring for Nagios. It's monitor Cluster Nodes, Groups, Resources and Prefered Owners. The script is for PS4 (Windows 2012). Earlier windows are missing the method CIM method getpreferedowner -> you need to comment that section.
$Status= 0
# 0-OK
# 1-Warning
# 2-Error
# 3-Unknown
$ItemName = $null
# This has to be unique per host in NAGIOS
$PerfData = '-'
# varname=value;warn;crit;min;max