Archive

Posts Tagged ‘Deployment’

Function: Set-PowerPlan – Adjust The Power Plan of a Server

February 25, 2014 1 comment

Just something I worked up based on a suggestion by someone. This will change the power plan of the machine it’s run on. This can be critical if you want to ensure that the machine doesn’t go to sleep while an extended process is running. Simply run the function with the desired power plan and the change is immediate. For example:

Set-PowerPlan "High Performance"

The three power plans you can choose from are “high performance”, “balanced”, and Power Saver. That’s all there is to it.

function Set-PowerPlan {
	[CmdletBinding(SupportsShouldProcess = $True)]
	param (
		[ValidateSet("High performance", "Balanced", "Power saver")]
		[ValidateNotNullOrEmpty()]
		[string] $PreferredPlan = "High Performance"
	)
	 
	Write-Verbose "Setting power plan to `"$PreferredPlan`""
	$guid = (Get-WmiObject -Class Win32_PowerPlan -Namespace root\cimv2\power -Filter "ElementName='$PreferredPlan'").InstanceID.ToString()
	$regex = [regex]"{(.*?)}$"
	$plan = $regex.Match($guid).groups[1].value 
	
	powercfg -S $plan
	$Output = "Power plan set to "
	$Output += "`"" + ((Get-WmiObject -Class Win32_PowerPlan -Namespace root\cimv2\power -Filter "IsActive='$True'").ElementName) + "`""
	Write-Verbose $Output
}
Categories: PowerShell Tags: ,

Script: New-CsLyncRoomSystem.ps1 – Easily Deploy Lync Room Systems

January 28, 2014 6 comments

Description

One of the really cool features of Lync Server 2013 is the Lync Room System. LRS is comprised of a single or dual screen system, video camera, and control unit. This system provides for a rich conferencing experience by providing HD video, touch screens with white-boarding, audio & video inputs, and more. For more information on Lync Room system, see the Product Group’s blog post. To see the systems optimized for Lync, see the catalog.

Deploying a Lync Room System involves several steps, and is outlined (albeit poorly) in the LRS Deployment Guide. I say poorly because from a PowerShell perspective, the 10 steps outlined can be combined down to about 6. Some are Exchange related, some are Active Directory related, and some are Lync related.

What I’ve done is to automate & streamline the process, add a ton of error checking, optimization, and validation. Instead of picking an Exchange server, the script will automatically find and connect to Exchange. It then performs the following tasks:

  1. Create an Exchange mailbox configured as a room resource. Additionally, the description is defined, and the company name on the account is configured (see http://www.ehloworld.com/2266 for why this is important). The room account is enabled. You’re prompted for a password for the account, and that password must conform to the organizations’ password policy for complexity. If the mailbox already exists, which would be common in most scenarios, the script will handle it gracefully, ensuring it’s configured properly.
  2. The mailtip for the account is defined. It merely reminds users to make meeting requests a Lync meeting.
  3. Set calendar processing to AutoAccept so that when the room account is added to meetings, it will automatically accept the request.
  4. The AD account is enabled
  5. The Lync Meeting room is created, and uses the email address for the SIP address. This is important to avoid Exchange Web Services (EWS) issues.
  6. If a LineURI is defined, the meeting room is enterprise voice enabled. LineURI should be specified in E.164 format.

Any other configuration, such as conferencing policies, etc., can be set after the script runs. I’ve used this script to deploy a 70″ dual display SMART Room System.

See the assumptions section below for more info.

Syntax

New-CsLyncRoomSystem.ps1 [[-Alias] ] [[-Name] ] [[-UPN] ] [[-SamAccountName] ] [[-RegistrarPool] ] [[-LineURI] ] [[-CompanyName] ] [[-ResponseText] ] [[-ResourceCapacity] ] [-DeleteSubject ] [[-EnableResponseDetails] ] [-WhatIf ] [-Confirm ] []

example

New-CsLyncRoomSystem.ps1 -alias nycconfroom -name "New York City Conference Room" -upn "nycconfroom@contoso.com" -registrarpool "frontendpool.contoso.com"

The SamAccountName only needs to specified if it needs to be different than the alias.

Installation

Execution Policy: Third-party PowerShell scripts may require that the PowerShell Execution Policy be set to either AllSigned, RemoteSigned, or Unrestricted. The default is Restricted, which prevents scripts – even code signed scripts – from running. For more information about setting your Execution Policy, see Using the Set-ExecutionPolicy Cmdlet.

Assumptions

  • The SIP address is set to match the SMTP address. This is to avoid issues where the two don’t match and Exchange Web Services (EWS) calls fail.
  • Exchange 2010 or 2013 exists in the environment
  • The user running the script has the appropriate rights in Exchange (Recipient Management or higher) and Lync (RTCUniversalUserAdmin or higher)
  • The machine that the script runs on has both the Lync and Active Directory modules installed.

Download

v1.2 – 06-10-2014 – New-CsLyncRoomSystem.v1.2.zip

v1.1 – 02-08-2014 – New-CsLyncRoomSystem.v1.1.zip

v1.0 – 01-28-2014 – New-CsLyncRoomSystem.v1.0.zip

Changelog

See the changelog for information on what’s changed/included in each version.

Changelog: New-CsLyncRoomSystem.ps1

January 27, 2014 Leave a comment

This is the changelog for New-CsLyncRoomSystem.ps1. You will find a complete list of released versions, their dates, and the features and issues addressed in each. Please refer to the script’s main page for more information including download links, installation details, and more.

v1.2 – 06-10-2014

  1. Added –AdditionalResponse option for Set-CalendarProcessing
  2. Added -DomainController switch to every command that supports it to ensure that we don’t start getting errors due to AD replication being laggy.
  3. A warning is now shown if the user services policy that is applied to the LRS has UCS enabled
  4. ResourceCapacity option added. If defined, will set the mailbox capacity accordingly

v1.1 – 02-08-2014

  1. comment help optimized per suggestions at http://www.lazywinadmin.com/2014/01/powershell-tip-adding-help-in-param.html
  2. validation for registrar name
  3. cleaned up param block
  4. validate that FE pool is 2013, exit if not
  5. new version of Set-ModuleStatus

v1.0 – 01-28-2014

  1. Original version

Cleaning Up Removed OCS Servers Before Migrating to Lync 2013

November 12, 2013 2 comments

Migrating a customer from OCS 2007 R2 to Lync 2013 recently, I came across an issue that needed some extra work before I could continue.

When I opened the OCS 2007 R2 management console, I noticed a server listed under “Earlier Server Versions”.

legacy server

I verified that the server no longer existed in Active Directory or DNS. The customer confirmed that it was an OCS 2007 server that had long been removed from service. This server would likely cause issues with publishing a Lync 2013 topology since OCS 2007 isn’t supported in a Lync topology. This server needed to be removed. Unfortunately, there was also no other servers in the environment with the OCS 2007 (non R2) management tools installed. And the OCS 2007 R2 management tools can’t remove the server. This meant that the only way I could remove this server is via our friend ADSIEdit. If you’ve got this issue, follow along as I show you how to remove it. Remember, we’re deep into Active Directory internals here, so tread lightly. Read twice, delete once. And for God’s sake, have a backup of AD.

Depending on where the OCS Global Settings are in Active Directory dictates where to connect to in ADSIEdit. These settings can info can either be in the root domain System container, such as if the environment originally held LCS and/or OCS 2007 servers and the settings were never migrated, or the Configuration container, where they would be if they had been migrated, or if OCS 2007 R2 was installed in a greenfield deployment. If you’re Global Settings are in the System container, open ADSIEdit and select “Configuration” in the Select a well known Naming Context field.

config container

If your Global Settings are in the System container, as was the case for this customer, Select the “Default naming context”.

Expand the domain, then expand CN=System, then expand CN=Microsoft, then expand CN=RTC Service. Inside that, expand CN=Pools. You should see the pools and servers listed. Highlight CN=Pools on the left. On the right side, right-click on the server you wish to remove, and choose Delete.

delete server

Once that’s done, close ADSIEdit. Once AD replicates, open the OCS 2007 R2 Management Console and check. The “Earlier server versions” branch should now be empty.

OCS 2007 R2 Management Console

Script: Set-Cs2013Features.ps1 – Easily Install Prerequisites and Tools for Microsoft Lync Server 2013

February 8, 2013 101 comments

Lync 2013 logo 128x128Description

This script will assist in getting servers ready for the installation of Microsoft Lync Server 2013 on Windows Server 2012 and Windows Server 2012 R2. This includes the operating system prerequisites, SQL Express (where necessary), Silverlight, and more. Some post installation options are also available, and include Microsoft tools such as the debugging tools, the Best Practices Analyzer (BPA), Connectivity Analyzer, and more. Where the script needs files available online, it will automatically download them. More options will be added as I have time, and can properly test. This includes Edge, Director, Front End, Office Web Apps, Persistent Chat, and Mediation server prerequisites, and more tools. If you have suggestions, please feel free to comment below.

In the event that the server needs to be rebooted before prereqs can continue, it will automatically restart the script and continue after you reboot and login again.

The current options are:

1. Director – Installs the OS prerequisites and SQL Express instances required to install this role.

2. Edge – Installs the OS prerequisites and SQL Express instances required for this role.

3. Front End – includes the Operating System prerequisites, Microsoft Silverlight, as well as the installation of SQL Express SP2 and creation of the various required instances. The SQL Express installs are done because Lync Server installs the RTM version by default. So installing the SP2 version saves a long update later. Note that each instance takes 3-5 minutes to install – longer on slower machines. Enterprise edition servers have two instances, RTCLocal and LyncLocal, and Standard edition servers also have the RTC instance. See the syntax and example sections below on how to call the script for the two types of servers. This option will also prompt (if the firewall is enabled) if you’d like the required firewall exceptions created for my Get-CsConnections.ps1 script. This option will also prompt if the Lync Room System Admin Portal will be installed. If you select Yes, the ASP.NET MVC 4 for Visual Studio 2010 SP1 and Visual Web Developer 2010 SP1 prerequisite for that is installed.

4. Mediation – still being tested to make sure I didn’t miss something.

5. Office Web App – Installs the OS prerequisites required, then installs the Office Web App binaries, and then prompts to install the English language pack, followed by the re-released SP1 update. Almost everything needed to deploy an Office Web Apps server. This option also verifies that Windows Update settings are NOT set to automatic, as that is not recommended.

6. Persistent Chat – Installs the OS prerequisites and SQL instance required for this role.

7. Lync Server 2013 Resource Kit – tools that make troubleshooting and administrating a Lync environment easier, such as Address Book config, etc.

8. Lync Server 2013 Persistent Chat Resource Kit – tools useful for Persistent Chat environments.

9. Lync Server 2013 Debugging Tools – includes the logging tools such as OCSLogger and Snooper. Helpful for troubleshooting.

10. Lync Server 2013 Stress and Performance Tool – prepare, define, and validate performance

11. Lync Server 2013 Best Practices Analyzer – this tool helps identify any issues from a best practices perspective

12. Lync Server Connectivity Analyzer – identifies any issues that may result in connectivity problems for mobility clients including the Lync Windows Store app

13. Install/Update Lync Server 2013 Documentation Help

14. Create scheduled task to automatically update PowerShell help files daily. I discuss this in Function: New-PSUpdateHelpScheduledTask – Auto Update PowerShell Help

15. Launch Windows Update

16. SCOM Watcher Node prerequisites

17. Custom PortQryUI. PortQryUI is installed, along with a custom config file that adds Lync related options.

18. Install Microsoft Message Analyzer (formerly NetMon)

19. Add custom Scheduler simple URL – if you’d like to have a simple URL for the scheduler app, such as scheduler.contoso.com, this option will handle the configuration of that. Note that this option requires that the simple URL provided be in the Subject Alternative Names (SAN) list of the certificate on your Front End servers. See Understanding the Lync Web Scheduler for additional info.

20. Install SQL Server 2012 Management Studio

21 Install telnet client

23. Create Windows Update tile on desktop

24. Microsoft Unified Communications Managed API 4.0, Runtime (UCMA 4.0) – this is required if you’re going to run sefautil.exe from the resource kit. It’s still recommended that sefautil.exe be used on a dedicated box.

25. Set recovery of Lync and/or OWAS services to “restart”. See Set recovery of Lync services to “restart” for more info.

28. Configure Skype Federation. This removes the MSN Public Provider and adds the Skype Public Provider, complete with icon. Download includes the Lync-Skype Provisioning Guide. See http://blogs.technet.com/b/lync/archive/2013/05/23/lync-skype-connectivity-available-today.aspx for more info.

29. Disable SSL 3.0. This is in response to the POODLE attack issue. Disabling SSL 3 will help reduce risk. The caveat is that disabling it will break connectivity for XP machines running IE 6/7.

30. Wireshark. This downloads the installer and starts it. Due to the fact that WinPCap can’t be silently installed, a silent install of Wireshark isn’t possible. You’ll just have to go through the install manually (normally just picking all of the default options).

31. Enable Photo URL option. Enables the photo URL option in the client. See http://www.lynclog.com/2013/11/lync-2013-client-and-and-pictures-from.html for more info.

32. Fix Control Panel font. Reverts the font in the Control Panel back to the original Segoe UI. See Resetting the Font in Lync Server Control Panel – Goodbye Times New Roman!

33. Set server power plan to “High Performance”. See http://www.ehloworld.com/2558

34. Lync Room System (LRS) Admin portal prerequisites.

36. Create Lync file share on local computer. Creates a file share on the local computer. That information then should get added to Topology Builder.

38. Create Lync file share on local computer. This creates a file share on the local computer called “LyncShare”, and assigns the basic NTFS and share rights. This can then be added to the Lync Topology Builder.

40. Desktop shortcuts menu. This is basically an enhanced menu driven version of Create a Shutdown/Restart/Logoff Windows 8 Tile for the Start menu (PowerShell) that puts easy to reach tiles on the Start screen. The available tiles are:

41. Logoff
42. Restart
43. Shutdown
44. Windows Update
45 Lync Server Management Shell
46. Lync Server Deployment Wizard
47 Lync Server Control Panel
48. Exchange UM Integration Utility (OcsUmUtil)
49. Snooper
50. OCSLogger Logging Tool
51. Lync Server Topology Builder
52. Certificate Management (local machine)
53. Active Directory Users and Computers (ADUC)
54. Microsoft Message Analyzer

60. Taskbar shortcuts menu. These options create shortcuts on the taskbar for commonly used tools.

 61. Lync Server Management Shell
62. Lync Server Deployment Wizard
63. Lync Server Control panel
64. Exchange UM Integration Utility (OcsUmUtil)
65. Snooper
66. OCSLogger Logging Tool
67. Lync Server Topology Builder
68. REMOVE shortcut for PowerShell
69. Certificate Management (local machine)
70. Active Directory Users and Computers (ADUC)
71. Microsoft Message Analyzer
72. REMOVE Windows App Store shortcut (Windows Server 2012 R2)

80. Downloads only menu. This menu shows options for download (only) of some key Lync related products.

81. Download latest Lync Server 2013 Cumulative Update
82. Lync Server 2013 Watcher Node
83. Lync Server 2013 Management Pack & Documentation
84. Lync 2013 Rollout and Adoption Success Kit (RASK)
85. Lync Server SDN API 2.1 (includes the API installer, the management utility, the docs, and the .chm file)

Simply choose your desired option. When the script is finished, it will return to the menu.

Note: The installation of some Lync Server 2013 roles requires some .Net 3.5 components, which are not installed in Windows Server 2012 by default. So the script will need to know where your Server 2012 installation media is. The script defaults to the CD-ROM/DVD-ROM drive with the lowest drive letter (typically D: or E:), but can be configured for other locations.

The script will also create a log file that can be used for troubleshooting. The log file is created in a logs folder inside the $TargetFolder (by default, c:\_install). This log file should be included when reporting any bugs.

Syntax

C:\Set-Cs2013Features.ps1 [[-TargetFolder] ] [[-Win2012Source] ] [[-SQLPath]] [-WhatIf] [-Confirm]

Examples

Set-Cs2013Features.ps1

This will launch the script with the default options for Enterprise edition servers

Set-Cs2013Features.ps1 -Win2012Source e:

This will launch the script using the e: drive for the source of the Windows Server 2012 installation files

Set-Cs2013Features.ps1 -sqlpath "d:\sqlexpress"

This will install any related SQL Express instances to the specified path

Installation

WARNING!

An issue has been identified in Windows Server 2012 servers that are built as Server Core, but converted later to Server with GUI. Installation of Windows Features, either manually or via a script, fail if Windows Updates are installed BEFOREHAND. That being the case, this script cannot be used in such scenarios. I’m working on detecting (if possible) servers that are converted, as well as researching why they fail. Thanks to John for pointing it out. It’s likely that the issue detailed here is the cause.

Execution Policy: Third-party PowerShell scripts may require that the PowerShell Execution Policy be set to either AllSigned, RemoteSigned, or Unrestricted. The default is Restricted, which prevents scripts – even code signed scripts – from running. For more information about setting your Execution Policy, see Using the Set-ExecutionPolicy Cmdlet.

Frequently Asked Questions

Question: Why doesn’t this script support Windows Server 2008 R2?

Answer: I get asked this all the time. There are several reasons. The first is that out of the box, Server 2008 R2 has PowerShell 2.0 installed, and this script is written in PowerShell 3.0. Requiring you to upgrade to PowerShell 3.0 first, before running a script that installs prerequisites, seems counter-intuitive. And converting the script to just use PowerShell 2.0 is taking a step backwards, especially considering that the current version of PowerShell is 4.0, and even as this is written, 5.0 is in preview.

Next is sheer time. I test changes I make. And then I test them again. And then I choose different options and combinations and test them. Testing on just Server 2012 and Server 2012 is exhausting. Adding Server 2008 R2 would mean even more testing, plus I’d have to add those resources in my already overtaxed test labs. That would slow down my ability to add new features and test fixes.

Third is that Server 2008 R2 is two versions back. Get with the times already!


Question: Can you add feature x?

Answer: I LOVE getting feature requests. Seriously! Best method to suggest features is to send me an email. My email address is in the comment section at the top of every script I release. Please be detailed in what you’d like to see, as well as any scenarios you’d use the option (so I can try to duplicate testing).


Question: How do I submit bug reports?

Answer: Email is best. Grab my email address from the comment section at the top of the script. Please be VERY detailed. Please include screen shots if possible, and ALWAYS include the log file. If you’re not using the latest version of the script, please download it and see if you can duplicate the problem before reporting it.


Question: What if my server doesn’t have Internet access?

Answer: Fear not. Download the required files from another machine and place them in the TargetFolder, which is c:\_install by default. The script looks to see if the file is available locally before attempting to download.

Download

v3.1 – 10-24-2014 – Set-Cs2013Features.v3.1.zip

v3.0 – 10-06-2014 – Set-Cs2013Features.v3.0.zip

v2.9 – 09-22-2014 – Set-Cs2013Features.v2.9.zip

v2.8 – 08-13-2014 – Set-Cs2013Features.v2.8.zip

v2.7 – 06-26-2014 – Set-Cs2013Features.v2.7.zip

v2.6 – 06-10-2014 – Set-Cs2013Features.v2.6.zip

v2.5 – 05-24-2014 – Set-Cs2013Features.v2.5.zip

v2.4 – 04-29-2014 – Set-Cs2013Features.v2.4.zip

v2.3 – 02-08-2014 – Set-Cs2013Features.v2.3.zip

v2.2 – 01-20-2014 – Set-Cs2013Features.v2.2.zip

v2.1 – 12-17-2013 – Set-Cs2013Features.v2.1.zip

v2.0 – 11-26-2013 – Set-Cs2013Features.v2.0.zip

v1.9 – 10-28-2013 – Set-Cs2013Features.v1.9.zip

v1.8 – 08-01-2013 – Set-Cs2013Features.v1.8.zip

v1.7 – 05-31-2013 – Set-Cs2013Features.v1.7.zip

v1.6 – 05-24-2013 – Set-Cs2013Features.v1.6.z1p

v1.5 – 05-10-2013 – Set-Cs2013Features.v1.5.zip

v1.4 – 05-03-2013 – Set-CsLync2013Prerequisites.v1.4.zip

v1.3 – 04-29-2013 – Set-CsLync2013Prerequisites.v1.3.zip

v1.2 – 04-01-2013 – Set-CsLync2013Prerequisites.v1.2.zip

v1.1 – 02-28-2013 – Set-CsLync2013Prerequisites.v1.1.zip

v1.0 – 02-08-2013 – Set-CsLync2013Prerequisites.v1.0.zip

Changelog

See the changelog for information on what’s changed/included in each version.