Mastodon

Thursday, 20 June 2013

Adding modules into PowerShell 3.0 ISE for services running on other machines

In my last blog I talked a little about the new Commands menu within the PowerShell 3.0 ISE, the ability to view all the cmdlets relating to an individual module, and then use it to build a command.

It's a great feature and of course there are a lot of modules out there for different applications and services. As you install new roles and features that use their own set of modules the installer adds those modules into the list, so by default the PowerShell ISE modules list contains all the modules relevant to the local installation.

But what if you want to write your script and insert cmdlets into it on a machine that doesn't have those roles or features installed? You could install the relevant management pack, but that seems somewhat overkill to me.

The other option is to simply copy the relevant files from a machine that already has them.

All of the module files installed on a machine can be found in :

c:\windows\system32\WindowsPowerShell\v1.0\Modules\

with an individual folder for each module installed. These obviously get loaded when PowerShell ISE loads.

To make these available on another machine, for instance making the DNS Server module show up on your desktop machine, simply copy the relevant folder(s) (in this case DnsServer) from a server that it's installed on, into the modules folder on your target machine (your desktop).

The next time you load the PowerShell ISE you'll find the module and its list of cmdlets listed and available for use. This way on one machine you can have all your required modules, be they SQL Server, Exchange Server, Active Directory, DNS Server etc on a single machine.

Update:

Just to avoid confusion, my intention when finding this method was simply to allow me to write the code on my local machine, NOT to allow me to execute the cmdlets locally. Using the -Computer parameter to specify the machine to run the command against won't work, since your local machine is missing the required dll's. That said, if you've established a connection to the remote server, eg using Enter-PSSession, then the cmdlets generated on your local machine can be run since you're using the dll's on the remote machine not the local ones.

 

Wednesday, 19 June 2013

PowerShell v3 and new features including DNS Server cmdlets

With the introduction of PowerShell v3 in Windows Server 2012 we now have a new collection of cmdlets to play with, and amoung them are a collection of cmdlets for controlling and administering DNS Server.

As someone who's been rewriting many old batchscripts to use PowerShell, and is also in the process of migrating to a new 2012 DNS setup this obviously came as great news. No more using PowerShell as a wrapper for dnscmd or having to dig into WMI calls. Unfortunately as is often the case being up to date has its drawbacks, yep, you guessed it, there's a definite drought of documentation out there explaining how to use it all. There are other additions as well, but DNS Server's the area I've been playing with recently.

For a straight forward list of DNS cmdlets check out http://technet.microsoft.com/en-us/library/jj649850%28v=wps.620%29.aspx. Once you know which cmdlet you need the easiest option is perhaps to use the Commands menu within the PowerShell v3 ISE, which if not already displayed on the right hand side can be viewed by selecting View and then Show Command Add-on.

Using the new commands menu definitely helps, for any cmdlets you haven't used before. Selecting the DnsServer option from the modules list gives you a list of the available cmdlets in that category, and selecting one of them displays the parameter details for it. Note, where the options change depending on what you're doing (for instance using Add-DnsServerResouceRecord, where A records have different options to MX records etc), you'll see tabs along the top to allow you to select the required set of parameters. Simply fill in the required text boxes, and then click Insert, the complete PowerShell command line using those parameters will be created in the bottom window. Either run it there or copy and paste the code into your script.

If you're unsure which details need to go into which box, the -WhatIf parameter will let you know what your current selection would do if it was run (without actually doing it and potentially doing something wrong / unexpected). The WhatIf parameter isn't new to v3, but its combination and availability in the commands menu makes it even more useful. One thing worth noting about the -WhatIf parameter is that it gives an overview of what will happen, not always the exact detail. Take the following example :

Add-DnsServerResourceRecord -DomainName mail.domain.com -Name _autodiscover._tcp -Port 443 -Priority 0 -Srv -Weight 0 -ZoneName foo.com -WhatIf

The output produced will be :

What if: Adding DNS resource record _autodiscover._tcp of type SRV in zone foo.com on MYSERVER server.


You'll see that it confirms the command will create the resource record, that it's an SRV record, where it is and in which zone, but not the finer details. So if you put the port details in the wrong place then WhatIf won't help.

That's enough for now, the next couple of blogs will be looking at specific DNS Server cmdlets and how they can be used.

Wednesday, 17 April 2013

Making Windows 8 that little bit more usable



First of all, let me just say that I actually really quite like Windows 8, so don't expect this to deteriorate into a list of reasons why you shouldn't bother. I upgraded my home desktop almost as soon as I could get my mits on the upgrade, and it's been running on my work desktop for a little while now.

Once I'd got past the initial confusion everyone gets on seeing a new way of doing things, and focused instead on how I actually use my machine and the benefits available in this version, I was well and truly a convert. Yes TIFKAM (The Interface Formerly Known As Metro) jars a little at first, no I really don't like it, however and this is the important point, I hardly ever use it! Since Windows 7* introduced pinning your apps to the task bar I've generally had all my regularly used apps pinned, so I rarely needed to click start for anything other than shutting down. So if I didn't use the Start menu in 7, I probably won't use TIFKAM in 8, so it doesn't matter what it looks like!

All that said, there are a number of little tips and tricks I've discovered to resolve some of the little annoyances, and make Windows 8 far better (in my opinion) than it is out of the box. I figured I'd write about them here, if they help someone else then great, if not I've got a handy crib sheet if I need to set things up again in the future.**


  • For quick access to the desktop when starting Windows, drag the "Desktop" tile on the start menu to the top left hand corner. This then becomes the default tile and is already selected. When you login to Windows and are presented with the Start menu, simply hit return and you'll be at the desktop.
  • To start your applications without needing to use the Start menu the simplest way it to pin them to your task bar. Once they're running, simply right click the taskbar icon, and you'll see an option to "Pin this program to the taskbar". When the app is closed the icon remains without the box surrounding it, making it easy to start next time. You can also re-order them by dragging and dropping them into the order you prefer.
  • If you can't find an app, either type its name in the Start menu to search for it, or (and this isn't always obvious), right click in some empty space and you'll see an option for "All apps" which will being up a complete list of them.
  • Accessing the Shutdown/Restart menu can be done in multiple ways, moving the mouse to the bottom right and selecting settings, pressing Windows-C to access the Charms menu, or Windows-I to go direct to the Setting Charm, but if nothing is open or no applications are selected (eg you clicked on the desktop / taskbar) you can press ALT-F4 to go direct to the menu.
  • If you like having easy access to My Computer, documents, the Control Panel etc, you can get a measure of this functionality back via a taskbar toolbar. Right click on the taskbar, go to Toolbars and select Desktop. You'll now see on the right hand end of the task bar a new entry title "Desktop >>", clicking on the >>'s gives you access to many of those things you previously had through the start menu.
  • And finally, if / when you accidentally open something in Metro mode (it loads full screen, and the taskbar etc is no longer visible) it's simple enough to get back to the desktop, however you'll notice a lack of familiar x to close the application. In Metro mode, move the mouse to the top middle of the screen and the mouse changes to a hand icon, click and drag down until the application is gone (effectively dragging the application off your desktop).

Next post will be some of the useful changes you can make in Office 2013.

* It may have started in Vista, but I never used it and prefer to think of it as a beta version of Windows 7!

** Note, there are various add-ons and start bar replacements out there but I haven't touched them. I spend enough time supporting other peoples machines that I don't want mine moving too far from the default.

Sunday, 18 November 2012

Windows 8 and importing VirtualBox VM's into Hyper-V

Upgraded to Windows 8 this weekend and it's definitely nice and painless. Other than the new start menu and the loss of Aero it's really not much different to Windows 7 externally, and after the upgrade all my apps continued to work like before as if nothing had changed.

The only real issue I had initially was with VirtualBox. The version I was running won't run on Windows 8 (the latest might do), but that wasn't an issue as I was already planning to switch to using Hyper-V instead. Importing my existing .vhd's into Hyper-V should have been straight forward, but I kept getting errors similar to this :

---
New Virtual Machine Wizard
The Virtual machine management service encountered an error while configuring the hard disk on virtual machine <Guest name>.

Failed to add device 'Synthetic Disk Drive'

'<Guest name>' failed to added device 'Synthetic Disk Drive'. (Virtual machine ID xxx)
 
The Virtual Machines configuration xxx at '<Hyper-V Path>' is no longer accessible: The requested operation cannot be performed on a file with a user-mapped section open (0x800704C8)
---

when I tried to create a new VM using the existing vhd as the disk. The issue turned out to be AVG and its resident shield scanning the files as mentioned here http://support.microsoft.com/kb/961804, once I'd excluded all those folders I was good to go and things started working.

Wednesday, 31 October 2012

Changing the cPanel "Configure Email Client" server addresses in WHM 11.34

One of the great things about cPanel is how easy it makes it for non-technical people to use, for instance within Email Accounts, clicking More and then Configure Email Client provides you with links to automatically configure several email clients, or the details required to do it manually. The data is automatically generated to show the relevant domain's POP3/IMAP/SMTP server details (specific to each domain), but what if you prefer to have a single set of service addresses, how do you update this page to show your preferred details.

In the previous version it was quite simple, you simply edited the clientconfinclude.html that's found within /usr/local/cpanel/base/frontend/x3/mail/ and replaced the dynamic code with your static text.

With WHM 11.34 that's changed, and the .html file no longer controls any of the data, instead it calls the template file clientconfinclude.tmpl which then generates all of the content. Simply doing the switch like before isn't as simple any more, especially if you're not much of a coder, but it's still doable with some minor modifications. Unfortunately the code seems to use multiple methods to call the server addresses, so you have to do different mods for different sections of code.

First all we have the SSL hosts, which is easily the simplest part. Line 11 to line 24 deals with getting those details, with the next section storing them for use later. Without deleting anything simply insert these three new lines immediately before line 26 that begins "SET ssl_hosts = {" :

SET imap_ssl_host = 'imap.mydomain.com';
SET pop3_ssl_host = 'pop3.mydomain.com';
SET smtp_ssl_host = 'smtp.mydomain.com';

That will then force all SSL references to use your information. Now look for the line :

SET non_ssl_mail_server = webmail_settings.domain;

Copy it, and edit the entries so you have :

SET non_ssl_mail_server = 'pop3.mydomain.com';
SET non_ssl_mail_server_smtp = 'smtp.mydomain.com';

In the manual settings section, if you'd prefer the default POP3/IMAP to be IMAP then change pop3 to imap above. Now look for the line :

[% locale.maketext("Outgoing Server:") %]

at around line 685. On the next line, change "non_ssl_mail_server" to be "non_ssl_mail_server_smtp" (so it matches the name used in the last step).

If you save this file and reload the page you should now find most of the links / text now points to your preferred addresses. Unfortunately it's not perfect, there are a few entries that display incorrectly, and I haven't yet worked out where they get their information or how to change it, but hopefully it will be a bit of help for someone.

Monday, 20 August 2012

Windows 8 - First thoughts and future telephone support issues

Now that Windows 8 has been released I've been having a play with it this weekend. In terms of usability I'm not entirely sure how I feel about it currently. On the one hand I'm sure in time I could come to get used to the new way of doing things, and the workarounds to enable the old ways, but on the other I can only imagine the pain and misery to come from trying to do telephone support for it.

The key problem I see is with the schizophrenic nature of Windows 8. Having two completely different UIs within a single OS will at best make things interesting, at worst confuse the hell out of people.

It's not helped by a lack of distinction between the two in regards to names. For instance, now that it's no longer officially called Metro, we have the Desktop and the Modern UI, but the latter isn't a name it's a description! The Desktop UI doesn't exactly look dated either, in fact I'd say it was positively modern. What will we call it in several years time when the "Modern UI" is anything but? It's not helped by many sources also referring to it as the Windows 8 UI, therefore throwing three different names into the mix.

Then there's Internet Explorer, with two essentially different applications using the same name. They function differently, have different options and ways of doing things, yet how do you easily differentiate them verbally? I've seen enough users struggle to understand what IE is at the best of times, but at least then you can tell them to look for the big blue "e". Now you also have to check which UI they're using, otherwise your instructions will be meaningless.

Internet Explorer also handles downloads differently, which could be fun for anyone using a remote support application (eg, getting the client to go to a URL, enter some details, and run a program to give you remote access to their machine). Since IE 9 the download dialog window has been tied to the window that initiated it. If the download was initiated via a popup (eg it provides the download link to click), and that popup closed once the download started, the download dialog would disappear once completed. Fortunately you could bring it back by pressing CTRL-J, and then choose to save or run the download. This still works in the desktop IE 10, but doesn't in Metro IE 10. Instead you get a dialog appear for 2 or 3 seconds giving you the run / save / cancel options, and if you don't respond in time it vanishes. Thus far I've been unable to find a way to retrieve it other than running the download again.

All that said, I have found a few handy features.

Windows + D - Show Desktop - Nothing new here, but importantly it will get you out of Metro to the normal desktop UI.

Windows + C - Charms menu - This is the Metro menu you get by hovering to the right hand corners to access things like settings, shutdown/restart etc.

Windows + Z - Tabs / Address menu in Metro IE and All apps from Metro start page - Again, saves messing around with tricky mouse positioning.

Finally, while there's no way to disable Metro on startup, there is a work around to make getting to the desktop easier. On the metro start screen, drag the Desktop tile up to the top left hand corner (eg top row, first column). Now after typing your password and pressing Enter to login you can immediately go to the desktop by pressing Enter a second time (since the top left tile is automatically selected).

http://social.technet.microsoft.com/Forums/en/w8itprogeneral/thread/66df8624-d6bc-46c8-a7a8-2600c6f12193

Sunday, 19 August 2012

The joys of technet

Thanks to the wonders of a Technet subscription and a new computer I've been having a play with VirtualBox at home. While certainly more basic than VMWare or Hyper-V it does the job, I think it's easier to use than VMWare and of course Hyper-V won't run on Windows 7.

I'm definitely very tempted by Windows 8 since that includes Hyper-V Client, though due to the train reck that is the Metro interface I may well stick with this if it continues to do what I need, especially if the reviews of the latest release preview turn out to be accurate.

Perhaps it's sad, but I'm actually looking forward to being able to play with various things at home. All those things that have caught my interest, that I fancy looking at, but which have no justification to spend time looking at while at work.