How to add VLANS to Service Profiles in UCS Manager via PowerShell

We have had some unique cases where we need to add VLAN’s to a service profile’s vNic’s in the new Cisco UCS Manager. With the new HTML 5 Manager 3.1(2b) I am unable to make this change to all vNic’s templates. I have it push the change to all service profiles.

The solution was to write quick script that sets some variables, and adds the vlans to each vNic (in our case 2) for each service profile. I googled but was unable to find a quick and easy script. I decided to write my own and share it with you.

The requirements for this script to run properly are Cisco PowerTools and ensure that PowerShell remote execution is enabled.

Enjoy!

################################
# Author: Jeff Patton #
# #
# Date: 3/17/2017 #
################################

#Variables to be set by you.
$ucsserver = "172.0.0.20"
$hostsp = Import-CSV C:\Scripts\hosts.csv
$vlantoadd = "New-VLAN"
$identpoolA = "Pool-A"
$identpoolB = "Pool-B"

#Import Modules
Import-Module Cisco.UCSManager

You can create the VLAN’s via Gui or by using this script as well. If you want to create them in this script, remove the commented out sections called “VLAN Creation Section 1 and 2” in this script.

#VLAN Creation Section 1 - Connect to UCS Server
#Connect-Ucs $ucsserver -Credential (Get-Credential)

#VLAN Creation Section 2 - Optional Script to Add VLAN via CLI to Global LANCloud
#Get-UCSLanCloud | Add-VLAN -Name "DeleteMe" -Id "999"
#$vlantoadd = "DeleteMe"

#Script to Run
foreach ($part in $hostsp)
{
$sp = Get-UcsServiceProfile -Name $part.Name
$ethA = $sp | Get-UcsVnic -Name eth0 -IdentPoolName $identpoolA
$ethB = $sp | Get-UcsVnic -Name eth1 -IdentPoolName $identpoolB
$ethA | Add-UcsVnicInterface -Name $vlantoadd -Verbose
$ethB | Add-UcsVnicInterface -Name $vlantoadd -Verbose
}

Exchange Migrations with Power BI Help

When migrated users in Exchange it is imperative to ensure that shared mailboxes are migrated along with its assigned users or the permissions will not work. When migrating, it is always good to get a grasp on how many Shared mailboxes are in the organization. What a better way than by using Power BI Visualization to help in understanding the magnitude of the task at hand. The results are simple and intuitive.

I like to use the Bubble Visualization created by Dharminder Kumar Dhanda located here. This visualization encodes data in circles. In this application the bigger the bubble the more users have access to the shared mailbox. Thank you Mr. Dhanda for sharing your custom visualization with the Power BI Community.

Now to the guide!

First we need the CSV, from the exchange management shell we run the following command.

Get-Mailbox -resultsize unlimited | Get-MailboxPermission | where {$_.user.tostring() -ne "NT AUTHORITY\SELF" -and $_.IsInherited -eq $false} | Select Identity,User,@{Name='Access Rights';Expression={[string]::join(', ', $_.AccessRights)}} | Export-Csv mailboxpermissions.csv -NoTypeInformation

Next, we need to load the CSV as a data set.

Get Source Data

2

Once you have chosen the file you will notice that the column names do not match. We will fix this issue on the next step.

Select Edit.  3

Now we will need to select Transform and select Use First Row As Headers.

4

Below the headers have been corrected but our Access Rights column has unwanted data. In this case its not much but in some cases its messy.

5

We will cleanse our data by using the Split Column feature.

6

We will use the Comma as the delimiter and split using the “At the left most delimiter” option.

7

After the split occurs you will notice two things.

  • There is an additional column that contains the additional data.
  • The original Access Rights column has been renamed.

We do not need the new column thus it can be removed. Ensure you review the column carefully, sometimes the first feature is not “FullAccess” but “DeleteItem”, this seems to happen randomly and it not immediate noticeable. This can be corrected by filtering and using the “Does not Equal” filter on the “DeleteItem”.

8

The next step is to close and apply the changes.

9

The data is now fit for our reporting. The Query window will close and the Reporting window becomes the active window. While in the reporting window please import the visualization we downloaded at the beginning of this guide.

10 11 12 13

Once the new visualization has been imported, select it and it will appear on the reporting window.

14

From the reporting window chose the Mailbox column as the first feature then the users as the values feature.

15

Lets change the Title!

Change Title

We should see some progress now! At this point we can see the mailbox name and if we select it the number of users will access is displayed.

That is pretty exciting but we want to know who these users with access are. We can accomplish this by using the built in Matrix Visualization.

17

For the Matrix Visualization we must ensure that Mailbox feature is first then the User feature 2nd in the Rows section.

 

18

Now we can see the users that pertain to the Mailbox select or we can view them all at once.

19

Another option is to add a slicer which would allow the selection of more than one Mailbox at once for those who like to select multiple mailboxes at once.

This guide can be adapted for Public Folders, etc.

I hope this guide is useful and aid in communicating to peers, layman and of course the corporate folks.

 

Best PowerShell Exchange Health Report

Tools

There are many exchange tools on the web but this has been the most useful I have ever encountered. It provides a the bulk of what you need to know about an exchange organization. Every exchange admin should have this in their toolbox. Its called the Exchange Environment Report, it was developed by Steve Goodman Microsoft MVP.

This Report is like a Swiss Army Knife of reports.  It provides a comprehensive view on the exchange organization, from roles to database health, backup information, DAGS, mailbox counts, etc.. it includes this and more!

Enough bragging about it, you can get more information and a copy at Steve’s website or a direct download here. I would like to thank Steve for writing this awesome tool. Don’t forget to send him a message on Twitter!

 

Two step process to export a list of installed patches using PowerShell

desk-office-workspace-coworking

Building on the previous post Easy Server Inventory!

Not all businesses can afford expensive patch management solutions. Some organizations may have WSUS but not know how to use it properly or its outdated. Some of you may think SCCM can produce reports. SCCM is great when you have staff that can take advantage of it; for some its not a viable solution, because no one on staff has the skill set, price tag or a combination of time and/or money it takes to send someone to train on SCCM.

Scenario

The auditors, boss, corporate folks, etc. request a list or sample list of servers, they want to see  installed patches on each server with dates. A hefty proposition if you do not have one of these fancy applications that handle all of these things for you! No worries! Below is a quick way to keep things under control and provide the necessary information quickly and effectively.

Step 1

You can either gather a list of all servers in the domain via the AD Users and Computers, PowerShell or any other preferred method. You will use this to populate a txt file that will be used to feed the script.

Below is a script I like to use which can be useful for inventory, etc.

Export all servers to a friendly csv by running the following in PowerShell

Get-ADComputer -Filter {(OperatingSystem -Like "Windows *Server*")-and (Enabled -eq "True")} -Property * | Select Name,OperatingSystem,OperatingSystemServicePack,IPv4Address | export-csv Servers.csv -notypeinformation

*Added the (Enabled -eq "True") to filter only enabled Severs, thanks to the comment posted on Reddit by Master_apprentice .  -Thank you again

Step 2

Populate a file name servers.txt with the requested selection of servers.  Store this file in the same directory as the script below. The script below simply needs to be copied into either the PowerShell ISE or a notepad and saved as a ps1.

$ErrorActionPreference= 'silentlycontinue' # Allows the script to run in case of an error.

$servers = Get-Content -path Servers.txt  # Pulls the servers in question.

# The foreach below run the commands as the commands states for each server in the txt file.

# It then exports them to a useful csv.

foreach ($server in $servers)

{

(Get-Hotfix -ComputerName  $server | sort InstalledOn)| select CSName, Description, HotFixID, InstalledOn, RebootRequired | export-Csv -Path export.csv -append -notypeinformation

}

Once the report runs you will have a CSV with the information needed.

Easy Server Inventory using PowerShell – Minor Update

Easy Inventory with PowerShell

Ever need a quick inventory, well the following script pulls servers directly from AD. It cannot get easier than this. There is no need for fancy software or databases. Once the data is exported you can give it a facelift in excel and turn it in to the C level folks, share it with the team, your boss or perhaps you simply need a copy for yourself.

Export all servers to a friendly csv by running the following in PowerShell:

Get-ADComputer -Filter {(OperatingSystem -Like "Windows *Server*")-and (Enabled -eq "True")} -Property * | Select Name,OperatingSystem,OperatingSystemServicePack,IPv4Address | export-csv Servers.csv -notypeinformation

*Added the (Enabled -eq "True") to filter only enabled Severs, thanks to the comment posted on Reddit by Master_apprentice .  -Thank you again!

It can be saved as a script and set to automatically run as a scheduled task or use the script to feed a dataset somewhere with Power Bi, SQL, Access, etc.