Tag Archives: powershell

PowerShell Parameters for Modules

One for the personal digital scrapbook. When writing PowerShell modules I always have to dig this up as reference material and I’ve added an example as well.

about_Functions_Advanced_Parameters – https://technet.microsoft.com/en-us/library/hh847743.aspx

Obviously you need to  Export-ModuleMember  when you’ve created the function and save the file as .psm1 to identify it as a PowerShell Module.

After writing my personal use modules, I usually want them to load automatically when I fire up a PowerShell console so I add them to [Environment]::GetFolderPath('mydocuments') + "\WindowsPowerShell\Microsoft.PowerShell_profile.ps1"  usually in a try/catch block.


Automating upload to Azure Blob Storage

This is my latest effort in an attempt to offer myself slightly more robust backups of my personal website. I’m using PowerShell and Azure PowerShell to automate the process of zipping up a folder (actually my website’s application folder) and its associated MySQL database in to a zip file and finally, as well as storing the zip locally on-disk (yes, I know!…. wait for it!) uploading the file to Azure Blob Storage. Using some new functionality in .NET Framework 4.5 (zip files, yay) and Azure PowerShell to get the job done.

Here’s a quick snippet from the script:

I also ensure I’m optimising my use of Azure Storage by only retaining the latest 4 files in the target container and deleting anything older than 30 days on  the local machine. Run once per week, this will give you one month’s worth of backups and help you sleep a little easier.

Even without the MySQL dump integration, this is a handy script for backing up a folder and all of its child contents then uploading it for safe keeping to Azure Storage…. Continue reading Automating upload to Azure Blob Storage

Editing SharePoint Online User Profiles with PowerShell

Borrowing heavily from these TechNet contributors, I cobbled the following PowerShell script to enable editing of User Profile properties in SharePoint Online. Don’t just run the script blindly, it updates the AboutMe property for anyone with an email address – you’ll need to adapt what properties you want to update of course and also, this script does not update MultiValue properties but it probably isn’t too much of a leap to get to that from this either.

NB: Most of the comments below relate to access denied issues, this is caused by not connecting to the correct site. Ensure you connect ONLY to the administration site.


PowerShell .NET and GUI Interfaces

I’ve been grabbing a bit of software from Technet (you know, that thing that Microsoft are shutting down! <_<) and with their download links, they provide SHA1 hashes of the ISOs. I had a quick look around the web for something that allowed you to get SHA1 hashes of files and while I found a few, I didn’t find any that would allow you to provide a hash and compare the resultant hash with the one you’re given by the provider so I decided to write one myself and as with any opportunity, I decided to use PowerShell and .NET with Windows Forms to create a GUI interface as opposed to it all being text based. Sacrilege to those PowerShell purists but it’s a limited feature tool and I wanted to learn something new so here’s the code. Continue reading PowerShell .NET and GUI Interfaces