What version of SQL and powershell was this script meant for? I've been having some trouble with the script.
1. I had to change the query in GetServers to "SELECT server_name FROM msdb.dbo.sysmanagement_shared_registered_servers
" because my systargetservers was empty even though I have over 170 registered servers.
2. I am getting a laundry list of errors at runtime to include:
Export-Csv : A parameter cannot be found that matches parameter name 'Append'.
At line:18 char:138
+ SystemType, @{Name="TotalPhysicalMemory (GB)"; Expression={[math]::round($($_.TotalPhysicalMemory/1gb), 2)}} | export-csv -Append <<<< -pa
th .\ProductionServers\ProductionSQLServer_ComputerSystem.csv -noType
+ CategoryInfo : InvalidArgument: (:) [Export-Csv], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.ExportCsvCommand
AND
The term 'Invoke-Sqlcmd' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if
a path was included, verify that the path is correct and try again.
At line:2 char:18
+ Invoke-Sqlcmd <<<< -ServerInstance $SqlServer -Database master -Query "
+ CategoryInfo : ObjectNotFound: (Invoke-Sqlcmd:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Regarding the Append error, I've looked up Export-CSV in MSDN and see no reference to that parameter. Regarding the Invoke-Sqlcmd I have found the article below to correct this error but I'm posting it anyways just in case others have issues with it.
How to use Invoke-Sqlcmd.[/url]
Best Regards,
Derik Hammer
www.sqlhammer.com