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-GeoIP { | |
<# | |
.SYNOPSIS | |
Retrieves IP geolocation data. | |
.DESCRIPTION | |
Connects to GeoIP REST API (www.telize.com/geoip) and retrieves JSON-encoded IP geolocation data and converts to custom objects. | |
.PARAMETER IP Address | |
Specify IP address or addresses to retrieve IP geolocation data. | |
.PARAMETER Protocol |
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
# Single line using one pair of curly brackets. | |
Import-Csv -Path .\Input.csv | ForEach-Object {$_ | Add-Member -MemberType NoteProperty -Name OSVERSION -Value (Get-WmiObject -Class Win32_OperatingSystem -ComputerName $_.MACHINENAME).Caption -PassThru} | Export-Csv .\Output.csv -NoTypeInformation | |
# Single line using no semicolons or curly brackets if host names are specified in the CSV file to import. | |
Get-WmiObject -Class Win32_OperatingSystem -ComputerName (Import-Csv .\Input.csv).MachineName | Select-Object PSComputerName,Caption | ConvertTo-Csv -NoTypeInformation | Select -Skip 1 | ConvertFrom-Csv -Header MACHINENAME, OSVERSION | Export-Csv .\Output.csv -NoTypeInformation |
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
Exit ("1") | |
[Environment]::Exit("1") |
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
[CmdletBinding()] | |
Param ( | |
$VerbosePreference = $PSCmdlet.GetVariableValue('VerbosePreference') | |
) |
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
[CmdletBinding()] | |
Param ( | |
[ValidateScript({Get-Item (Get-Item $_).DirectoryName})] | |
[String]$LogFile = "", | |
[Parameter(Mandatory=$True)] | |
[String]$Message, | |
[ValidateSet('Info','Error','Warning')] | |
[String]$Level = "Info" | |
) |
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
Switch ($Level) | |
{ | |
'Info' {$Event = ("" + (Get-Date -Format s) + ": INFORMATION: " + $Message + ".")} | |
'Warning' {$Event = ("" + (Get-Date -Format s) + ": WARNING: " + $Message + ".")} | |
'Error' {$Event = ("" + (Get-Date -Format s) + ": ERROR: " + $Message + ".")} | |
} |
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
# Conditional logic to determine event generation method. | |
If ($LogFile) | |
{ | |
# Conditional logic to determine if the log file current exists in the location specified. | |
If (!(Get-Item $LogFile -ErrorAction SilentlyContinue)) | |
{ | |
# Creates the log file in the location specified. | |
New-Item $LogFile -Force -ItemType File | Out-Null | |
} | |
# Generates events in the current Windows PowerShell session specified and the log file specified. |
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
[CmdletBinding()] | |
Param ( | |
[String] | |
$ModuleName = "TestModule", | |
[String] | |
$Author = "", | |
[String] | |
[ValidateScript({Get-Item $_ })] | |
$Path = "C:\Sandbox\PowerShell\Modules" | |
) |
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-RSSFeed { | |
<# | |
.SYNOPSIS | |
Retrieves most recent articles for an RSS feed(s). | |
.DESCRIPTION | |
Retrieves most recent articles for an RSS feed(s). By default, this will return the article headline. Optional parameters will retrive the link and description of the article. | |
This function requires Windows PowerShell 3.0 to in order to retrieve Uniform Resource Identifier (URI) using the Invoke-WebRequest cmdlet. | |
.PARAMETER Uri | |
Specify the Uniform Resource Identifier (URI) to send a request to the web page of the RSS feed(s). |
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
[CmdletBinding()] | |
Param ( | |
[Parameter(Mandatory=$True, ValueFromPipeline=$True, HelpMessage="Enter an email address to compute hash")] | |
[ValidateScript({"\b[A-Z0-9._%+-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,4}\b"})] | |
[String[]]$Email | |
) |
OlderNewer