Answered by:
Snap-ins

Question
-
I'm adding the SQL Server snap-in to PowerShell using a script from andMSDN article. For now I just ran the script from a PowerShell Window.However, my intent is to write scripts using this provider. What is thebest way to make sure the provider is available to PowerShell on asystem. Do I put it in the main PowerShell profile or is there another,better way to add snap-ins so they are available for use.Thanks.Tuesday, August 10, 2010 8:22 PM
Answers
-
You can use get-pssnapin to check if the required snapin is already loaded, and run add-pssnapin to load it if it not already loaded.
[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "- Marked as answer by Marco Shaw Wednesday, August 11, 2010 12:37 AM
Tuesday, August 10, 2010 8:49 PM
All replies
-
You can use get-pssnapin to check if the required snapin is already loaded, and run add-pssnapin to load it if it not already loaded.
[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "- Marked as answer by Marco Shaw Wednesday, August 11, 2010 12:37 AM
Tuesday, August 10, 2010 8:49 PM -
Thanks. I'll try that. If I want to make it available to anyone whomight use PS on the machine should I just put the check and if not thereadd it in a profile?On 8/10/2010 4:49 PM, mjolinor wrote:> You can use get-pssnapin to check if the required snapin is already> loaded, and run add-pssnapin to load it if it not already loaded.> ------------------------------------------------------------------------> [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775> 0645570").substring(($_*2),2))})-replace " "
xxxxTuesday, August 10, 2010 11:12 PM -
I'd avoid adding it to their profile. That makes PS load that snapin and consume additional resources every time they run Powershell, whether they're going to use it for anything that needs those cmdlets or not.
[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "Tuesday, August 10, 2010 11:27 PM -
I'd like to add that many people in fact do add this type of stuff in their profile. This is a matter of preference.Tuesday, August 10, 2010 11:51 PM
-
I add stuff to my profile, but I don't like the idea of writing a script for distribution that updates someone else's profile with snapins just because that script needs it.
[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "Wednesday, August 11, 2010 12:04 AM -
I don't like this idea either =) Agreed.Wednesday, August 11, 2010 12:10 AM
-
Me neither on adding something to a profile unless it's somethingeveryone can use and then I'd just put it in the profile and not updateit with a script. These are my SQL servers and all they do is SQL Serveand I'll be doing a lot of Powershell. I've got several good points toconsider. Thanks everyone.On 8/10/2010 8:04 PM, mjolinor wrote:> I add stuff to my profile, but I don't like the idea of writing a script> for distribution that updates someone else's profile with snapins just> because that script needs it.> ------------------------------------------------------------------------> [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775> 0645570").substring(($_*2),2))})-replace " "
xxxxWednesday, August 11, 2010 12:36 AM