I'm quite new to PowerShell, but getting along OK with a PS cookbook, but I have run into an issue and I cant get around it, and looking for some help.
I just wanted to list the service accounts, it all looks good but I am getting the following error when I run it which I am fairly sure relates to $managedcomputer.services
PS SQLSERVER:\> $managedComputer.Services
The following exception occurred while trying to enumerate the collection: "SQL Server WMI provider is not available on MyNamed\instance.".
At line:1 char:1
+ CategoryInfo : NotSpecified: (
+ FullyQualifiedErrorId : ExceptionInGetEnumerator
I did import the module SQLPS, and their are no problems with that. My actual code is...
#import SQL Server Module
Import-Module SQLPS -DisableNameChecking
$InstanceName = "MYNAMED\INSTANCE"
$managedComputer = New-Object 'Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer' $InstanceName
Select Name, ServiceAccount, DisplayName, ServiceState | Format-Table -AutoSize
So I downloaded the SQL 2012 Feature Pack to get the SQLSysClrTypes, SharedManagementObjects, and PowerShellTools, which google led me to from the error I was receiving, and now face an additional issue whereby I cannot install the sharedmanagment objects because it says I need to install the SQLSysCLRTypes as a prerequisite, buts already installed. I also tried uninstalling, and also tried the 32 bit options.
I'm enjoying learning PS, but this is just a pain. I am running it within the ISE in case its important.
Any advice? PowerShell V3 BTW.