Jump to content


mopey85

Status Filter rules passing variables

Recommended Posts

Hey Guys,

I have just set up a filter rule to email me the status of software deployments by running a powershell script.

I am currently passing the name into the powershell script by using this command

script.ps1 %msgsys

 

then within the first line of powershell i use

param([string]$strComputer)

 

This is working fine. I also wanted to pass the variable for message description so the script was

script.ps1 %msgsys %msgdesc

 

Powershell

param([string]$strComputer, [string]$message)

 

When i run this all that i get is the first word in the message.

example

The message was

The task sequence has completed successfully

 

My script will only return

"The"

 

How can i output the entire message not just the first word??

post-17870-0-23526500-1370053542_thumb.jpg

 

 

 

 

 

 

post-17870-0-23526500-1370053542_thumb.jpg

Share this post


Link to post
Share on other sites


Mine looks like this and works fine:

 

"C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe" "E:\Powershell_scripts\OSD_Provisioning_SCCM\email_OSD.ps1 '%msgsys' '%msgdesc'"

Share this post


Link to post
Share on other sites

Mine looks like this and works fine:

 

"C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe" "E:\Powershell_scripts\OSD_Provisioning_SCCM\email_OSD.ps1 '%msgsys' '%msgdesc'"

I notices you put singe inverted commas around %msgdesc.

 

i will try that and see how it goes.

 

UPDATE: So no luck.

 

I am wondering if it has something to do with setting execution policy and all of the other commands i have before it.

Share this post


Link to post
Share on other sites

With PowerShell 2.0 you can bypass the security policy with :

 

C:\WINNT\SysWOW64\windowspowershell\v1.0\powershell.exe -executionpolicy bypass -file E:\Powershell_scripts\OSD_Provisioning_SCCM\email_OSD.ps1 %msgsys

Share this post


Link to post
Share on other sites

After a hour of testing I found out that you must add double quotes around "%msgdesc" to get the full description.

 

Example of how my command line works:

 

"C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe" -executionpolicy bypass -file "D:\scripts\Dcreation.ps1" -message "%msgdesc"

  • Like 2

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...