Script directory for a PowerShell profile. https://blog.lksz.me/keeping-track-of-everything/#-mypsscriptroot
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
560 B

  1. function smartsudo() {
  2. [CmdletBinding(SupportsShouldProcess)]param(
  3. [switch]$sudo,
  4. [switch]$Force,
  5. [Parameter(Position = 0, ValueFromRemainingArguments = $true)]
  6. [string[]]$expr
  7. )
  8. if( $sudo -and -not $(Test-IsAdmin) ) {
  9. Write-Verbose "Perofrming the following command line via SUDO:`n$($expr -join ' ')"
  10. $local:base64command = ConvertTo-Base64 "$expr"
  11. /usr/bin/env sudo pwsh -EncodedCommand $base64command
  12. return
  13. }
  14. Write-Verbose "Perofrming the following expression in-line:`n$($expr -join ' ')"
  15. Invoke-Expression "$expr"
  16. }