This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Process | |
{ | |
Try | |
{ | |
# Sends HTTPS request to the Slack Web API service. | |
$WebRequest = Invoke-WebRequest -Uri $Uri -Body $PostMessage | |
# Conditional logic to generate custom error message if JSON object response contains a top-level error property. | |
If ($WebRequest.Content -like '*"ok":false*') | |
{ | |
# Terminates with error if the response contains an error property, parses the error code and stops processing of the command. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generates POST message to be sent to the slack channel. | |
$PostMessage = @{token="$Token";channel="$Channel";text="$Text";username="$Bot";icon_url="$Icon"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Get-Uptime { | |
<# | |
.SYNOPSIS | |
Gets the uptime for a local or remote computer. | |
.DESCRIPTION | |
The Get-Uptime function gets the uptime for specified computers by retrieving the LastBootUpTime from Win32_OperatingSystem WMI class. The uptime period is calculated in days by comparing the interval between the LastBootUpTime and the current date and time. | |
The function sends an Internet Control Message Protocol (ICMP) echo request packet to determine if a the specified computer may be contacted. If the computer is offline this will report a status of 'Offline. If an echo reponse is received, the uptime status will |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Validate Base64 string. | |
[0-9a-zA-Z\+=]{20,} | |
# Validate Subnet in CIDR notation. | |
^(([01]?\d?\d|2[0-4]\d|25[0-5])\.){3}([01]?\d?\d|2[0-4]\d|25[0-5])\/(\d{1}|[0-2]{1}\d{1}|3[0-2])$ | |
# Validate IP address range. | |
^(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[0-9]{1,2})(\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[0-9]{1,2})){3}-(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[0-9]{1,2})(\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[0-9]{1,2})){3}$ | |
# Validate IP address. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Returns a collection of REST:RESTHost object types from the inventory service plugin | |
var getHosts = RESTHostManager.getHosts() | |
// Iterates the collection to return the REST:RESTHost object type and perform a match on the name attribute provided as an input parameter and returns the REST:RESTHost type if true. | |
for(var restHostId in getHosts){ | |
var restHost = RESTHostManager.getHost(getHosts[restHostId]) | |
if(restHost.name == name){ | |
return restHost | |
} // if(restHost.name == name) | |
} // var restHost = RESTHostManager.getHost(getHosts[restHostId]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Retrieves the resource element as a mime attachment from the specified input parameter (resourceElement). | |
var content = resourceElement.getContentAsMimeAttachment(); | |
System.debug('The resource element ' + resourceElement.name + ' has been returned with the mime type ' + content.mimeType) | |
content.mimeType = mime; | |
// Sets the mime attachement to the type specifed from the input parameter (mime). | |
resourceElement.setContentFromMimeAttachment(content); | |
System.log('The resource element ' + resourceElement.name + ' mime type type has been set to ' + mime) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Retrieves the resource element as a mime attachment from the specified input parameter (resourceElement). | |
var content = resourceElement.getContentAsMimeAttachment(); | |
System.debug('The resource element ' + resourceElement.name + ' has been returned with the mime type ' + content.mimeType) | |
content.mimeType = mime; | |
// Sets the mime attachement to the type specifed from the input parameter (mime). | |
resourceElement.setContentFromMimeAttachment(content); | |
System.log('The resource element ' + resourceElement.name + ' mime type type has been set to ' + mime)]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from dateutil import parser | |
from pytz import timezone | |
from datetime import datetime | |
import time | |
def localized_time_to_epoch(timestamp, time_zone): | |
strptime = "%Y-%m-%d %H:%M:%S" | |
timestamp = parser.parse(timestamp) | |
localize = timezone(timezone).localize(datetime.strptime(str(timestamp), strptime)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ~/.bashrc | |
# exported variable for SSH jump host | |
export SSH_JUMPHOST='{{ hostname }}' | |
# Creates a short lived SSH certificate signed by AAD. | |
# Requires public key file creating using the command - ssh-keygen -t rsa -b 4096 | |
alias az_ssh_cert='az ssh cert --public-key-file ~/.ssh/id_rsa.pub --file ~/.ssh/id_rsa-aadcert.pub' | |
# Connects to the target host first by making a connection to the jump host and then establishing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var date_limit = {{ number_of_days }} | |
$("#startDate").on("change", function(e) { | |
var maxDate = new Date($(this).val()) | |
var endDate = new Date($('#endDate').val()) | |
var maxDate = maxDate.setDate(maxDate.getDate() + date_limit) | |
if (endDate > maxDate){ | |
$('#endDate').val(new Date(maxDate).toJSON().slice(0,10)); | |
} |