PowerShell – Getting Server IP Address Information

KB ID 0001404

Problem

I’ve been rebuilding some Hyper-V hosts over the last few weeks, and one thing I learned rebuilding VMware ESX hosts is, ‘make sure you know what all the network cards are doing before you flatten it!’

The same is true of storage as well but here I’m just concentrating on networking.

List Network Cards and MAC Addresses

If you have these documented you can rename the network card correctly after the rebuild and the mac addresses ensure you have the right names assigned to the right NICs. (Without having to go and check all the cabling afterwards!)

[box]Get-NetAdapter | Select Name, MACAddress, vlanID[/box]

List Network Teams and Members

From the names of the network connections above we can see we are using network teaming, but even if yours dont have sensible names, you can get the team names and the NICs that are a member of each team with the following command;

[box]Get-NetLbfoTeam[/box]

List NICs and IP addresses

To see what IP addresses are in use on which NICs, (physical or virtual) use the following;

[box]Get-NetIPAddress -AddressState Preferred -AddressFamily IPv4 | Select Name, IPAddress, PrefixLength[/box]

Hyper-V: Get vSwitch and Virtual NIC info

As stated above, I’m rebuilding Hyper-V hosts, the following lists all the Management vSwitch(es) and vNICS, (and their names).

[box]Get-VMNetworkAdapter -ManagementOS[/box]

Hyper-V: Get vSwitch and Virtual NIC VLAN info

In addition to above, I also need to know the VLANs the vNICs are on.

[box]Get-VMNetworkAdapterVLAN -ManagementOS[/box]

Related Articles, References, Credits, or External Links

NA

Exchange – Creating Dynamic Distribution Groups Based on Organizational Units

KB ID 0000820 

Problem

A Dynamic Distribution list, (as the name implies), maintains its membership for you. Unlike a normal static distribution list that you need to add/remove mailboxes manually.

Solution

Use PowerShell/Exchange Management Shell

1. I’m assuming you already have an OU populated with mail enabled users, in this example called Engineering.

2. Launch the Exchange Management Shell, Execute the following command, (change the values in red to match your own);

[box]New-DynamicDistributionGroup -IncludeRecipients MailboxUsers -Name “Engineering Dept” -OrganizationalUnit Engineering[/box]

Note: In this example the ‘Alias’ can’t be created with a space in it, so it would be EngineeringDept@domainc.com.

Exchange 2013 Use the Exchange Admin Center

1. I’m assuming you already have an OU populated with mail enabled users, in this example called Sales.

2. Launch the Exchange Admin Center > recipients > Groups > Add > Specify a Name and Alias > Browse to the OU > Save.

 

Exchange 2007 / 2010 Use the Exchange Management Console

1. I’m assuming you already have an OU populated with mail enabled users, in this example called Sales.

2. From within the Exchange Management Console > Recipient Configuration > New Dynamic Distribution Group > Browse > Select your OU > Specify a Name and Alias > Next.

3. Specify the recipient types or click next to select All.

4. Specify any conditions > or leave blank to select none > Next > New.

5. Finish.

 

Related Articles, References, Credits, or External Links

NA

 

Exchange – Enable ‘Out Of Office’ For Another User

KB ID 0000843

Problem

Got in the office to find a colleague was going to be on long term sick this morning, the boss asked, “Can we turn on his out of office?”. I could have simply changed the users password and logged into OWA and done it, but executing some PowerShell would be more elegant.

Note: You must be in one of the following groups to carry out this procedure, Organizational Management, Recipient Management, or Help Desk.

Solution

Powershell Syntax

[box]

Set-MailboxAutoReplyConfiguration -Identity username -AutoReplyState Enabled/Disabled/Scheduled [-EndTime DateTime] [-ExternalAudience None/Known/All] [-ExternalMessage message] -InternalMessage message [-StartTime DateTime]

[/box]

Note: Remember the dates need to be in ‘American date format’ or the command will fail.

Example

[box]

Set-MailboxAutoReplyConfiguration -Identity 'PeteL' -StartTime '08/12/2013 08:00' -AutoReplyState Enabled -EndTime '12/31/2013 23:59' -InternalMessage 'Pete is currently out of the office' -ExternalMessage 'Pete is currently out of the office, please contact the helpdesk for technical assistance' -ExternalAudience 'All'

[/box]

 

Related Articles, References, Credits, or External Links

NA

Cisco ASA – View The Contents of an Object and Object-Group

KB ID 0001043 

Problem

My colleague loves the ASDM, I put up with it and prefer command line. We were troubleshooting a problem the other day and he said, there this is why I prefer the ASDM, just ‘hover’ over an object-group and it will show you the contents of it.

Now if (like my test firewall above) you only have a few hosts, then I don’t see the point, but if you have a very complicated config with hundreds of object-groups and thousands of hosts, even troubleshooting why host ‘x’ can’t get to server ‘y’ on port ‘z’ can be a painstaking process.

So I dropped to CLI and tried to do the same;

[box]

Petes-ASA(config)# show object-group Obj-ALL-PROD-DMZ
                                   ^

ERROR: % Invalid input detected at '^' marker.

Petes-ASA(config)# show object-group network Obj-ALL-PROD-DMZs 

                                           ^

ERROR: % Invalid input detected at '^' marker.

[/box]

 

Solution

View Contents of an Object Group

Turns out you need to use the ‘id’ parameter, or it won’t work;

[box]

Petes-ASA(config)# show object-group id Obj-ALL-PROD-DMZs

object-group network Obj-ALL-PROD-DMZs

network-object 192.168.110.0 255.255.255.0

network-object 192.168.121.0 255.255.255.0

network-object 192.168.130.0 255.255.255.0

network-object 192.168.141.0 255.255.255.0

network-object 192.168.140.0 255.255.255.0

network-object 192.168.210.0 255.255.255.0

network-object 192.168.220.0 255.255.255.0

Petes-ASA(config)#

[/box]

I’ve been using that a lot this week.

View Contents of an Object

If you try an to the same this for an object, you will get nothing, you need to add the run keyword as follows;

[box]

Won't Work!
Petes-ASA# show object id Internal_RDP_Server    
object-group Internal_RDP_Server does not exist
Petes-ASA# 

Use 'run'
Petes-ASA# show run object id Internal_RDP_Server
object network Internal_RDP_Server
 host 192.168.100.10

[/box]

Related Articles, References, Credits, or External Links

Original article written 25/03/15