Skip to content

Instantly share code, notes, and snippets.

View PrateekKumarSingh's full-sized avatar

Prateek Singh PrateekKumarSingh

View GitHub Profile
Function Change-BackgroundColor
{
[CmdletBinding()]
Param(
[Parameter(Position=0,ValueFromPipeline=$True)]
[String] $Color
)
PRocess{
Function Get-LastBootTime($servers)
{
$creds = Get-Credential 'domain\username'
$lastbootuptime=@()
foreach($s in $servers)
{
$Wmio=Get-WmiObject win32_operatingsystem -ComputerName $S -Credential $creds
Function Resolve-Hostname($IPAddress)
{
return (ping -a $IPAddress -n 1)[1].Split(' ')[1]
}
gc C:\list.txt| %{"$(Resolve-Host $_) `t$_"}
Function Start-RandomMusic($directory)
{
Start-Process (gci $directory -Filter *.mp3 |Get-Random -Count 1).fullname -verb 'play'
}
Start-RandomMusic C:\Users\Prateek\downloads\
Function Start-Recursion($Times, $Upto)
{
If($Times -gt $Upto){$Times;Start-Recursion($Times-1)}else{break}
}
Start-Recursion 100 0
@PrateekKumarSingh
PrateekKumarSingh / DownloadImages_fromURL.ps1
Last active May 6, 2019 20:15
Extracting Images from a URL and saving it in a desired directory
$url="https://geekeefy.wordpress.com/2016/03/12/powershell-extract-text-from-image-and-convert-print-in-any-language/"
(Invoke-WebRequest -Uri $url).images.src | ?{$_ -like "*Geekeefy.files*"} -PipelineVariable pv `
| %{$fn = ($pv.split("/")[-1]).split('?')[0];iwr $pv -OutFile "D:\scraping\$fn"}
# Running MSI installation
$MSIFile = @('C:\users\prateesi\download\zoomit.msi')
$MSIEXECPath = "$env:SystemRoot\system32\msiexec.exe"
(Start-Process $MSIEXECPath -ArgumentList "/i `"$MSIFile`" /qn" -Wait -PassThru).exitcode
# Running WUSA/ .EXE installation
$path = "C:\Users\prateesi\Downloads\Win7AndW2K8R2-KB3134760-x64.msu"
$ExitCode = (Start-Process 'wusa.exe' -ArgumentList "`"$path`" /quiet" -wait -PassThru).exitcode
Function Get-ExitCodeInformation($ExitCode)
Function Search-PowershellScript
{
Param(
[Parameter(Mandatory=$true)] [String] $Directory,
[Parameter(Mandatory=$true)] [String] $Keyword,
[String] $Extension = ".ps1",
[Switch] $ShowMatchResult
)
@PrateekKumarSingh
PrateekKumarSingh / update-githubgist.ps1
Last active May 26, 2016 17:53
Updated on 26-May-16 11:23:09
Function Update-GithubGist
{
Param(
[Parameter(Mandatory=$true)] [String] $Path,
[Parameter(Mandatory=$true)] [String] $GistName,
[Switch] $SecretGist = $False
)
if (Test-Path -Path $Path)
{
@PrateekKumarSingh
PrateekKumarSingh / Get-GithubGist.ps1
Last active May 26, 2016 18:00
Updated on 26-May-16 11:30:26
Function Get-GithubGist
{
Param(
[Parameter(Mandatory=$True, ValueFromPipelineByPropertyName = $True)] [String[]] $GithubUser,
[String[]] $FileName,
[switch] $openInISE
)