Skip to content

Instantly share code, notes, and snippets.

@tknr
Created July 18, 2021 21:37
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tknr/e802a38a4a1eaf5484fb6879f9fcc5f7 to your computer and use it in GitHub Desktop.
Save tknr/e802a38a4a1eaf5484fb6879f9fcc5f7 to your computer and use it in GitHub Desktop.
PowerShell
<#
.SYNOPSIS
exports installed packages.
.DESCRIPTION
exports installed packages:
exportChocolatey.ps1 > packages.config
You can install the packages using :
choco install packages.config -y
.LINK
https://gist.github.com/alimbada/449ddf65b4ef9752eff3
#>
function exportChocolatey {
Write-Output "<?xml version=`"1.0`" encoding=`"utf-8`"?>"
Write-Output "<packages>"
choco list -lo -r -y | % { " <package id=`"$($_.SubString(0, $_.IndexOf("|")))`" version=`"$($_.SubString($_.IndexOf("|") + 1))`" />" }
Write-Output "</packages>"
}
function ll {
Get-ChildItem $args[0] -force | Sort-Object -Property @{ Expression = 'LastWriteTime'; Descending = $true }, @{ Expression = 'Name'; Ascending = $true } | Format-Table -AutoSize -Property Mode, Length, LastWriteTime, Name
}
function getSchedules {
Get-ScheduledTask | Where {$_.State -eq 'Ready'} | Get-ScheduledTaskInfo | where {$_.nextruntime -ne $null} | select taskpath,taskname,nextruntime
}
function getFilenameDate {
Get-Date -UFormat "%Y%m%d%H%M"
}
function gitAddCommitPush {
git add --all && git commit && git push
}
function which {
Param(
[parameter(mandatory=$true)][String]$command
)
gcm $command | fl
}
function sudo {
powershell start-process pwsh -verb runas
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment