Skip to content

Instantly share code, notes, and snippets.

View PrateekKumarSingh's full-sized avatar

Prateek Singh PrateekKumarSingh

View GitHub Profile
# Parameter Definition
Param
(
[Parameter(mandatory = $true)] [String] $DPMServer,
[String] $SendEmailTo,
[String] $OutputDirectory,
[String] $SMTPServer
)
# HTML Body Definition Start
Function Get-Direction()
{
Param(
[Parameter(Mandatory=$true,Position=0)] $Origin,
[Parameter(Mandatory=$true,Position=1)] $Destination,
[Parameter(Position=2)] [ValidateSet('driving','bicycling','walking')] $Mode ="driving",
[Switch] $InMiles
)
Function Auto-Complete()
{
Return (Invoke-RestMethod -Uri "http://api.bing.com/qsml.aspx?query=$($TextBox1.text)").searchsuggestion.section.item.text
}
Function Create-WinForm()
{
#Calling the Assemblies
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
Get-MailboxStatistics -Database DBNAME | where {$_.DisconnectReason -eq “SoftDeleted”} | `
%{Remove-StoreMailbox -Database $_.database -Identity $_.mailboxguid -MailboxState SoftDeleted -Confirm:$false}
#Exchange
Import-pssession $(New-PSSession -ConfigurationName Microsoft.Exchange `
-ConnectionUri http://CAS_SERVER/PowerShell/ -Authentication Kerberos -Credential (Get-Credential))
#Lync
Import-pssession $(New-PSSession -ConnectionUri https://LYNC_SERVER_FQDN/ocspowershell/ -Credential (Get-Credential))
Get-Content C:\server.txt | `
foreach { Test-Connection ($_.ToString()+'ilo') -Count 1} `
| ft -property @{l='Server Name';e={(($_.address).split("ilo"))[0]}}, @{l='iLO Ip Address';e={$_.ipv4address}} -AutoSize
Function Change-BackgroundColor
{
[CmdletBinding()]
Param(
[Parameter(Position=0,ValueFromPipeline=$True)]
[String] $Color
)
PRocess{
Function Start-Recursion($Times, $Upto)
{
If($Times -gt $Upto){$Times;Start-Recursion($Times-1)}else{break}
}
Start-Recursion 100 0
Function Start-RandomMusic($directory)
{
Start-Process (gci $directory -Filter *.mp3 |Get-Random -Count 1).fullname -verb 'play'
}
Start-RandomMusic C:\Users\Prateek\downloads\
Function Search-PowershellScript
{
Param(
[Parameter(Mandatory=$true)] [String] $Directory,
[Parameter(Mandatory=$true)] [String] $Keyword,
[String] $Extension = ".ps1",
[Switch] $ShowMatchResult
)