Powershell Here

Remember the Power Toys where you could add open prompt here? Did you know there is an even easier way?

Navigating the file system isn’t that hard in the Powershell CLI to start with considering tab completion and all of that but there is an even easier way….

In your file explorer window type powershell in the address bar. A new Powershell window will start and as the included video a simple get-location will show your working directory is same as the explorer window you launched powershell from. It may look different than what you expect when starting the Powershell CLI but you can change that with the window’s defaults settings.


A quick example (video) here.


Stop loading iTunes

Yeah I am an iPhone user these days. No I don’t need to have the software installed but I installed it. Now when I plug my phone in, just to charge, stupid iTunes loaded. I have a ton of windows open pushing my laptop to the max so sometimes clicking on the x to close the window just doesn’t work… my new favorite one-liner is now…

(Get-Process -Name iTunes).Kill()

So of course I took this and added it to my profile.ps1

function kill-itunes
    param ()
    (Get-Process -Name itunes).Kill()


Very handy

mukesh notes

This PowerShell script can be used to download some of the common cloud (Azure and AWS) management tools available on Windows Platform.

Earlier I had seen Download and Install SharePoint 2013 Prerequisites on Windows Server 2012.  However this technet script uses Start-BitsTransfer cmdlet from BitsTransfer module. I was toying with similar idea while working on my last workshop (Cloud Automation Using PowerShell) preparation. Since some of the URLs do redirect the Start-BitsTransfer wasn’t working for me initially.

I started with simple Invoke-WebRequest cmdlet and added second variation to handle redirected URLs and pass it to Start-BitsTransfer. So let’s go through the script and output for the both the approaches.

I am using Downloads directory to store the files. For demo I have created CloudTools folder inside. I already have AWS Tools for Windows PowerShell downloaded in the folder.


I am already into the working directory where the script is saved.

View original post 607 more words

Quick Hit – PowerCLI as a Module and Loading it up

PowerCLI is a great tool, has been since about day one of Powershell. As Powershell has progressed and PSSnapins where replaced with Modules, PowerCLI took a long time to make the jump to modules. While stiff functional it was a point of question. So with version 6 it is mostly modules which is great, however now I have to tweak my Powershell profiles. Much like other customized shells (Operations Manager, SharePoint, etc …), I hate the single purpose shells so I had to customize my profiles. So what I have put together is real simple, and gets me started loading it up:

(get-module -Name vm* -ListAvailable).Foreach{Import-Module $_.Name}

Where is it…

So I have been really liking the new Script Browser (http://blogs.technet.com/b/onescript/archive/2014/05/11/what-s-new-in-script-browser-amp-script-analyzer-1-2.aspx) add-on for ISE. Surprisingly I am liking it for the Script Analyzer. Surprising? To be honest I have not been a fan of the recent Scripting Games and all of the judges’ feedback regarding aliases and other commonly used practices. I do see the point but for me, I write the script, make it work and then if I have to make it public I will go through and comment the code to a sickening level. I love what Mr. James Brundage (http://www.start-automating.com/) has brought to the Powershell community but Script Cop angered me 🙂

Since I spend time trying to bestow the strengths of Powershell amongst my colleagues, I am starting to use Script Analyzer to clean up my code before sharing.

The support with the “add-on” has been great as well. With version 1.1 I had encountered some “features” and submitted an email inquiring. The response was quick and a great help.

Since Powershell V3 I have been using the ISE exclusively as my editor and this set of add-ons just makes that experience better.

So what am I posting about? I had the feature installed and working and using the toolset. Then I rebuilt my machine (Bare Metal) to Win7 x64 and of course tried to reinstall the product. Hint, we use roaming profiles. I could net get the install to work, always getting to a point where it wanted a path to a setup.msi file. I tried a few things and was about to send an email to see where I should look in the registry. I wish there was a better code display plugin for wordpress but the details of where I found it…

HKEY_USERS and within my hive it was withing Software\Microsoft\Installer\Products

Once I removed the key from Products, I was able to cleanly install Script Browser.

I said no Confirm…..

So I have been pulled away from Powershell (at least in day to day work) and getting back into it on a project by project basis. Yeah I miss it. Enough of that…

So another product I am getting back to is Exchange. Even better is as I have moved into the Exchange team, the product (currently using 2010) has some decent Powershell modules. I do find them weak in a forest and the documentation is far from what he have been used to with Powershell. I was able to work on a few scripts for the migration, one of them was dealing with shared calendars, sadly eventhough the script updated permissions it was documented that you still needed to open each mailbox and set calendar permissions…..

Onto another usage. How can you delete an email from mulitple mailboxes? Search-mailbox is the answer. Again the documentation (http://technet.microsoft.com/EN-US/library/9ee3b02c-d343-4816-a583-a90b1fad4b26(EXCHG.141).aspx ) is a little lacking especially for the most important parameter, SearchQuery. I started by using my mailbox as the test case (not to mention it was a good way to clean up my mailbox) and came up with:

get-mailbox someaccount-domaincontroller somedc |

Looks good, hey what is this Confirm prompt? I said no to that. So then I tested without the confirm parameter… okay setting it to false stopped some confirmation prompts but not all. I need to run this against mutliple mailboxes, I don’t want to require someone to man the process and type A with each mailbox… Let’s try something else. The winner:

get-mailbox someaccount-domaincontroller somedc |
search-mailbox -SearchQuery ‘From:”someuser@nodomain.com”‘ -deletecontent -confirm:$False -Force

Adding the Force parameter suppresses all confirmation prompts, mission accomplished.