Content Preview: rss
1 days ago
SQLPS.exe (PowerShell mini-shell) means business. You want a quick way to get information about your SQL Server logins, then here it is: 1: cd SQLServer:\SQL\YourSQLServer_Name\Default_or_YourSQLinstance_Name\Logins 2: dir TWO LINES…. is that GREAT!! The more you discover how productive PowerShell can be, then you go crazy and want to learn more. Hey!! Learning to use SMO with PowerShell add more ammunition to your scripting arsenal. Here’s a screenshot showing the logins results: Now, to keep growing these two liner… you could add the list of SQL Server and do a “Foreach” cmdlet to build a nice report. This is just a starting point to start using SQLPS and extending it with PowerShell v2. Enjoy!!
2 days ago
for the last 1.5 year, in all my “PowerShell and SQL Server” presentations, I have shown some basic samples on how to use both technologies together. Let me be clear, in SQL Server 2008(including R2), SQLPS.exe is a PS mini-shell built on PS v1 which means that PowerShell V2 additional cmdlets and features wouldn’t be available from within SQLPS. For this reason you can’t use PowerShell V2 scripts in a SQL Agent job. Now, looking outside of the box, thanks to SQL Server 2008, you can load the SQL snapins/provider & use PS V2 to extend management on your SQL box. To load the SQL provider with PowerShell v2, follow the instructions from Michiel Wories Blog: http://blogs.msdn.com/mwories/archive/2008/06/14/SQL2008_5F00_Powershell.aspx Please, if you want to understand how this work: 1. Try to build a Virtual machine with the OS you’re currently familiar(Windows XP/Vista/7), 2. Make sure all Windows Update are loaded, 3. Make sure PowerShell is upgraded to V2, 4. ...
4 days ago
Here’s another few PowerShell short script to be executed under SQLPS.exe and/or if you already have the SQL Server provider loading on your WindowsPowerShell folder under your user profile. Look for the script “Microsoft.PowerShell_profile.ps1”. Requirement to run script: 1. Must have SQL Server 2008 in order the use the SQL Server provider. 2. You could run this script in SQLPS.exe 3. Optional-> load your SQL provider in your PowerShell V2 profile. Here's how: http://blogs.msdn.com/mwories/archive/2008/06/14/SQL2008_5F00_Powershell.aspx (Add this code in your WindowsPowerShell profile) 4. Results will be display on screen but you could add code to save result to a file. (" Out-File ...") This script will list all my SQL Agent jobs on one server or more servers. Remember you can expand this script to do more. This is a teaser code: 1: ## Sample Listing SQL Agent jobs results 2: cd ...
7 days ago
I always was curious about Windows Home Server (WHS) and during a Microsoft LiveMeeting on WHS with Jonas Svensson talked about wanted to see some PowerShell in WHS. Well, here’s a start. I’m showing my Windows 7 (64bit) using Windows Virtual PC. I have been able to build my virtual network with Windows 2008 STD SP1(32bit), and Windows Home Server. Installing PowerShell on the Windows Home Server: What’s needed? 1. Make sure that WHS has all the Windows Updates (including the SP2) 2. Install the WMF (Windows Management Framework) for Windows Server 2003: (Windows Management Framework Core (WinRM 2.0 and Windows PowerShell 2.0)) http://support.microsoft.com/kb/968929 What to do after PowerShell is installed? 1. If you’re creating a Windows 7 virtual machine, *install “Integration Features”. 2. Open the PowerShell Console. 3. Type “Enable-PSRemoting”, answer with a “Y”. This will setup your PowerShell remoting features to allow connectivity to other ...
11 days ago
As you have notice with my previous sample COMObject vs .NET, that is looks the same. So, as one of the PowerShell MVP college (Marco Shaw) pointed out on an email to me, that “… .NET just wrapped COM for Office programming” and this is true. Now, there’s a reason why I went two ways on my QuickBlogs: 1. Both sample works on my computers (Windows 7 RTM 64bit and Windows Vista Business 32bit). And that’s awesome!! 2. I have a SQL Server Admin college that wanted me to help him with the script but was having an error using the COMobject sample. He’s on a Windows 7 64bit with Outlook 2007 installed and here’s error message he was getting: Error: “New-Object : Retrieving the COM class Factory for component with CLSID {0006F03A—0000-0000-C000-000000000046} failed due to the following error: 80080005…} His “Outlook.Application” COMobject was not loading. So, I provided him with the .NET version of the script and he was able to extract and produce his email list from ...



