not sure if this is possible, but i can't see why it isn't.... here's the scenario... i get emails from my SCOM server that tell me when a user has "Reached the maximum category subscriptions per publisher limit" and then it tells me the user's SIP address that reached the limit. i then have to go to my powershell and run the command:
Grant-CsPresencePolicy -Identity sip:firstname.lastname@example.org -PolicyName PopularUsers
is there a way that i can "double click" a .ps1 script, have it open powershell, then ask me "What is the sip address" i then enter email@example.com and hit enter and it runs the above command inserting the sip address i specified automatically??
Thanks in advance
By default PowerShell does not allow you to double click a .ps1 file and run it. I would not recommend changing those default settings.
One possiblilty would be to create a script as an example
param ( [parameter(Mandatory=$true)] [string]$myparam
"this was my parameter $myparam"
then create an icon on your desk top for powershell.exe
right click and open properties
change the Target to
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoExit -File "c:\scripts\test\test-param.ps1"
or whatever is appropriate
When you double click the icon powershell starts and runs your script. Because the parameter is mandatory you will be prompted for a value.
Put your code in the script and off you go.
Once the command has run close the PowerShell window. If you leave the -NoExit off the command then it will close automatically. I prefer to leave the window open so I can catch error messages
thanks for the reply. i hate to admit... i am not a coder or a scripter so i do not know how to create the actual script. i understand the rest of your reply about creating a shorcut to the powershell, but i do not know how to write the script itself and thats what i really need.
This should do it for you. Its simplistic but as you are using and understand what is needed it will do
save the script with a .ps1 extension and call it as discussed in my previous reply
param ( [parameter(Mandatory=$true)] [string]$user)
Grant-CsPresencePolicy -Identity sip:$($user) -PolicyName PopularUsers
thank you so much!!! intial tests are failing but i think i know why. i am going to play around with it tomorrow but i am positive in the end, this will work. thanks alot!!!!