Skip to content

Instantly share code, notes, and snippets.

@tknr
Created July 18, 2021 21:37
Show Gist options
  • Select an option

  • Save tknr/e802a38a4a1eaf5484fb6879f9fcc5f7 to your computer and use it in GitHub Desktop.

Select an option

Save tknr/e802a38a4a1eaf5484fb6879f9fcc5f7 to your computer and use it in GitHub Desktop.

Revisions

  1. tknr created this gist Jul 18, 2021.
    44 changes: 44 additions & 0 deletions Microsoft.PowerShell_profile.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,44 @@
    <#
    .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
    }