Skip to content

Instantly share code, notes, and snippets.

View PrateekKumarSingh's full-sized avatar

Prateek Singh PrateekKumarSingh

View GitHub Profile
Function Get-DictionaryWord
{
[Cmdletbinding()]
Param(
[String]$StartingAlphabet
)
$Results = @()
$i = 1
$StartingAlphabet = $StartingAlphabet.toLower()
@PrateekKumarSingh
PrateekKumarSingh / Get-MP3MetaData.ps1
Last active June 24, 2023 06:56
Get MetaData from a .MP3 or .MP4 file
Function Get-MP3MetaData
{
[CmdletBinding()]
[Alias()]
[OutputType([Psobject])]
Param
(
[String] [Parameter(Mandatory=$true, ValueFromPipeline=$true)] $Directory
)
Function Start-MediaPlayer
{
[cmdletbinding()]
Param(
[Alias('P')] [String] $Path,
[Alias('Sh')] [switch] $Shuffle,
[Alias('St')] [Switch] $Stop,
[Alias('L')] [Switch] $Loop
)
#Install IIS Feature
Install-WindowsFeature -Name Web-Server -IncludeManagementTools
#Install FTP feature
Install-WindowsFeature -Name Web-Ftp-Server -IncludeAllSubFeature -IncludeManagementTools -Verbose
#Creating new FTP site
$SiteName = "Demo FTP Site"
$RootFolderpath = "C:\DemoFTPRoot"
$PortNumber = 21
Function Get-TwitterProfile
{
[cmdletbinding()]
Param(
$URL = "https://twitter.com/followers"
)
Begin
{}
Process
Function Create-HTMLDOMFromFile
{
Param(
[String] $FileName,
[String] $TagName,
[Int] $OuputCount = 11
)
$HTML = New-Object -Com "HTMLFile";
$Content = Get-Content -Path $FileName -raw
$Content = @"
<HTML>
<BODY>
<h1> This is a heading </h1>
<P id='para1'>First Paragraph with some Random text</P>
<P>Second paragraph with more random text</P>
<A href="http://Geekeefy.wordpress.com">Cool Powershell blog</A>
</BODY>
</HTML>
"@ | Out-File File.html
<#
.Synopsis
Gets information of a port number
.DESCRIPTION
Function provides detailed information of port numbers, like - the service which use the port, Transport protocol and a small decsription.
.EXAMPLE
PS > Get-Port -Port 20,21,53
Port Service Protocol Description
---- ------- -------- -----------
# Tokenizing Powershell script
# 1. From Content of a File
[System.Management.Automation.PSParser]::Tokenize((Get-Content $path), [ref]$null)
# 2. From content of Current file in Powershell ISE
[System.Management.Automation.PSParser]::Tokenize($PSISE.CurrentFile.Editor.Text, [ref]$null)
# 3. From a String
[System.Management.Automation.PSParser]::Tokenize('$c= $a+$b', [ref]$null)
# 4. Current File in VScode using Powershell editor services (only on VSCode)
$psEditor.GetEditorContext().currentfile.tokens.gettype()
<#
.SYNOPSIS
Retries a powershell command n-times.
.DESCRIPTION
The cmdlet is capable of retrying a PowerShell command passed as a [ScriptBlock] according to the user defined number of retries and timeout (In Seconds)
.PARAMETER TimeoutInSecs
Timeout in secods for each retry.