Place a shortcut of shell command on desktop

Hi,
I have Exchange 2010, and every week I run a command in Exchange Management Shell to run a report of the mailbox sizes. I know the command but instead of typing this inside the Shell all the time, I want to create a shortcut to place it on the desktop and run it. Can you please help? Thanks!
Bob MacphersonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jon BrelieSystem ArchitectCommented:
put it in a script and execute it that way
"./scriptname.ps1"


Or, you can make a shortcut calling  "X:\path\to\powershell.exe" -File "X:\path\to\script.ps1"
0
Mohammed KhawajaManager - Infrastructure:  Information TechnologyCommented:
If you are outputting to a file then yes, you can create a shortcut.  The shortcut command would be as " powershell c:\xxxx\script1.ps"
0
Bob MacphersonAuthor Commented:
This is the command I run (get-mailboxstatistics -server Mail | sort-object TotalitemSize -descending | select-object Displayname,Itemcount,@{name="MailboxSize";exp={$_.TotalItemSize}} | convertto-Html | out-file c:\mailbox\report.htm), how do I put it in a shortcut? Thanks
0
Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

Jon BrelieSystem ArchitectCommented:
open notepad
paste the command (turn off word wrap so you don't get any weird returns)
save it as "MailboxStats.ps1" or whatever
test:  In EMS, CD to where you saved it, and run it "./MailboxStats.ps1"

If that works, then create a shortcut like I previously described.  
Target = "powershell.exe -File script.ps1"
0
SeanSystem EngineerCommented:
if you run it every week why don't you just do a scheduled task to run the script once a week? save you a little trouble....

good how to:
http://community.spiceworks.com/how_to/show/17736-run-powershell-scripts-from-task-scheduler
0
Bob MacphersonAuthor Commented:
OK, I created the script and it runs fine, but I'm having trouble creating the shortcut. I went to Desktop and chose New Shortcut and typed powershell.exe C:\MailboxSize.ps1. I ran the shortcut but nothing happened. Then I changed it to  powershell.exe -File C:\MailboxSize.ps1, but again nothing happened. Then I typed C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File C:\MailboxSize.ps1, and again nothing happened. Finally, I typed "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -File "C:\MailboxSize.ps1", but still didn't run.
0
SeanSystem EngineerCommented:
when you run a script this way you probably won't see a prompt as it closes the screen once the script is complete. Did you make sure it didn't output the file?
0
Jon BrelieSystem ArchitectCommented:
My bad... these are exchange commands, so you need to load the proper tools.

Add these to the beginning of your PS1 file:

set-executionpolicy RemoteSigned

Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bob MacphersonAuthor Commented:
Yes, it works now, thank you guys!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Exchange

From novice to tech pro — start learning today.