robert.sterbal 56890 (8/19/2015)
I do remote support, so I'm guessing I'll have to create the functions on each site.
Can I run this from xp_cmdshell?
It depends on how you define "remote support". In my case I work from home 100% and do not always have one machine in a client environment to run scripts from; in that scenario then yes you have to move your scripts to each "site" or environment you want to run them on.
Another scenario I had at a previous employer, I used a VM on my laptop and connected via VPN to each client environment. In that case if the domain supports authentication over the VPN, then you can use the remote ability in PowerShell cmdlets to pull information. You would not have to push the scripts to every server.
With regard to using xp_cmdshell, I have used this in one PowerShell project to build out disk space report for all the servers in a client environment (included pulling all the data to a database and then alerting based on configured thresholds). The one thing you have to understand is if you want to do something with the data returned by PowerShell, via xp_cmdshell, it takes a bit more than just having it call the script/commands. I used a variation of Laerte's script here for using XML[/url].