- code 7
- tricks 7
- powershell 6
- AST 5
- ISE 5
- GUI 4
- error 4
- search 3
- write-up 3
- Proxy 2
- clean-up 2
- data 2
- Installer 1
- MSI 1
- Sync 1
- WMI 1
- WPF 1
- command line navigation 1
- compare 1
- date conversion 1
- download 1
- format 1
- measure download 1
- native commands 1
- outlook 1
- python 1
- query 1
- sort 1
- trading 1
- web automation 1
- xml 1
code
Control Split-Panes in Windows Terminal through PowerShell
In this post, I would like to introduce a PowerShell function to create new split-panes for the Windows Terminal.
Graph theory with PowerShell - part 2
This is part two of ‘Graph theory with PowerShell’, focussing on ‘Small World Graphs’, with PowerShell based on (Chapter 3) of the execellent book Think Complexity 2e by Allen B. Downey.
Extending PowerShell’s Compare-Object to handle custom classes and arrays
In this post I will walk you through the process of extending the the built-in Compare-Object cmdlet to support ‘deep’ comparison of custom objects, arrays, and classes.
Use PowerShell to monitor a folder and extract downloaded .zip files
Use PowerShell to monitor a download folder as a background task and smartly extract .zip files automatically as you download them.
Using PowerShell and RegEx to extract text between delimiters
In this post I will share a little PowerShell function that I use quite frequently in order to extract text between delimiters out of a bigger chunk of text. I hope that this can be useful to others too.
Jupyter PowerShell Notebooks based blogging
In this post I would like to share how one can use PowerShell Jupyter Notebooks with .Net interactive for blogging
Python Pandas and Trading Stuff
Post displaying the various ways one can highlight code blocks with Jekyll. Some options include standard Markdown, GitHub Flavored Markdown, and Jekyll’s {% highlight %}
tag.
tricks
PowerShell tricks – Convert copied range from excel to an array of PSObjects →
In this post, I would like to share a simple function that converts tables copied from Excel to the clipboard into PowerShell objects. While there are several more efficient ways to retrieve data out of Excel files (e.g. COM, EPPlus), I sometimes just want something quick and dirty to get the job at hand done. https://gist.github.com/12f06bec82dc4cc93370b2fa7dc750f4 Usage:
PowerShell tricks – Open a dialog as topmost window →
Windows.Forms provides easy access to several built-in dialogs (see MSDN: Dialog-Box Controls and Components). Here is an usage example to show a “FolderBrowse” dialog: [code language=”powershell”] Add-Type -AssemblyName Windows.Forms $FolderBrowser = New-Object System.Windows.Forms.FolderBrowserDialog $FolderBrowser.Description = ‘Select the folder containing the data’ $result = $FolderBrowser.ShowDialog() if ($result -eq [Windows.Forms.DialogResult]::OK){ $FolderBrowser.SelectedPath } else { exit } [/code] While this works as expected, the dialog won’t show up as the topmost window. This could lead to situations where users of your script might miss the dialog or simply complain because they have to switch windows. Even though there is no built-in property to set the dialog as the topmost window, the same can be achieved using the second overload of the ShowDialog method (MSDN: ShowDialog method). This overload expects a parameter which indicates the parent windows of the dialog. Since the owning window will not be used after the dialog has been closed we can just create a new form on the fly within the method call: [code language=”powershell” highlight=”4”] Add-Type -AssemblyName System.Windows.Forms $FolderBrowser = New-Object System.Windows.Forms.FolderBrowserDialog $FolderBrowser.Description = ‘Select the folder containing the data’ $result = $FolderBrowser.ShowDialog((New-Object System.Windows.Forms.Form -Property @{TopMost = $true })) if ($result -eq [Windows.Forms.DialogResult]::OK){ $FolderBrowser.SelectedPath } else { exit } [/code]
PowerShell tricks - Use Show-Command to add a simple GUI to your functions →
The Show-Command cmdlet has been introduced in PowerShell Version 3 and is very useful to help discovering and learning more about PowerShell cmdlets and their respective parameters (also built into the ISE as the Show-Command Add-on).: [code language=”powershell”] #Discover commands by running Show-Command without parameters Show-Command #Run Show-Command for a specific cmdlet Show-Command Get-ChildItem [/code] Show-Command can be also utilized for your own functions in order to provide your users with a simple GUI as it builds a graphical user interface for the provided function on the fly. Show-Command displays:
PowerShell tricks – Useful default parameters to add to your profile →
Since version 3 PowerShell introduced $PSDefaultParameterValues which is a built-in preference variable which lets you specify default values for any cmdlet or advanced function. You can read much more about it inside the respective help file. In a nutshell $PSDefaultParameterValues is a hash-table where (in its most common version) the key consists of the cmdlet name and parameter name separated by a colon (:) and the value is the custom default value: [code language=”powershell”]
PowerShell tricks - Using dot(s) to refer to the current location →
Most people are aware that PowerShell supports commandline navigation in the same way as the good old command prompt (see my previous post Improve PowerShell commandline navigation for ways to enhance this): [code language=”powershell”] cd $env:USERPROFILE\Desktop Resolve-Path ‘.’ #change to the current direction (doing nothing) cd . #move up one level Resolve-Path ‘..’ cd .. [/code] The above is using cd as the alias for the Set-Location Cmdlet providing:
PowerShell tricks - replace and transform a value within a string →
PowerShell tricks - Build an array of strings without quotation marks →
This is one of the tricks I keep forgetting about and therefore document it here for myself but also in case someone else might find it useful.
In order to create an array of strings one usually does something like this:
[code language=”powershell” light=”true”]
$stringArray = “first”, “second”, “third”, “fourth”
[/code]
It involves quite some redundant characters in order to do a simple thing. This can be made easier using a simple function that is part of the excellent PowerShell Communicty Extensions. The QL (QL is short for Quote-List an idea borrowed from Perl) function has the following definition:
[code language=”powershell”]
function ql {$args}
ql first second third fourth
[/code]
Note that extraneous commas and quotation marks can be avoided using this approach. There is actually even a built-in cmdlet that can be used for the same purpose. Write-Output alias echo or write:
[code language=”powershell” light=”true”]
echo first second third fourth
[/code]
If an element of the string array we’d like to create contains a space the element needs to be surrounded in quotes:
[code language=”powershell” light=”true”]
echo first second third fourth “with space”
[/code]
As a bonus tip we can use a similar idea as for the ql function in order to create strings without having to limit them by quotation marks:
[code language=”powershell”]
function qs {“$args”}
qs this is a long string without any quotes
#only gotcha is when using quotes (single or double) within the argument
#qs this does not’ work
qs quotes require escaping using a 'backtick
’ otherwise it will not work
[/code]
powershell
Control Split-Panes in Windows Terminal through PowerShell
In this post, I would like to introduce a PowerShell function to create new split-panes for the Windows Terminal.
Graph theory with PowerShell - part 2
This is part two of ‘Graph theory with PowerShell’, focussing on ‘Small World Graphs’, with PowerShell based on (Chapter 3) of the execellent book Think Complexity 2e by Allen B. Downey.
Extending PowerShell’s Compare-Object to handle custom classes and arrays
In this post I will walk you through the process of extending the the built-in Compare-Object cmdlet to support ‘deep’ comparison of custom objects, arrays, and classes.
Use PowerShell to monitor a folder and extract downloaded .zip files
Use PowerShell to monitor a download folder as a background task and smartly extract .zip files automatically as you download them.
Using PowerShell and RegEx to extract text between delimiters
In this post I will share a little PowerShell function that I use quite frequently in order to extract text between delimiters out of a bigger chunk of text. I hope that this can be useful to others too.
Jupyter PowerShell Notebooks based blogging
In this post I would like to share how one can use PowerShell Jupyter Notebooks with .Net interactive for blogging
AST
WMI query filters with PowerShell syntax instead of WQL →
PowerShell comes already with tight integration to WMI with its built-in Get-WmiObject and Get-CimInstance cmdlets. One of the things that people already familiar with PowerShell syntax bothers about WMI is that it comes with its very own query language WQL. While WQL is very similar to SQL. Wouldn’t it be nicer if we could use the same operators and wild-card patterns we are already familiar with? Well, for myself the answer is Yes:
Zen Coding for the PowerShell console and ISE →
First of all let’s clarify what Zen Coding actually is. According to their website: Emmet (formerly known as Zen Coding) is …
Simplified Where-Object for multiple conditions on the same property for PowerShell? →
[![310749483260009ec22b_m](https://powershellone.files.wordpress.com/2015/10/3107494832_60009ec22b_m.jpg)](https://powershellone.files.wordpress.com/2015/10/3107494832_60009ec22b_m.jpg) While PowerShell version 3 already introduced a (quite controversial) simplified syntax for the Where-Object cmdlet (alias where). It still doesn’t account for a quite common error PowerShell beginners encounter when using where with multiple conditions on the same property. As an example let’s say we would like to filter the range 1-10 to get only those numbers that are between 6 and 7. I’ve seen many people (yes that includes me) attempting to do it like below since it seems a logical translation of ‘where x is greater than 5 and lower than 8’.: [code language=”powershell”] 1..10 | where {$ -gt 5 -and -lt 8} #correct version 1..10 | where {$_ -gt 5 -and $_ -lt 8} [/code] Granted that this failing makes mathematically total sense since it should say ‘where x is greater 5 than and x is lower than 8’ . I’d wish there would be a syntax supporting something like this: [code language=”powershell”] 1..10 | where {$_ (-gt 5 -and -lt 8)} #or Get-Process | where {$_.Name (-like ‘power’ -and -notlike ‘ise’)} [/code] The idea is that the parentheses would indicate that the preceding variable should be considered as the (left-hand) parameter for the operator. I came up with a crude proof of concept on how this could be done: https://gist.github.com/d24442b2bbb72f5ff269 What do you think, would you also like to see this kind of syntax for Where-Object?
Show-CommandGUI an enhanced Show-Command for PowerShell →
After my last post (PowerShell tricks - Use Show-Command to add a simple GUI to your functions). I was thinking how one could write a function that would not have the deficiencies that Show-Command has when it comes to providing a GUI for functions. In addition to what Show-Command does I wanted a function that:
Expanding aliases in PowerShell ISE or any PowerShell file →
Further extending my PowerShell ISE module (ISEUtils) I’ve added a function to convert aliases either in the currently active ISE file or (in case a a path is provided) within any PowerShell file (that way the function can be also used from the PowerShell Console) to their respective definitions. Aliases are very useful when working interactively, since they help saving extra keystrokes when you just want to get things done fast. At the same time if we are speaking about production code where readability, and easy comprehension of the code are much more important the usage of aliases should be avoided ( read here for a good article on best practices for PowerShell alias usage). With the Expand-Alias function you can get the best of both worlds. Writing clearer code while avoiding extraneous keystrokes. For the code samples in my blog posts I’m also using aliases quite a lot, but would like to start using the new function from now on. Below is the source code for Expand-Alias: https://gist.github.com/9db6632423d673ff18f6 Usage:
ISE
Add spell checking to PowerShell ISE →
Zen Coding for the PowerShell console and ISE →
First of all let’s clarify what Zen Coding actually is. According to their website: Emmet (formerly known as Zen Coding) is …
Expanding aliases in PowerShell ISE or any PowerShell file →
Further extending my PowerShell ISE module (ISEUtils) I’ve added a function to convert aliases either in the currently active ISE file or (in case a a path is provided) within any PowerShell file (that way the function can be also used from the PowerShell Console) to their respective definitions. Aliases are very useful when working interactively, since they help saving extra keystrokes when you just want to get things done fast. At the same time if we are speaking about production code where readability, and easy comprehension of the code are much more important the usage of aliases should be avoided ( read here for a good article on best practices for PowerShell alias usage). With the Expand-Alias function you can get the best of both worlds. Writing clearer code while avoiding extraneous keystrokes. For the code samples in my blog posts I’m also using aliases quite a lot, but would like to start using the new function from now on. Below is the source code for Expand-Alias: https://gist.github.com/9db6632423d673ff18f6 Usage:
Create an integrated (WPF based) ISE Add-On with PowerShell →
Add a default code template to the PowerShell ISE →
Some of the 3rd party PowerShell editors offer already built-in support for a default code template where the content of the code template replaces the default blank sheet for every new tab as a starting point for new scripts. While the PowerShell ISE does not provide this functionality out-of-the-box, it can be quite easily added through the $psISE object model by registering a custom action for the $psise.CurrentPowerShellTab.Files ‘CollectionChanged’ event. This event is triggered whenever a tab is closed or opened: https://gist.github.com/ae270d78e2a469398ddf After pasting and running the above code inside the ISE we first need to create the template. The code template is required to be located at “MyDocuments\WindowsPowerShell\ISETemplate.ps1” it can be created and/or edited using the Edit-ISETemplate function. Once the ISETemplate.ps1 contains some text. Every new tab should now be pre-filled with the content of the code template file. In order to make this persistent the code should be added to your profile. You can find the path(s) to your profile by running ‘$profile | select *’. I personally favor the ‘CurrentUserAllHosts’ profile since I don’t want to maintain multiple profile files. Host specific code can be added by using conditions like: [code language=”powershell”] if ($host.Name -eq ‘Windows PowerShell ISE Host’){ #ISE specific code here } elseif ($host.Name -eq ‘ConsoleHost’){ #console specific code here } [/code] I’ve also added this functionality to my ISE Add-On over on GitHub.
GUI
Show-CommandGUI an enhanced Show-Command for PowerShell →
After my last post (PowerShell tricks - Use Show-Command to add a simple GUI to your functions). I was thinking how one could write a function that would not have the deficiencies that Show-Command has when it comes to providing a GUI for functions. In addition to what Show-Command does I wanted a function that:
PowerShell tricks - Use Show-Command to add a simple GUI to your functions →
The Show-Command cmdlet has been introduced in PowerShell Version 3 and is very useful to help discovering and learning more about PowerShell cmdlets and their respective parameters (also built into the ISE as the Show-Command Add-on).: [code language=”powershell”] #Discover commands by running Show-Command without parameters Show-Command #Run Show-Command for a specific cmdlet Show-Command Get-ChildItem [/code] Show-Command can be also utilized for your own functions in order to provide your users with a simple GUI as it builds a graphical user interface for the provided function on the fly. Show-Command displays:
A nicer PromptForChoice for the PowerShell Console Host →
Sometimes it’s not possible to fully automate a certain process and we need some input from the user(s) of the script in order to determine the further path of action. If this is based on a fixed set of choices the built-in PromptForChoice method can come to the rescue. Here is an example: https://gist.github.com/778414455f932e1f9ac8 Running the code below in PowerShell ISE will produce the following result:
Search file content by keyword using Everything + PowerShell + GUI →
Even with Windows 10 MS still didn’t manage to include a proper in-built file search functionality. If it is about searching for files I definitely prefer the excellent Everything search engine (see also my post on a PowerShell wrapper around Everything commandline) .But quite frequently I also need to search for keywords/pattern within files. PowerShell’s Get-ChildItem and Select-String can certainly do this together: [code language=”powershell”] #search through all .ps(m)1 files for instances of the word ‘mySearchString’ $path = ‘c:\scripts\powershell’ Get-ChildItem $path -Include (“.ps1”,”.psm1”)) -Recurse | Select-String ‘mySearchString’ | select Path, Line, LineNumber [/code] While this does the job it doesn’t follow my preferred workflow and is also not very quick when running it against a large set of files. I would prefer to have the ability to search and drill down a list of files within a Graphical User Interface just like Everything and then search through the filtered list of files using keyword(s)/pattern(s) and get back the search results within a reasonable time-frame. Say hello to “File Searcher” (I didn’t spend any time thinking about a catchy name): The three text boxes at the top of the UI can be used to:
error
Fix: Battery Icon and/or Volume Control Missing From Windows 10 Taskbar →
I came across a rather weird problem today where my taskbar was missing the icons for the volume control and battery meter: My first attempt to fix this was to check the related system settings:
PowerShell Error - “Select-Object : Cannot convert System.Object[] to one of the following types…” →
“Please wait while windows configures Microsoft Visual Studio…” when starting Excel →
Group-Object “Wildcard characters are not allowed in …” →
search
Full text search using PowerShell, Everything, and Lucene →
Searching for files is something everyone does on a very regular basis. While Windows is consistently changing the way this is done with every new operating system, the built-in functionality is still far from being sufficient. Therefore, I’m always looking for methods on how to improve this (you can also find several blog posts in relation to file searches around here). In regards to searching for files based on file names or paths, I’m pretty happy with the performance of Everything. If it is about searching for files based on their content (aka full-text search), there is still room for improvement in my opinion. Recently I’ve been watching the session recordings from the PowerShell Conference Europe 2016 (I can highly recommend anyone that is interested in PowerShell to watch those).
Search file content by keyword using Everything + PowerShell + GUI →
Even with Windows 10 MS still didn’t manage to include a proper in-built file search functionality. If it is about searching for files I definitely prefer the excellent Everything search engine (see also my post on a PowerShell wrapper around Everything commandline) .But quite frequently I also need to search for keywords/pattern within files. PowerShell’s Get-ChildItem and Select-String can certainly do this together: [code language=”powershell”] #search through all .ps(m)1 files for instances of the word ‘mySearchString’ $path = ‘c:\scripts\powershell’ Get-ChildItem $path -Include (“.ps1”,”.psm1”)) -Recurse | Select-String ‘mySearchString’ | select Path, Line, LineNumber [/code] While this does the job it doesn’t follow my preferred workflow and is also not very quick when running it against a large set of files. I would prefer to have the ability to search and drill down a list of files within a Graphical User Interface just like Everything and then search through the filtered list of files using keyword(s)/pattern(s) and get back the search results within a reasonable time-frame. Say hello to “File Searcher” (I didn’t spend any time thinking about a catchy name): The three text boxes at the top of the UI can be used to:
Using Everything search command line (es.exe) via PowerShell →
write-up
PowerShell Get-Command -Syntax output explained →
Review of methods to download files using PowerShell →
The goal of this post is to review and compare different methods to download files using PowerShell. As part of the review I would like to share (in addition to the inline source code you can also download a module (Get-FileMethods) that contains all functions via GitHub) some wrapper functions that follow the same pattern:
PowerShell scope write-up →
Proxy
Simplified syntax for calculated Properties with Select-Object →
WMI query filters with PowerShell syntax instead of WQL →
PowerShell comes already with tight integration to WMI with its built-in Get-WmiObject and Get-CimInstance cmdlets. One of the things that people already familiar with PowerShell syntax bothers about WMI is that it comes with its very own query language WQL. While WQL is very similar to SQL. Wouldn’t it be nicer if we could use the same operators and wild-card patterns we are already familiar with? Well, for myself the answer is Yes:
clean-up
Automatically clean-up excel data with multiple entries per cell separated by comma or line-breaks →
This is a follow-up from a previous post where I did the same using PowerShell.
A short recap first. The goal is to turn something like this:
Into this:
In the original state some of the cells have multiple entries that are either separated by comma or line-breaks (via Alt+Enter). Furthermore several of those entries contain extraneous spaces. In order to tabulate the data the columns for those rows that contain multiple entries per cell also need to be cross-joined (or Cartesian product) to ensure all possible combinations for the entries are accounted for.
Rather than merely translating the recursive CartesianProduct function from the previous post into VBA I decided to follow a different approach.
Utilizing ADO to build a cross-join (without duplicates) across columns for rows that contain multiple entries. In order do that (I’m not really good at VBA and there might be better ways, that I’d love to hear about) the columns need to be copied to separate sheets so that the ADODB adapter recognizes them as separate tablesI actually found that there is no need to copy the columns to separate sheets since ADO also accepts range references.The SQL for the cross-join with only unique entries is very simple. Assuming the following setup (for the separated entries of the second row from our example):
The Macro to build the cross-join looks like this:
https://gist.github.com/d840be45ba5c82e6d874
If you like to follow along here are the steps:
Using PowerShell to clean-up excel data with multiple entries per cell →
How many times did you come across a situation where you were supposed to work with Data that looks like this?: Some of the cells have multiple entries that are either separated by comma or line-breaks (via Alt+Enter). Furthermore several of those entries contain extraneous spaces. Happy days! What would be actually needed in order to work with the data is one clean entry per cell. In order to do that the columns for those rows that contain multiple entries per cell also need to be cross-joined (or Cartesian product) so that all possible combinations for the entries are accounted for. The end result should look like this: How could we do the same using PowerShell? Let’s first have a look on how to do the cross-join part. This can be done quite easily with nested loops. Taking the second row from the example, the following will lead to the desired result: [code language=”powershell”] $name= @(‘Nigel’) $products = ‘Product 1’, ‘Product 2’ $preferences = ‘Fast Delivery’, ‘Product Quality’ foreach($n in $name){ foreach($product in $products){ foreach($preference in $preferences){ “$n, $product, $preference” } } } [/code] One way to turn this into a more generic solution is using recursion (You need to understand recursion in order to understand recursion ;-) ). Here is an implementation of the same: https://gist.github.com/a7209498dbaacb1ef951 Ok, having covered the difficult part we now only need to read the data from excel clean it up and apply the Cartesian product function to it. Here is the full code to automate the whole process: https://gist.github.com/67a2b18e59f440184f47 The above contains a modified version of the CartesianProduct function in order handle objects (actually ordered hashtables since they preserve the column order). If time permits I would like to implement the same as an Excel macro and share it as part of another post. Update: I’ve added another post outlining how to do the same (using another approach) via an Excel Macro
data
Automatically clean-up excel data with multiple entries per cell separated by comma or line-breaks →
This is a follow-up from a previous post where I did the same using PowerShell.
A short recap first. The goal is to turn something like this:
Into this:
In the original state some of the cells have multiple entries that are either separated by comma or line-breaks (via Alt+Enter). Furthermore several of those entries contain extraneous spaces. In order to tabulate the data the columns for those rows that contain multiple entries per cell also need to be cross-joined (or Cartesian product) to ensure all possible combinations for the entries are accounted for.
Rather than merely translating the recursive CartesianProduct function from the previous post into VBA I decided to follow a different approach.
Utilizing ADO to build a cross-join (without duplicates) across columns for rows that contain multiple entries. In order do that (I’m not really good at VBA and there might be better ways, that I’d love to hear about) the columns need to be copied to separate sheets so that the ADODB adapter recognizes them as separate tablesI actually found that there is no need to copy the columns to separate sheets since ADO also accepts range references.The SQL for the cross-join with only unique entries is very simple. Assuming the following setup (for the separated entries of the second row from our example):
The Macro to build the cross-join looks like this:
https://gist.github.com/d840be45ba5c82e6d874
If you like to follow along here are the steps:
Using PowerShell to clean-up excel data with multiple entries per cell →
How many times did you come across a situation where you were supposed to work with Data that looks like this?: Some of the cells have multiple entries that are either separated by comma or line-breaks (via Alt+Enter). Furthermore several of those entries contain extraneous spaces. Happy days! What would be actually needed in order to work with the data is one clean entry per cell. In order to do that the columns for those rows that contain multiple entries per cell also need to be cross-joined (or Cartesian product) so that all possible combinations for the entries are accounted for. The end result should look like this: How could we do the same using PowerShell? Let’s first have a look on how to do the cross-join part. This can be done quite easily with nested loops. Taking the second row from the example, the following will lead to the desired result: [code language=”powershell”] $name= @(‘Nigel’) $products = ‘Product 1’, ‘Product 2’ $preferences = ‘Fast Delivery’, ‘Product Quality’ foreach($n in $name){ foreach($product in $products){ foreach($preference in $preferences){ “$n, $product, $preference” } } } [/code] One way to turn this into a more generic solution is using recursion (You need to understand recursion in order to understand recursion ;-) ). Here is an implementation of the same: https://gist.github.com/a7209498dbaacb1ef951 Ok, having covered the difficult part we now only need to read the data from excel clean it up and apply the Cartesian product function to it. Here is the full code to automate the whole process: https://gist.github.com/67a2b18e59f440184f47 The above contains a modified version of the CartesianProduct function in order handle objects (actually ordered hashtables since they preserve the column order). If time permits I would like to implement the same as an Excel macro and share it as part of another post. Update: I’ve added another post outlining how to do the same (using another approach) via an Excel Macro
Installer
Retrieve UninstallStrings to fix installer issues →
Recently I have encountered several installer related issues on my machine. Most of them seemed to be caused by insufficient privileges. This kind of issue can be usually fixed by running the installer “As Administrator”. In case the issue is in relation to an already installed software packet, it’s sometimes not so easy to locate the respective uninstaller/MSI packet, though. For that purpose, I’ve written a small PowerShell function that scans the registry (it turned out that if you are using PowerShell v5, there is a better way of doing this. See below for more details) (have a look here on why I didn’t want to use WMI Win32_Product instead) for the information. The function has the following features:
MSI
Retrieve UninstallStrings to fix installer issues →
Recently I have encountered several installer related issues on my machine. Most of them seemed to be caused by insufficient privileges. This kind of issue can be usually fixed by running the installer “As Administrator”. In case the issue is in relation to an already installed software packet, it’s sometimes not so easy to locate the respective uninstaller/MSI packet, though. For that purpose, I’ve written a small PowerShell function that scans the registry (it turned out that if you are using PowerShell v5, there is a better way of doing this. See below for more details) (have a look here on why I didn’t want to use WMI Win32_Product instead) for the information. The function has the following features:
Sync
Using Microsoft SyncToy through PowerShell →
This post is about running Microsoft SyncToy via PowerShell. For those that don’t know SyncToy:
WMI
WMI query filters with PowerShell syntax instead of WQL →
PowerShell comes already with tight integration to WMI with its built-in Get-WmiObject and Get-CimInstance cmdlets. One of the things that people already familiar with PowerShell syntax bothers about WMI is that it comes with its very own query language WQL. While WQL is very similar to SQL. Wouldn’t it be nicer if we could use the same operators and wild-card patterns we are already familiar with? Well, for myself the answer is Yes:
WPF
Back to Top ↑compare
Back to Top ↑date conversion
Back to Top ↑download
Review of methods to download files using PowerShell →
The goal of this post is to review and compare different methods to download files using PowerShell. As part of the review I would like to share (in addition to the inline source code you can also download a module (Get-FileMethods) that contains all functions via GitHub) some wrapper functions that follow the same pattern:
format
Back to Top ↑measure download
Back to Top ↑native commands
Use PowerShell to open regedit at a specific path or RegJump for PowerShell →
Even though PowerShell contains everything to read and write to the registry I still find myself quite frequently opening the registry editor (aka regedit.exe). Since navigating the tree manually can be quite time consuming I used to rely on RegJump developed by Mark Russinovich. I was wondering if the same could be implemented using PowerShell and maybe even adding some features like opening multiple registry keys either from the clipboard or provided as an argument to the function. Say hello to Open-Registry alias regJump. The function opens (instances of) the registry editor for provided paths from the clipboard or as argument to the regKey parameter. The registry paths can contain hive name shortnames like HKLM, HKCU, HKCR or PowerShell provider paths syntax like HKLM:\, HKCU:. Similar to how RegJump.exe handles non-existing paths Open-Registry also ignores those parts of the path and works its way backwards until it finds a valid path or returns an error message if the path doesn’t contain any valid parts. Let’s look at some example use cases:
outlook
Use PowerShell to set Exchange Out of Office status from any PC →
I’m sure this has also happened already several times to you. You finish up your work to start into your well deserved holidays and only after you arrive at home do you realize that you forgot about to set your “Out of Office” status (considering that you actually do that). Usually, this would mean that you need to use your company device in order to connect back to work and set it up. If your company is running Exchange mail servers there is actually another option available which enables you to do the same from any PC that is connected to the Internet. The EWS Managed API is the technology that enables this. I’ve written a module that uses the API in order to set an Out of Office message. The function has the following features:
python
Python Pandas and Trading Stuff
Post displaying the various ways one can highlight code blocks with Jekyll. Some options include standard Markdown, GitHub Flavored Markdown, and Jekyll’s {% highlight %}
tag.
query
Back to Top ↑sort
Back to Top ↑trading
Python Pandas and Trading Stuff
Post displaying the various ways one can highlight code blocks with Jekyll. Some options include standard Markdown, GitHub Flavored Markdown, and Jekyll’s {% highlight %}
tag.