Useful Powershell Commands

Forums Desktop Info Useful Powershell Commands

Tagged: 

  • This topic has 4 replies, 2 voices, and was last updated 3 years ago by BenderBender.
Viewing 3 reply threads
  • Author
    Posts
    • #2351
      GlennGlenn
      Keymaster

        Let’s start a collection of useful Powershell commands that you use with Desktop Info. If we get even a small collection I’ll add a chapter to the manual.

        I’ll start the ball rolling with this one that was sent to me by someone whose name I’ve forgotten (feel free to put your hand up). It returns a list of installed Microsoft applications. I’ve added this to the advanced ini file.

      • #2358
        Anonymous

          Not exclusively powershell tho.

          Robocopy(built-in windows tool)command to take backup of a folder to a external drive.
          Change drives/folder to your needs, it will only copy new items. when using the /MIR switch it will also delete files in the target if files does not exists in the source, to keep an clean backup.
          the log file is optional

          robocopy.exe C:\Data H:\backup\data /MIR /XA:H > C:\robobackup.log

          I use this to backup a large folder of images after i have imported new photos

        • #2360
          Anonymous

            Quickly list “Application” eventlog, useful if some applications crash etc.

            Get-EventLog -Log "Application"

            • #2362
              GlennGlenn
              Keymaster

                There’s already an event log item but here’s Powershell code ready to copy/paste:

            • #2385
              BenderBender

                If you use GitHub, you can query and display the number of new notifications from the GitHub API with PowerShell. For that you will first need a personal access token with the “notifications” permission for the account authentification via the command line (can be created in your GitHub account under Settings > Developer settings > Personal access token). I store it in a new environment variable named GITHUB_TOKEN, so that I don’t have to put it in my configuration file for Desktop Info. Then I use the following command to extract the number of new notifications (replace “username” with your GitHub username):
                CMD=active:1,interval:900,file:powershell.exe,parameters:Invoke-RestMethod -Headers @{Authorization = 'Basic {0}' -f [System.Convert]::ToBase64String([char[]]\"username:$Env:GITHUB_TOKEN\");} -Uri https://api.github.com/notifications | Select-Object -ExpandProperty Count | Write-Host -NoNewline,text:GitHub,display:%4 new notifications
                preview

            Viewing 3 reply threads
            • The topic ‘Useful Powershell Commands’ is closed to new replies.
            Glenn's Page