Every once in a while, I need to have a nice way to monitor progress of a script. I used to add write-host messages and echo variables back so I could see counters – but, there’s progress bars for that. This is how you use them. #Progress bars for scripts # A Quick Array to have data $fruit = @('Apples','Oranges','Bananas') # # Main Activity is -Activity. Subtasks are -id 1

Well, it’s been some time since I decided I need to create Azure scripts for powering off and starting up VMs.  It’s probably been in my backlog over 2 years, but time’s escaped me. I’ve seen a few scripts that do parts of what I wanted to do and I’ve tried some that burnt through all the free processing time you get with an automation account, so I built my

Does PowerShell Truncate your output? Say for example you’re looking at output: ProxyAddresses: STMP: [email protected], smtp: [email protected], smtp: [email protected]… DOT>DOT>DOT!!!! Annoying right. Well, fix that with the following: $formatenumerationlimit =-1

Having Meeting rooms available in Office365 is one thing, but organizing them by office location or floor is super helpful. Here’s some powershell snippits to organize your rooms: $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection Import-PSSession $Session New-DistributionGroup -Name JaxConfRooms -DisplayName "Jacksonville Conf Rooms" -PrimarySmtpAddress [email protected] -RoomList Add-DistributionGroupMember -Identity JaxConfRooms -Member Jax.LargeConfRm Add-DistributionGroupMember -Identity JaxConfRooms -Member Jax.SmallConfRm New-DistributionGroup -Name BedfordConfRooms -DisplayName "Bedford

Here’s a quick one. Azure Storage tables. I have a function that is called Add-Entity that will add rows to the table and the powershell that does the lifting. # Function Add-Entity: Adds an employee entity to a table function Add-Entity() { param( $table, $partitionKey, $rowKey, $name, $id ) $entity = New-Object -TypeName Microsoft.WindowsAzure.Storage.Table.DynamicTableEntity -ArgumentList $partitionKey $rowKey $entity.Properties.Add("Name", $name) $entity.Properties.Add("ID", $id) #Entity is new data row inserted into table

New to Message queues in Azure? Here’s some samples for working with them. #Azure Message Queue Manipulation $StorageAccountName = "storage001" $StorageAccountKey = Get-AzureRMStorageAccountKey -StorageAccountName $StorageAccountName -ResourceGroupName "Storage" $storeAuthContext = New-AzureStorageContext $StorageAccountName -StorageAccountKey $StorageAccountKey.value # Create Queue $myQueue = New-AzureStorageQueue -Name 'myqueue' -Context $storeAuthContext # Create Queue Message $queueMessage = New-Object -TypeName Microsoft.WindowsAzure.Storage.Queue.CloudQueueMessage -ArgumentList 'Hello' #Can run next line a few times in a row to fill queue with data $myQueue.CloudQueue.AddMessage($queueMessage)

Sometimes you just need to get a list of all your users and the last time they set their passwords. This is a pretty quick and dirty way to do it. $reportObject = @() $userList = Get-ADUser -filter {Enabled -eq $True -and PasswordNeverExpires -eq $False} -Properties "DisplayName", "LastLogonTimeStamp", "LastLogonDate", "PasswordLastSet", "msDS-UserPasswordExpiryTimeComputed" | Where-Object {$_.DisplayName -ne $null} $userList | %{ $output = "" | Select DisplayName, passwordlastset, ExpiryDate, LastLogonDate $output.DisplayName =

Quick steps to deploy your first Azure RM based VM utilizing PowerShell. # Step 1 - Login Add-AzureAccount Login-AzureRMAccount # Step 2 - create a resource group $locName = "centralus" $rgName = "PowerShellVM" # Step 3 - Create a storage account $stName = "hscjhstore01" Get-AzureRMStorageAccountNameAvailability $stName $storageAcc = New-AzureRMStorageAccount -ResourceGroupName $rgName -Name $stName -SkuName "Standard_LRS" -Kind "Storage" -Location $locName $ Step 4 - Configure networking $subnetName = "VMSubnet" $ipName =

Here’s some quick snips to help work with Azure Storage. Everything from creating the storage account, to manipulating it with files. #Create Azure storage and manipulate it. #update with the name if your subscription $subscriptionName = "Pay-As-You-Go" #Give a name to your new storage account. must be lowercase. Can test this with powershell as well $storageAccountName = "teststorage001" #Choose location $location = "west us" #Give a name to your new