Thursday 22 January 2015

Filtering Output with PowerShell

So the next thing to look at in PowerShell is how to filter output from a cmdlet. A good example is Get-Mailbox, a cmdlet that gets you information on the Exchange mailbox settings of a user. This cmdlet has dozens of properties and this gets even worse if you want to see the mailbox settings of all your users at once. Clearly you need some way of just displaying the properties you want to see and excluding the ones you don't need. This can be done using the Select-Object cmdlet and is very simple. We simply pipe the output of Get-Mailbox into Select-Object and specify which properties we want to see.
get-mailbox | select-object
and then specify the names of the properties we want to see out of get-mailbox

So here is an example that produces a CSV file by piping the output from Select-Object to Export-CSV. Note that Select-Object has an alias, select, which I can use to abbreviate it.
 get-mailbox |select name,primarysmtpaddress,forwardingaddress,forwardingsmtpaddress,delivertomailboxandforward | export-csv -notypeinformation -path c:\users\p.dunford\bbb.csv
This gives me a nice CSV list of all the users in these specific mailbox properties only.

Powershell has a lot of useful stuff to do with filtering either properties or the objects that are being returned where you are getting more than one object in a cmdlet. As we see above I used get-mailbox without specifying a particular instance. This returns all the mailboxes on the Exchange server. I could also have the option of using a query to return a set of particular mailboxes. The cmdlet to do this is Where-Object, alias where.

For example, if I want to return only those maiboxes where ForwardingAddress is set to something, I can do this using the command string below:
get-mailbox | where {$_.ForwardingAddress -ne $null}
Note in this case I'm using $_ to refer to the current object instance.

That result could then be piped into select and then to export-csv to get the list in a file as above.

PowerShell's capabilities in filtering objects and properties are far more powerful than the old Windows command interpreter or various VBScript kludges.

Monday 19 January 2015

Using PowerShell with Active Directory [2]

So back last year I talked about using Powershell to do stuff with Active Directory. At the time I thought it was imminent I would have to run some scripts to change some stuff in AD.

The occasion I was looking at at the time hasn't materialised yet but something similar came up today to be worked on. We have to redirect some user's email addresses as part of a Google Apps migration to forward from Exchange to the new Google Apps account.

In this case I am employing two steps:

1. Create mail contacts in Exchange for the new email addresses.

Firstly I exported the mailboxes from the Exchange Management Console which gave me a TSV file. Opening this in Excel I changed it to CSV and it has the following columns with typical data

Name,EmailAddress,NewEmail,NewAlias
John Smith,j.smith@old.domain.nz,jsmith@new.domain.nz,JohnSmith|new-domain-nz

Then my script looks like this

$staffaddresses = Import-CSV "C:\Users\p.dunford\documents\staffaddresses.csv"
foreach ($staffaddress in $staffaddresses)
{
    $ContactName = $staffaddress.Name + " (new.domain.nz)"
    $DisplayName = $staffaddress.Name + " (new.domain.nz)"
    $proxyAddresses = "SMTP:"+$staffaddress.NewEmail
    $Alias = $staffaddress.NewAlias
    New-ADObject -Name $ContactName -DisplayName $DisplayName -Type contact -OtherAttributes @{'mail'=$staffaddress.NewEmail;'proxyAddresses'=$ProxyAddresses;'mailnickname'=$Alias; 'targetaddress'="SMTP:"+$staffaddress.NewEmail}
}

So basically we are calling a standard function, New-ADObject and setting some attributes. This causes the object to be created in Active Directory. The OtherAttributes parameter is the useful one that contains a whole lot of attributes you need to set to create a mail-enabled contact and set its email address to something useful. Actually this is all the special ones like department or location that aren't exposed as standard parameters.

As noted in the previous article, this can be run on a workstation (rather than a DC) provided that it has RSAT installed.

We are using Import-CSV here to pipe in the CSV list for the contacts.

2. Set up the forwarding in Exchange to the new email address

Whereas the Exchange Management Console will only let you set forwarding based on a contact object, in a script you don't have this limitation. Because it uses a contact, EMC sets ForwardingAddress based on that contact. But usually with Office365 I have used ForwardingSMTPAddress instead, which just uses the actual email address. Apparently these properties are mutually exclusive and if you set ForwardingSMTPAddress in a script then you get a warning if ForwardingAddress is set as well. Presumably ForwardingAddress takes precedence.

The relevant cmdlet in this case is Set-Mailbox. You have to give it a name in order to find which mailbox you want to change, and then the relevant parameters for forwarding are
-SetForwardingSMTPAddress
This is the email address you are forwarding messages to. It should be prefixed with "smtp:" (EMS will automatically add this if you omit it).
-DeliverToMailboxAndForward
Set this to True to have the message copied to the Exchange mailbox and forwarded as well. If set to False then the message is forwarded without being copied to the Exchange mailbox.

I use this Cmdlet quite often with Office365 to set up forwarding because that wasn't an option in 365's admin interface (unlike the Exchange Management Console). Note that this time you need to run it in the Exchange Management Shell on the Exchange server.

If you are using Exchange on-premises (as opposed to hosted Office365) then you may need to set up a remote domain to allow automatic forwarding otherwise this may not work.

So far our forwarding isn't actually working - this is just an example but there is something else going on with our configuration that isn't allowing the forwarding to work at the present.

Thursday 1 January 2015

Antec ISK110 complete

20150101-172651_IXUS135
This is what it looks like with the front cover on. This cover is almost entirely grille to provide adequate airflow. There was little evidence of heat except through the louvres at the top where the power supply board is, as this is passively cooled by airflow. It has the supplied stand fitted on the bottom which is designed to allow airflow through another set of louvres; it also comes with a VESA mount bracket to go on the back of a display. I have installed Win8 Pro 64 bit and am still testing things out and haven’t completed playing with the unit but it is basically ready to do something with. Whether that something is a HTPC or a small portable PC is yet to be determined. I imagine from here we will do some testing to see that it is capable of doing a lot of different things and then take it from there. For now it has to go into the cupboard as I have a lot more stuff to do over the next few weeks with unpacking the house and getting ready to go back to work, it’s going to be a big year in 2015. So a great start to the year with this little wee computer. The next few posts will be a comparison with the T5720 thin client, the NUC and with Silverstone’s MILO series as alternative case types. Anyway the only noise you hear is the internal fan and the newer Gigabyte boards with passive cooling will be virtually silent.
Total cost of system approx is as follows:
  • Chassis with power supply $125
  • Motherboard with onboard CPU $150
  • 4 GB memory $75
  • 2.5” Scorpio Blue HDD $100
  • TOTAL $450
So that is not bad at all, $450 for a PC (without an OS of course)  and it only takes up a little space and is really portable (a biggie for me with limited transport options). In my case I already had all the parts except the chassis making it a really useful upgrade of an existing computer that was sitting in a big tower chassis. It has 8 USB ports, and can drive 2 displays – VGA and HDMI.

Gigabyte GA-E350 WIN8 vs Gigabyte GA-J1800N-D2H vs Gigabyte GA-J1900N-D3V Mini-ITX Embedded CPU Boards

I have two of the GA-E350 WIN8 boards, which is now an obsolete inventory line as far as Gigabyte is concerned. However they have proved to be vastly superior to the Intel D2700MUD boards which I had three of, all now given away to the local school. As we can see now, Gigabyte has replaced the E350 model with its AMD Brazos E350 dual core embedded CPU, with models that contain Intel Atom Bay Trail embedded CPUs. Given my negative experience with Intel’s D2700 boards and subsequent decision to stop using Intel desktop boards in my projects I am obviously wanting to see if Gigabyte can hold Intel to account with their choice of using the Atom CPUs in their newer model Mini-ITX boards. By the way, what’s special about Mini-ITX? Developed by VIA, it is a square motherboard measuring 170x170 mm and fits a corner of microATX formfactor, thus Mini-ITX boards will fit into a chassis designed for Micro-ATX. These are a range of very small form factors intended to build various types of tiny PCs and are usually optimised for very low power consumption. VIA has also developed a number of even smaller versions of ITX but there has not been such an uptake from other board makers and VIA’s own versions of these boards cost hundreds of dollars. Mini-ITX is becoming a formfactor of choice in the commercial sector for embedded and industrial applications, which was VIA’s original target market for the formfactor, while in the domestic world, Home Theater PCs using small chassis are a popular application. Where did ITX come from? VIA designed ITX in 2001 with a 215x191 mm reference board. ITX was similar to FlexATX so it did not get uptake from board makers. Mini-ITX was developed in the same year and became popular so other board makers took it up and started making them.

Intel’s introduction of the NUC formfactor will give the Mini-ITX a run for its money. However I am preferring Mini-ITX because it is less proprietary than the NUC and so you aren’t locked into special NUC chassis and boards which end up costing more for the spec. So I didn’t want to fork out for NUC, tempting though it was, when I already had these two GA-E350 boards that just needed new chassis to be useful.Another interesting development from Intel, apart from NUC, for low power is the Minnowboard Max which is supposedly a prototyping system but I would guess with ability to run a full operating system and do useful stuff at a cheap price. However it could turn out that the graphics or whatever aren’t very good for video playback and the pricing I have seen so far for NZ is anything but cheap. So I think we could rule out that one for any sort of HPTC scenario. The Minnowboard is really aimed at competing with the Raspberry Pi and should be in a similar price range but as I say I have not seen any indication of this, it may possibly be the case that it is not yet officially available here and the pricing will improve when that changes.

So the GA-E350 vs the two newer boards is what this article is about. And I am focusing on the embedded CPU range of boards. Like other manufacturers Gigabyte produces socketed CPU mini-ITX boards as well, but the issue with those is going to be higher price and possibly more power usage. The latter is an enemy for the Antec chassis I have because of the maximum power of 90 watts at the input, which is probably around 80 watts at the output. A CPU for a socketed board is probably going to cost you at least $100 and jack the price up by that much. That amount would buy a G3220 Pentium similar to the two desktop boards I have which both have Pentium G CPUs in them, you would pay a lot more money for a Core. The socketed boards are designed for Pentiums and you won’t buy an Atom off the shelf easily to go into one of them, so for low power / HTPC your choices are limited to embedded CPU. Socketed CPUs are aimed at an enthusiast market and aren’t really what Mini-ITX was designed for originally.

The main differences in the boards apart from the CPU and chipset are they are really a modernisation of the GA-E350. The J1800-D2H is very similar to the GA-E350 with the rear panel connectors, adding a USB3 outlet to the existing four USB2 sockets. The parallel port connector has been removed and empty space left in its place, as has the serial port connector, although there is still a serial header on the motherboard. You still have the PS/2 mouse and keyboard connectors, VGA, HDMI, network and audio connectors as on the earlier model even though the PS/2s in my mind are wasting space. The power connectors on the board are standard at 24 pin ATX and 4 pin CPU. The D2700MUD didn’t require the 4 pin CPU connector which let it be used with some older model PSUs. That was the attraction that led to me putting them into recycled Foxconn TS001 chassis that I had with older PSUs that only had a 20/24 pin ATX power connector and no 4 pin CPU connector. As mentioned you have the serial header and also a parallel header on the board; the usual front panel and FPAudio headers; chassis fan header; and one USB dual port header. There are just two SATA sockets on this board and expansion capabilities are taken care of with a PCIe 1x slot and a Mini-PCIe slot. There are two memory slots which are now SODIMM slots for dual channel instead of the DIMM slots for the E350 which were for a single memory channel. Up to 8 GB of memory is supported.

The J1900-D3V is somewhat more upspec and fascinatingly different. The rear panel has PS/2 keyboard and mouse separate connectors, two serial ports, VGA, DVI-D, audio, and two sets of identical connector groups in which each group has a RJ-45 and two USB3/USB2 sockets. So it is definitely aimed at a more industrial role than the J1800-D2H as shown by the serial ports, DVI and extra network connectors. Internally it is similar to the J1800-D2H with a parallel header, single USB2 9-pin dual socket header, MiniPCIe socket and reverting to a PCI expansion slot, and keeping the SODIMM memory sockets with dual channel and 8 GB memory supported.

Overall there is a small difference in the price of the boards but it is clear than the D2H boards are the ones which are possibly more useful for home users since the old PCI socket has less and less useful boards made for it. The PCIe x1 socket is somewhat limited but there are apparently some low end graphics cards that can use it. Do your research and check out reviews for these boards if you are looking for HTPC applications because I am still suspicious of Intel given the lies over the D2700 MUD when their graphics driver turned out not to provide the promised playback spec and they decided they couldn’t be bothered producing a 64 bit driver, only 32 bit. In particular Intel’s mini ITX boards to date have been deliberately crippled and as usual we have to go to Gigabyte or other manufacturers who can get us a higher spec board for no more money.