Maximo 的个人资料Max - Put It Together照片日志列表更多 工具 帮助

日志


7月4日

Virtual Varia Blog: More PowerShell in R2 tricks

Take a look at this blog about using Powershell in Windows Server R2 virtualization environment.  This is good stuff,

Click here: (Virtual Varia : More PowerShell in R2 tricks)

:)

7月3日

Executing SQLPS scripts from your SQLPS/PowerShell Window

I’ve seen many good SQLPS scripts on the internet but they asked you to copy/paste the code into the prompt. Then during my “PowerShell and SQL Server” presentation, I realized there’s a better way to stop doing copy/pasting code.  I already got it saved to my scripts folder and the only thing I need to do is running from the SQLPS prompt.

So, how can we do this?

I – From SQL Server Management Studio

 clip_image002

1. At the SQLPS prompt, Type the location of your Script Repository:

clip_image004

2. Now you can type the Script name and press enter. You can use the “tab expansion” to auto filled your script name.

clip_image006

clip_image008

II - Run “SQLPS” from within PowerShell Windows

1. Open Windows PowerShell Console prompt, then run SQLPS.exe or

2. Use the WindowsPowerShell user profile to include SQLPS.exe at the end of the script.

clip_image010

The following SQLPS script will create a table Employee in a NewDB database.

clip_image012

clip_image014

Keep in mind, that while doing using SQLPS.exe within Windows PowerShell, you do have two processes running.

image

So, next time you download your next SQLPS scripts, forget copy/paste into the SQLPS prompt, save the file, and run it from your scripts folder. I guarantee you will have a better user experience with SQLPS.

By the way, have you notice that at the end of the script, we end up with a long directory name.

clip_image018

Well, here’s a short PowerShell script to make it better:

################################################

## 1_chg_Prompt2.ps1

## Author: Max Trinidad, 11/08/2008

################################################

function prompt

{

if ($host.UI.RawUI.CursorPosition.Y -eq 0) { "< $pwd > `n`r" + "PS ["+$host.UI.RawUI.CursorPosition.Y+"] > "}

Else {"PS ["+$host.UI.RawUI.CursorPosition.Y+"] > "}

}

Now, because this is a PowerShell function, we need to running in a different way. We use the dot source method to execute functions in our PowerShell script:

####################################################

# NAME: DotSourcing01.ps1

# AUTHOR: Max Trinidad , PutItTogether

# DATE : 6/24/2009

#

# COMMENT: To help load function: 1_chgprompt2.ps1

####################################################

. .\1_chg_PSprompt2.ps1

cls

clip_image020

Now, change back to your SQL Server folder to get back to your final folder location:

clip_image022

Keep in mind, every time you do a clear screen “CLS”, it will return the folder location on the top of the screen:

clip_image024

Now, you have room to type your script and/or one-liner cmdlets.

clip_image026

Hope you find this information useful so you can enjoy working with both PowerShell and SQLPS.

Here’s some additional resource link on SQPS scripts and SQL Server PowerShell community extensions:

1. Sethu’s Blog: http://blogs.msdn.com/sethus/default.aspx

2. Chad Miller Blog: http://chadwickmiller.spaces.live.com/default.aspx

3. Chad Miller, SQL Server PowerShell Extensions: http://sqlpsx.codeplex.com/

Have fun!!

7月2日

Want to know how many PowerShell MVP’s in the world??

We are a total of 35 MVPs in the world.   Check the Microsoft site for more information on how to become an MVP.

:)

 

6月25日

Microsoft TechNet, MSDN, and some other learning resources…

Here’s some good Microsoft learning resources and can help you stay up-to-date with new technologies:

image image image image

 

1. Windows 7 Feature Walkthroughs:

http://technet.microsoft.com/en-us/windows/dd320282.aspx

2. TechNet “Microsoft – How Do I? Videos”:

http://technet.microsoft.com/en-us/cc138021.aspx

3. MSDN “Learn” section:

http://msdn.microsoft.com/en-us/bb188199.aspx

4. RAMP UP – Microsoft Developers community based learning program:

http://msdn.microsoft.com/en-us/rampup/default.aspx

5. THRIVE Program:

http://www.microsoft.com/click/thrive/

6. Microsoft Webcast Calendar:

http://www.microsoft.com/events/webcasts/calendar/monthview.aspx

Don’t forget to support your TechNet and MSDN quarterly meetings in your area when available.  And, take advantage of this information that mostly is free to view.

Enjoy!!

June 25th 2009 – So Florida SQL User Group – PowerShell and SQL Server presentation…

Tonight I will be presenting PowerShell and SQL Server bring in some samples.  There will be giveaways you don’t want to miss.  Also, you can download my presentation which includes supporting documents and all the PowerShell script samples.  During this presentation will be covering using SMO and SQLPS to manage your SQL Server. 

Location: DeVry University - SQL Server User Group Meeting, ROOM 254, 2300 SW 145th Ave., Miramar, FL

image

Please click in the following link: ()

6月22日

Windows PowerShell 2.0 is near…

 

Windows PowerShell 2.0 is around the corner.  Technet Script Center has made available the pre-release  documentation of the new Windows PowerShell 2.0.   This new release has a lot to offered to all IT professionals and scripters enthusiast. With already made modules to extend the power of this scripting .NET language.  Check it out and follow you PowerShell MVP’s in your area.

image

6月7日

PowerShell - Working with ODBC DSN Connection

How can we add ODBC connections without opening the Windows “ODBC Administrator” application?

Works in Windows Vista and Windows 7 RC.   We are going from this:

clip_image002

To this:

PS C:\> Add-ODBCconnection2HKCU.ps1

Here’s my sample of my registry before I run my PowerShell script:

clip_image004

I’m going to add an SQL ODBC connection to my local SQL Server “Developer” database which can be use in an MS Access and/or Excel application.

First, let us take a look at a VBScript sample that does this process.

(VBScript code modify from the Microsoft Scripting Center: http://tinyurl.com/eyk9t )

VBScript Code “AddODBCline.vbs” – (see how many lines of code?)

clip_image006

I’m not going to dissect VBScript, but this code works fine. Now, let take a look at PowerShell script that will do the same thing… and you guessed right!! You end up using less code and easy to read.

I basically study the VBScript work and then I found some blogs about build a registry keys using PowerShell script.

Using PowerShell make it easy for administrators to access and work with Registry keys. Use the CmdLet “Get-PSDrive” to see all predefined drive you can directly navigate and work. One of these is the Registry drives: “HKCU:” and “HKLM” drives.

clip_image008

Then, what’s needed to build these script?

  1. Create a variable to hold the HKCU path (not really require)
  2. Use the following DOS-like commands: “CD”, “MD”.
  3. Use the PowerShell Cmdlet: “Set-ItemProperty” (use the Help to list available parameters)
  4. Then, save everything in *.ps1 file.
  5. Additional considerations:
    1. Folder names with spaces, should be enclosed in single quotes.
    2. Run scripts as an “Administrator”

PowerShell – Add-ODBCConnect2HKCU.ps1 (how many lines of code?)

clip_image010

Last check both the Registry and your Windows ODBC Administrator application to see the added connection,

clip_image012

clip_image014

Now, you can use this connections in your Office application. If you need to remove the ODBC connection(s) then use the following script:

Remove-ODBCConnection2HKCU.ps1

clip_image016

Of course, you can keep enhancing these scripts and make them more powerful. 

Have fun with PowerShell!!

Download all scripts here:

3月30日

Orlando CodeCamp 2009 - "SQL Server and PowerShell" Session.

For all how attended the Orlando CodeCamp 2009 “SQL Server and PowerShell” session.   I posted the download link on my Florida PowerShell User Group website.   Please, click on the link below to get the files:

My Apologies to everyone,..  I notice I forgot to include my Powerpoint presentation and corrected the Zip filename.

Orlando CodeCamp 2009 - "SQL Server and PowerShell" Session.

Once again, Thanks for attending my session and keep supporting your community user groups.

:)

Max Trinidad ( email: maxt@putittogether.net )

3月27日

PowerShell 1.0 made available on Microsoft Updates

Here’s some information about PowerShell ver. 1.0 been available in the Microsoft Update download:

“… With PowerShell 1.0 on Windows update, we will now be reaching a  broader audience, a lot more than our 3.5 million downloads so far. This is our second step in making people ready for PowerShell and the rich set of features in 2.0 when they deploy Windows 7 or our WTR. Also, this release sets an expectation that the WTR of PowerShell 2.0 would be pushed through WU/MU/WSUS for enterprise deployment.

PowerShell 1.0 through MU is only offered:

· As an optional update

· If you don’t have any other version of PowerShell installed (including V2 CTPs) on your machine

· .NET 2.0 is installed on the machine

· OS is one of: XP-SP3, W2K3-SP2, Vista-RTM, Vista-SP1 …”

PowerShell is here to stay!

:)

3月15日

Build Your Own SQL Server 2008 Object Dependency Viewer - Windows Live

Awesome article that show how you can use PowerShell with, the combination of using the NodeXL .NET class libraries, and  the CodePlex “SQLPSX” so you can build your own SQL Server 2008 Object Dependency viewer. 

Great Stuff out there!!

Build Your Own SQL Server 2008 Object Dependency Viewer - Windows Live

result:

SQLdependsView

2月23日

Blain Barton's Blog : IT Pro Tiki Hut Tour - Spring 2009 Registration Open!

The IT Pro Tiki Hut Tour is on its way…

image_3

Look for the nearest location and register.  You don’t want to miss this event.

Blain Barton's Blog : IT Pro Tiki Hut Tour - Spring 2009 Registration Open!

1月29日

Mindre.net | Hyper-V Monitor Gadget for Windows Sidebar

Great tool for assisting managing Hyper-V virtual machines.  Give it a try.

Mindre.net | Hyper-V Monitor Gadget for Windows Sidebar

image image
:)
1月14日

New Blog Posted - Max-PIT> Microsoft Virtualization

Check out my blog on “Installing Windows 7 Beta on Hyper-V”.  Also, I included a PDF file with snapshots of the whole process from building a virtual machine all the way to connecting to your network.  Click on the link below:

Max-PIT> Microsoft Virtualization

Please, don’t forget to check our Florida PowerShell User Group at: http://www.flpsug.com/

BlogHyper01

Next, I will be blogging about Windows 7 and PowerShell.

12月24日

New Release is out – PowerShell Version 2 CTP 3 (not beta)

Check out the new community release of PowerShell and the Microsoft PowerShell Team blog.  There’s lot of information and its shaping up to be a great hit.

Download link here: <PowerShell Version 2 CTP 3 Download link >

Checkout the PowerShell Team Blog at: < PowerShell Team Blog >

New cmdlets, predefined variable, and ISE ( Integrated Scripting Environment )

image

image

Always remember this is not RTM yet!!

Enjoy!!

12月8日

John Baker's BritBlog => PowerShell Webcast series this Month December 2008

 

John Baker's BritBlog - Don't miss this opportunity to understand PowerShell.  Get involved and signed up to these series of webcasts.

Visit our Florida PowerShell User Group for resource information and local meetings: http://www.flpsug.com/

Have fun while doing PowerShell!

Thanks,

Max Trinidad

10月15日

Migrating Virtual Server 2005 R2 VM’s to Hyper-V...

Due to the fact, that I do work as an IT Pro, finally I got a chance to implement my first Hyper-V Servers on our IBM BladeCenter servers.  Please, take this documentation as is, but I have narrow down the steps to move all my Virtual Servers 2005 virtual machines into my new Hyper-V Server without much problems.  Its natural that there's always a learning curve but at the end its a straight process.

Virtual Server environment:

Currently, we have an IBM BladeCenter with 4 blade server connecting an IBM TotalStorage DS4700 SAN drive with 2TB total space. Two of the blades servers has Windows Server 2003 Enterprise 32bit Editions and the other has Windows Servers 2008 Enterprise 64bit Editions. On the Windows Server 2003 I have Virtual Server 2005 R2 and on the Windows Server 2008 I’m using Hyper-V RTM.

VM’s migration to Hyper-V

Things I found during my Virtual Server 2005 vm’s migration to Hyper-V:

Before you move your VS2005R2 VM, and to be done the last time you are on VS2005R, make sure to:

1. On your Local Admin account:

a. No screen savers to pop out.

b. Remove any Server Manager screen to pop out.

c. Remove “Virtual Machine Additions”

2. Then, do a shutdown (do not restart).

3. Ready to move your VM files.

There’s no need for other migration tools because you are going to end up doing more manual changes before your VM becomes fully operational under Hyper-V RTM.

Hyper-V Server Setup

Before you turned on you VM, make sure the following Hyper-V settings are in place:

1. Under “Server”

a. Provide a location for all your “Virtual Hard Disks”. All you VM’s Disk will be stored here:

    example “E:\HyperV_Server1\VirtualDISKs”

b. Provide a general folder where you’re going to store VM individually: example “E:\HyperV_Server1\”. Your VM config files will be stored on separately on each servername folder. This folder name will be create when you create a new virtual machine and attached your Virtual Disk to it. This way you will have the following folder structure: “E:\HyperV_Server1\NewServerName” for the VM you just created.

Hyper-V Virtual Machine Setup

To be done before you start the VM under Hyper-V:

1. Copy your VS2005r2 VM to your Hyper-V “Virtual Hard Disks” folder.

2. Run the “New Virtual Machine Wizard”:

a. Choose a name for your server

b. Assign memory

c. Configure Network – leave it “Not Connected”

d. Connect Virtual Hard Disk – here’s you attached you copied VHD’s

e. Completing new VM Wizard – make sure don’t check to “start VM” when finished.

Completing your Virtual Machine Settings

Here’s where you can adjust other devices settings before you start your virtual machine. Now, because your VHD’s comes from a Virtual Server, there’s one thing we need to set before we can continue:

1. Right click on your VM, select “Settings”:

a. Then, under “Hardware”:

       i. Add Hardware, Select “Legacy Network Adapter”

Please, notice that you are only adding a hardware and it will not connect to the network unless you enable it. At this time, don’t connect to the “Legacy Network Adapter” yet. This way we are going to see the adapter that was currently using on the other Virtual Server application. Following these steps you should be able to get to your old network adapter so you can decide to:

1. Keep the old network card with its IP addresses configurations, or

2. Give you the ability to remove the old adapter and use the Hyper-V Virtual Network Adapter

It’s your choice but failure to do this step will cause you not to see the adapter that your VM was using prior to Hyper-V. The old network adapter will be hidden from your hardware components and it will remain active when you start the server.

Starting your Hyper-V Virtual Machine

Here’s where you are going to spend more minutes (not hours) to finally make your VS2005 VM to work on your Hyper-V Server. As soon as the server becomes operational and previous steps has been completed. You are ready to install the Hyper-V “Integration Services” component. To Start your new Hyper-V virtual machine:

1. Right-Click on your VM, and select “Connect” or just Double-Click on the name.

2. Login using your Local Administrator ID (remember, server remains not connected to the network).

The following steps involves installing “Integration Services” but only using the keyboard. And, you might restart the server at least two times.

1. After your login, you need to cancel the “New Hardware Wizard”.

2. go to your “Virtual Machine Connection” pull-down menu:

a. Click on Action

b. Select “Insert Integration Services Setup Disk”

c. Wait for the prompt to start the installation

d. Then, reboots at the end.

3. When After, the server starts again you should have completed your initial migration. Now, you go back to check on your Legacy adapter before you go back to your server settings option and change it to connect.

This process took me less than 15min when I finally got my migration steps in place.

TIP: Did you know?

1. You can start your Virtual Machine without connecting your adapter, make changes to the server and then, while the server is running, change it back to “Connect”. This way you don’t have to restart the server until you are ready to connect back to the network.

2. Using the “Legacy Network Adapter” get you 100mb vs “Virtual Network Adapter” 10mb connection speed.

3. Increase you physical drive partition because you will need up to *32GB per virtual machine running on Hyper-V. This additional space doesn’t exist in Virtual Server 2005.

4. You don’t need the virtual machine configuration (*.vmc) file. You only need to move your VHD’s files to their new location.

5. These steps also apply to Virtual PC 2007 files.

6. If you feel you are getting stuck during the “Integration Services” installation. Just click on the “Ctrl-Alt-Delete” button in you Hyper-V VM Console. Then, use the keyboard “tab key” to select “Shutdown”. Then, you can continue with the installation.

7. Be ready to re-register/activate your Windows Server again.

*Note: This may vary depending on how you built your virtual machine. I’ve seen between 16GB up to 32GB.

9月30日

Software FX and IDERA joins Florida PowerShell User Group...

Yes, I'm happy to announce that beside "Software FX" now we have "Idera" to join as sponsor to our user group.

Please checkout both great products:

Software FX with "PowerGadgets" - Tool for the IT Professional.

Idera  with "PowerShellPlus Professional" - amazing Editor.

Both products add great values to your everyday needs and you will never regret having it.

Please download their evaluation copy:

http://www.softwarefx.com/sfxSqlProducts/powergadgets/

http://www.idera.com/Products/PowerShell/Default.aspx

9月15日

More stuff coming in our Florida PowerShell User Group...

Sign up for the next two events in the areas of West Palm and Miramar.  Plus, there will be three virtual session coming to "Second Life" with co-presenter Blain Barton (Microsoft IT Community Evangelist).  I will be posting the date soon.  Also, for those who subscribe to FLPSUG will chance of getting free gift from our sponsors: "SQL Server World User Group" and "Software FX". 

Please come and join us:

FLPSUG_newLogo1

FLPSUG giveaways will includes: 

 sswug01 ... From SWWUG:

* Two free Virtual Conference passes

SoftwareFX02 ... from Software FX:

* Some copies of "PowerGadgets" will be available.

For more information please check our website for more events information.

8月14日

PowerShell Tab-Expansion

Basically, you can use the tab to auto-complete what you are writing in your PowerShell (PS) cmdlet line.

Here’s some examples:

clip_image002

Then press the “tab” key a few times

clip_image004

clip_image006

Pick the “properties” or “method” you want to use to complete the cmdlet and run.

clip_image008

Now, using the one of the third-party PowerShell tools available on the Internet such as”PowerShellPlus”, you can take advantage of the Tab-expansion features in a graphical way.

clip_image010

A pull-down list will be available similar to the auto-completion features available in Visual Studio.

clip_image012 clip_image014

If you want to check out the “PowerShellPlus” tool, here the link: http://www.powershell.com/

Enjoy!

8月3日

Florida PowerShell User Group website is LIVE...

image 

This is a work in progress... and there will be lots of updates.  Currently working in the following sections: Articles, Community, and Library.  I will do my best in put together useful information and shortcuts to valuable resources.

<Click here> to access our Florida PowerShell User Group