Azure Storage Services – Article Series on 4sysops.com

I recently started to post on 4sysops.com regarding Azure Storage Services.

Azure-regions

 

 

 

 

 

Here are the blogs in this series that I’m planning to publish:

Azure Storage Services — Introduction
Azure Storage Services — Accessing Services
Azure Storage Services — Storage Account
Azure Storage Services — Blob Storage
Azure Storage Services — Table Storage
Azure Storage Services — Queue Storage
Azure Storage Services — File Storage
Azure Storage Services — Premium Storage Benefits
Azure Storage Services — Security
Azure Storage Services — Useful Tools.

PowerShell Function to create colorful menus

I was preparing a PowerShell demo for System Center Universe and decided to use nested menus in order to easily browse between different demo sections. This is how it looks like in action.

Couple of simple loops checks for the inputs and redirects you to the next level/menu.

Creating loops and logic was simple but drawing menus and lines was not easy as I expected. This is what I came up after couple of hours:

Write-Host “╔════════════════════════════════════════════════════════════════╗”-ForegroundColor Magenta
Write-Host “║” -f Magenta -nonewline;Write-Host “UCP Director – API Call – PowerShell Demo Script 1.0” -f Green -nonewline;Write-host “`0`0`0`0`0`0`0`0`0`0`0`0║” -ForegroundColor Magenta
Write-Host “╠════════════════════════════════════════════════════════════════╣”-ForegroundColor Magenta
Write-Host “║” -f Magenta -NoNewline;Write-Host “Please select the admin task you require:`0`0`0`0`0`0`0`0`0`0” -Fore Cyan -NoNewline;Write-host “`0`0`0`0`0`0`0`0`0`0`0`0`0║” -ForegroundColor Magenta
Write-Host “║`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0║” -f Magenta
Write-Host “║” -f Magenta -NoNewline;Write-Host “`t1. Provisioning” -f Yellow -NoNewline;write-host “`t`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0║” -Fore Magenta
Write-Host “║” -f Magenta -NoNewline;Write-Host “`t2. Monitoring” -f Yellow -NoNewline;write-host “`t`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0`0║” -Fore Magenta
Write-Host “╚════════════════════════════════════════════════════════════════╝`n”-ForegroundColor Magenta

Pretty ugly right? This is why I decided to create a consistent function so that everytime when I want to create a PowerShell menu I can use it.

Hopefully my Basel to London fligth delayed for 2 hours yesterday (!) and I had enough time to code it in airport.

Here is the function on Technet gallery:

https://gallery.technet.microsoft.com/scriptcenter/Create-colorful-PowerShell-8689c5b2

Usage is quite simple and in couple of seconds you can have menus like below:

Capture

Cheers!

SCOM SDK – PowerShell – Creating monitor

 

icon_sdkOne of my customers wanted to monitor a 3rd party solution by monitoring events and asked if it`s possible with SCOM. As you probably know it`s one of the easiest tasks in SCOM to create monitors to monitor events on event viewer for specific or bunch of servers.

I was told to send them instructions to create a monitor based on Windows events. I started to get screenshots from create management pack and create monitor wizards, and then creating a group for the servers need to be monitored and finally overriding my monitor to enable monitoring for this specific computer group. At the end I realized it was about 30 page screenshots. Instead of sending these screenshots I though it would be much easier and sexy to send them a single PowerShell script to create a monitor. I thought SCOM Shell would have these cmdlets.

I was wrong.

Unfortunately, SCOM Shell doesn`t have any supported shell to create a unit monitor for Windows events. Then I decided to check SCOM SDK.

https://msdn.microsoft.com/en-us/library/hh329086.aspx

That was the first time for me to deal with SDK with PowerShell. SDK is much more powerful than PowerShell but you need to figure out how to deal with objects and methods.

There is an example to create a unit monitor by using SCOM SDK but as you may realize it`s written in C#. That was a good starting point for me.

https://msdn.microsoft.com/en-us/library/hh329015.aspx

So I started my journey, spent couple of hours to create my PowerShell script that uses SCOM SDK binaries. You can find the script below.

Please note that this is really an ugly script, no error handling, structure or sexy functions. This is just a sample to deal with SDK. If you are interested in to learn how to deal with SDK using PowerShell, it`s a good chance to open my script and C# example and see the integration between them.

Also SCOM MVP Tao Yang has done great job with Automating OpsMgr series on his blog http://blog.tyang.org/ .

He also shared with me an article yet to be written regarding monitor creation using SDK. It`s much more better than my ugly script 🙂 So if you need more details, follow Tao`s automation series.

My ugly script:

https://onedrive.live.com/redir?resid=3CAAB02B9CC620D5!57641&authkey=!AKbaImed7116Ig8&ithint=file%2cps1

 

The Power of Automation

 

IT automation has always been one of the most important goal of IT managers to make their organization run efficiently. Automation simply ensures that all resources will be allocated according to business needs dynamically.

Hu wrote a post on HDS community where he talked about typical break down of IT budgets.

https://community.hds.com/community/innovation-center/hus-place/blog/2015/04/23/software-defined-infrastructure-enables-greater-innovation-in-it

 

ITSpending

I also found another diagram on Gartner`s IT metrics report that shows us organizations are spending %66 of their time and budget to just “run the business”

Gartner IT Metric Report

These two diagrams simply show us that in order to grow and transform our business we should focus on innovation and reduce time/money spending on operating. That’s obviously not an easy task to achieve and can only be possible if your infrastructure is flexible and adaptable for these changes.

Couple of years ago, it was a straightforward task for IT administrators to manage/operate less data, servers, and applications. But now, every single minute hundreds of terabytes of data are flowing from “things” to our systems. Since IoT concept will be an enabler to different domains including logistic, transportation, automotive, healthcare and smart cities, in the near future every single “thing” will be sensor attached and connected to the internet/cloud. Analysts expect that 50 to 100 billion devices will be connected to the Internet by 2020.

IT administrators should handle not only this huge amount of data but also underlying components such as storage, network, servers, applications, hypervisors so on.

Unfortunately without having a true software-defined infrastructure approach, managing, maintaining or innovating could be impossible.

As my colleagues Paul Meehan and Paula Phipps mention, to design a software-defined infrastructure approach, we can use three A`s

Automation: 29% of IT time is spent on tedious tasks. 39% of IT outages are due to human error. Hitachi midrange VSP family eliminates tedious manual tasks, reduces errors and lets administrators focus on revenue-generating activities.

Access: Access more data and solve real-world problems

Abstraction: Provide more services faster with more flexibility to support a diverse set of applications.

Couple of years ago I was involved in a project. Customer was working for government and had very sensitive public IIS web sites. Development team was developing updates every two weeks and sending MSI update package to Operations team. This team was responsible to achieve following actions:

  • RDP to different DMZ servers. All servers were belong to different forests therefore they need to use different credential for each server.
  • Copy MSI package to servers, unzip it (No check if MSI damaged/working or not)
  • Call network team and ask them to disable pool member on Load Balancer
  • For each web site, stop IIS service, change webconfig file, install MSI (no check if its installed or not, no check on event viewer or log files)
  • Start IIS service
  • Call network team to revert back configuration
  • Connect another IIS web site….

Operation team was spending around one or two days to update all web servers in production.

But I think time was not the main problem. The main problem was human errors. According the researches, most of the storage, server or service outages are caused by human errors. For the above scenario, if operation guy changes wrong line in webconfig or network guy removes wrong pool member, production environment will have service outage.

However, as using a correct automation method, organizations can easily reduce these statistics and save more money/time.   Remember the first “A” – Automation.

Microsoft is investing in automating, enabling the use of different automation solutions such as PowerShell, System Center Orchestrator and Service Management Automation. These automation solutions can be used to automate not only Microsoft workloads but also cross-platform Linux workloads, Network and Storage solutions.

I believe PowerShell is one of the most important initiatives by Microsoft in recent years. It`s a scripting language with an easy syntax and developed for System administrators. Almost all of the new Microsoft products, on-premise or Azure based, have native Windows PowerShell support.

Orchestrator is the new version of Opalis, acquired by Microsoft in 2009. It`s a process automation solution and comes with System Center suite. If you are using Virtual Machine Manager or Operations Manager you already have an IT Process Automation solution as well. Simple dashboard, drag&drop workflow design. You can also use .NET Script activity to run PowerShell scripts in workflows.

And Service Management Automation built-on PowerShell workflows. It`s a web based process automation tool designed to work with Windows Azure Pack, local version of Microsoft Azure in your datacenter. It allows you to build SMA workflows to create, monitor, deploy and manage resources in your private cloud environment.

When it comes to Software-Defined Infrastructure and Automation, Hitachi offers a wide range of solutions.  The Hitachi midrange VSP family provides the foundation for software-defined infrastructures by making automation and abstraction easy with an integrated portfolio of infrastructure automation and virtualization software.

If you are using Hitachi`s converged solution, you already know that how it simplifies management of private cloud and data center environments. You can also combine Microsoft System Center / Windows Azure Pack suite with UCP and it enables an end-to-end Private Cloud platform with self-service / orchestration / automation capabilities.

http://www.hds.com/solutions/virtualization/microsoft-hyper-v/hitachi-ucp-for-microsoft/

This solution automates the management of servers, networking components and storage using UCP Director, System Center and Microsoft adaptors.

Hitachi integrates with Microsoft applications to create a unified automation/management solution for Microsoft environments.

These are the available adaptors provided by Hitachi:

  • Hitachi Infrastructure Adapter for Microsoft System Center Operations Manager
  • Hitachi Adapter for Microsoft System Center Virtual Machine Manager
  • Hitachi Storage Adapter for Microsoft System Center Orchestrator
  • Hitachi Storage Adapter for Microsoft® SQL Server Remote BLOB Storage
  • Hitachi Storage Adapter for Microsoft Windows PowerShell
  • Hitachi Storage Adapter for Microsoft Volume ShadowCopy Service

Especially adapters for PowerShell and Orchestrator enables you to automate and orchestrate processes using together Hitachi and Microsoft solutions.

Hitachi Storage Adapter for Microsoft Windows PowerShell allows Hitachi storage administrators to use PowerShell cmdlets on Hitachi storage systems. Using cmdlets, administrators can create scripts to automate complex tasks.

Hitachi Storage Adapter for Microsoft Windows PowerShell

Using Hitachi Storage Adapter for Microsoft System Center Orchestrator you can easily extend the capabilities of System Center Orchestrator.

Hitachi Storage Adapter for Microsoft System Center Orchestrator

This plug-in provides:

  • Storage management and Hitachi NAS (HNSA) support
  • Virtualized storage management
  • Hitachi Content Platform (HCP) management

Each activity uses built-in PowerShell processes to run on remote server and allows you to create workflows/Runbooks to automate complex tasks in your datacenter.

It`s really good to see how two different vendor come together and built a complete management and automation solution. One more time hats-off to Hitachi engineers. They created really valuable plugins and integrations with Microsoft/System Center suite. These adaptors combines the power of Hitachi performance, reliability and agility with the productivity of Microsoft solutions.

Unseal durumdaki Management Packlerin PowerShell ile export edilmesi

SCOM üzerindeki unseal management packlerinizi, üzerlerinde customization gerçekleştirmek için export etmek isteyebilirsiniz. Bu durumda Operations Manager Shell yani PowerShell cmdletlerini kullanarak tüm export işlemini tek bir script ile gerçekleştirme imkanınız bulunuyor.

Aşağıdakine benzer bir script işimizi görecektir.

$all = Get-ManagementPack | where-object {$._Sealed –eq $false}

foreach ($mp in $all)

{

Export-ManagementPack –managementpack $mp –path “c:MyMps”

}

Windows Server 8 – Manage Hyper-V 3.0 with PowerShell

One of the major feature of Windows Server 8 is Hyper-V 3.0 This new version of Microsoft virtualization platform brings great improvements and features.

In this blog post we’ll cover a couple of Windows Server 8 Hyper-V PowerShell command lets. Using PowerShell cmdlet will reduce most of day-to-day administrative tasks.

Open Windows PowerShell ISE and begin with first command;

get-vm

Get-VM cmdlet outputs all virtual machines that hosted on local Hyper-V server. As you seen above, it warns us about missing columns. To get more user friendly output, use Format List

get-vm_fl

Get-VM will give you a general idea about virtual machine’s state. That means you can use filters to get specific virtual machine states.

get-vm_2

I used Get-VM cmdlet again but with pipeline and $_. special character. It filters the output to show me only virtual machines that status fields equal “Operating Normally”

Another helpful command is Checkpoint-VM. This cmdlet starts snapshot process for specified virtual machine.

Try get-help to learn which syntax and parameters available for CheckPoint-VM

checkpoint_gethelp

I can use –name parameter to specify virtual machine.

Now firstly I used Get-VM to specify virtual machine and then pipe that information to Checkpoint-VM cmdlet.

checkpoint

As you notice, snapshot process began and finished.

checkpoint_status

Well, what about reverting Virtual Machines to the previous checkpoints? You can check all snapshots for a specific virtual machine with Get-VMSnapshot cmdlet. Required parameter is –VMName.

get-vmsnapshot

Now you have all checkpoint information for a specific VM. That means you can pipe this data to the Restore-VMSnapshot cmdlet.

In below example I used another method to pipe required data. As you see I use Get-VMSnapshot cmdlet’s name property as a Restore-VMSnapshot Name parameter.

But it gives me a confirm popup.

restore-vmsnapshot

If you want to automate administrative tasks through PowerShell, you need to suppress some of confirm dialogs. It is possible with –confirm parameter.

restore-vmsnapshot2

Restoring snapshot..

restore-vmsnapshot3

Let’s look at other cmdlets. Networking is a major component of Hyper-V. Get-VMNetworkAdaptor gives you network interface details of virtual machines.

get-vmnetworkadapter

Also you can use Get-VMSwitch to get Hyper-V network switch details.

get-vmswitch

Let’s try to add another switch to Hyper-V. You need to specify physical network adapter name with –NetAdapterName parameter.

new-vmswitch_hata

As you see above, it couldn’t find any related network adapter on local host. To learn your physical network adapter names just run Get-Netadapter.

get-networkadaptor

get-networkadaptor2

I assigned net adapter name which have a “UP” status value to a variable called $AdapterName.

Now execute New-VmSwitch cmdlet again. But I gives me another error:

new-vmswitch_hata2

It says my physical network adapter is already in use. Let me check.

get-vmswitch2

Yeap. There is already a Hyper-V switch that uses my current physical adaptor and has a “External” switch type. I can convert that Hyper-V switch type from External to Private. That will let free my physical interface.(Wi-Fi)

set-vmswitch

Now creating again.

new-vmswitch_ekledi

You can check from Virtual Switch Manager. As you see a new switch added and bind to physical network card.

hyper-v swicth ekranı

PowerShell can also be used to modify other virtual machine hardware components. Add-VMHardDisk attaches virtual hard disk files (VHD/VHDX) to a VM as additional disks.

add-vmharddisk_hata

But of course firstly you have to create vhdx file separately. Use New-VHD cmdlet.

new-vmdisk

Now you can assign previously created virtual hard disk to a specific VM.

add-vmharddisk_tamam

Here is our newly added disk on Hyper-V manager.

hyper-v disk ekranı

There are bunch of commands that helps you to manage Hyper-V 3.0 on Windows Server 8. In my next blog I’ll cover them.

Thanks.

Generate HTML Report for Mailbox Permissions with PowerShell

Greate PS Script from my friend Serkan.

This script creates a HTML Report showing Send as, Full Access and Send on Behalf Permissions information for each mailbox for your Exchange 2010 Organization, for a selected database or for a single user.

If your environment consist of Exchange Server 2010 and lots of complex mailbox/database permissions, just visit Technet Script Repository and give Serkan’s script a try.

http://gallery.technet.microsoft.com/scriptcenter/Generate-HTML-Report-for-da0f5132