tirsdag 19. august 2014

OpsMgr: Properties with brackets in PowerShell

Have you tried to select or filter on properties using brackets in PowerShell? Did you figure out how to do it? If not, read on...

For example, I execute this command in Operations Manager Shell:
Get-SCOMClass -DisplayName 'Windows Computer'|Get-SCOMClassInstance|select -First 1 *

And the result:
[Microsoft.Windows.Server.Computer].IsVirtualNode            : (null)
[Microsoft.Windows.Computer].PrincipalName                   :
[Microsoft.Windows.Computer].DNSName                         :
[Microsoft.Windows.Computer].NetbiosComputerName             : dc1
[Microsoft.Windows.Computer].NetbiosDomainName               : CONTOSO
[Microsoft.Windows.Computer].IPAddress                       :
[Microsoft.Windows.Computer].NetworkName                     :
[Microsoft.Windows.Computer].ActiveDirectoryObjectSid        : S-0-0-00-000000000-0000000000-000000000-0000
[Microsoft.Windows.Computer].IsVirtualMachine                : True
[Microsoft.Windows.Computer].DomainDnsName                   :
[Microsoft.Windows.Computer].OrganizationalUnit              : OU=Computers,DC=contoso,DC=com
[Microsoft.Windows.Computer].ForestDnsName                   :
[Microsoft.Windows.Computer].ActiveDirectorySite             : contoso
[Microsoft.Windows.Computer].LogicalProcessors               : 1
[Microsoft.Windows.Computer].PhysicalProcessors              : 1
[Microsoft.Windows.Computer].HostServerName                  : (null)
[Microsoft.Windows.Computer].VirtualMachineName              : (null)
[Microsoft.Windows.Computer].OffsetInMinuteFromGreenwichTime : (null)
[Microsoft.Windows.Computer].LastInventoryDate               : (null)
[Microsoft.SystemCenter.ManagedComputer].InstallDirectory    : C:\Program Files\Microsoft Monitoring Agent\Agent\
[Microsoft.Windows.Server.2008.Computer].InstallType         : Full
[System.ConfigItem].ObjectStatus                             : System.ConfigItem.ObjectStatusEnum.Active
[System.ConfigItem].AssetStatus                              : (null)
[System.ConfigItem].Notes                                    : (null)
[System.Entity].DisplayName                                  :
IsManaged                                                    : True
HealthState                                                  : Success
StateLastModified                                            : 8/19/2014 10:00:00 AM
IsAvailable                                                  : True
AvailabilityLastModified                                     : 8/19/2014 10:00:00 AM
InMaintenanceMode                                            : False
MaintenanceModeLastModified                                  :
MonitoringClassIds                                           : {e817d034-02e8-294c-3509-01ca25481689, ea99500d-8d52-fc52-b5a5-10dcd1ba-33f801db7d37...}
LeastDerivedNonAbstractMonitoringClassId                     : ea99500d-8d52-fc52-b5a5-10dcd1e9d2bd
ManagementGroup                                              : SCOMMG
Name                                                         :
Path                                                         :
DisplayName                                                  :
FullName                                                     :
ManagementPackClassIds                                       : {e817d034-02e8-294c-3509-01ca25481689, ea99500d-8d52-fc52-b5a5-10dcd1ba-33f801db7d37...}
LeastDerivedNonAbstractManagementPackClassId                 : ea99500d-8d52-fc52-b5a5-10dcd1e9d2bd
TimeAdded                                                    : 8/19/2014 10:00:00 AM
LastModifiedBy                                               :
Values                                                       : {(null),,, dc1...}
LastModified                                                 : 8/19/2014 10:00:00 AM
IsNew                                                        : False
HasChanges                                                   : False
Id                                                           : 83f8d115-ccc8-5d88-2345-00d0148ecbd3
ManagementGroupId                                            : c6f7583b-f37e-101a-30fa-e53639ee0d80

Now you may wonder, how do I use Select-Object to view only Name and IPAddress? Well, square brackets require double-escaping in PowerShell (see this Microsoft Connect Feedback), so this is how:
Get-SCOMClass -DisplayName 'Windows Computer'|Get-SCOMClassInstance|select -First 1 Name,``[Microsoft.Windows.Computer`].IPAddress

Great, but what if I would like to use Where-Object to filter on IPAddress? Well, in this case we do not need to backtick-escape these brackets, instead we need to put single quotes around the entire property name, like this:
Get-SCOMClass -DisplayName 'Windows Computer'|Get-SCOMClassInstance|where{$_.'[Microsoft.Windows.Computer].IPAddress' -match ''}|select Name,``[Microsoft.Windows.Computer`].IPAddress

onsdag 13. august 2014

SQL Server: Unable to modify a Maintenance Plan

Are you unable to modify an existing Maintenance Plan in SQL Server Management Studio?

If you have installed the Microsoft SQL Server Management Studio tools in a Basic edition, try to install the Complete tools.

You can use "Installed SQL Server features discovery report" in Tools section of SQL Server Installation Center to see what features you have installed.

You may find that you also need to install Microsoft SQL Server Shared Management Objects. This is part of Microsoft SQL Server Feature Pack. You can find it at Microsoft Download Center. Be sure to select the version that correspond to the SQL Server you have installed.