Click here to Skip to main content
15,890,415 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I need the script to get the computer name automatically for the user, and also incorporate the following lines formatted in the body of the message:
CSS
PROBLEM
========
User stated problem with computer or issue

REQUIRED INFORMATION
======================
Computer Name: Pre fill from script actions
IP Address: Pre fill from script actions
Mac Address: Pre fill from script actions
Computer Domain: Pre fill from script actions


This way once the user executes the script it will develop an email ticket with useful information to send to the Helpdesk organizational box.



PowerShell


PHP
[CmdletBinding()]
param ($computername = (Read-Host "Enter Computer Name"),


    $subject = '### Inbound Ticket ###',

    $to = 'Help@us.com',

    $bcc = '',

    $body = $Collection,

    #$body = (Get-Content -path "c:\powershell\serialnumber\SerialNumber.csv"),

    #$mail = "mailto:$to&subject=$subject&body=$body",

    [string]$ErrorLog = 'c:\powershell\useful\errorlog\retry.txt',

    [switch]$LogErrors
    )

 [Array]$Collection = foreach($computer in $computername)

 {

 $os = Get-WmiObject `
        Win32_OperatingSystem -computer $computer

 $model = Get-WmiObject `
        Win32_ComputerSystem -computer $computer


   $body = New-Object -TypeName PSObject -Property @{
   Computername = $computer;
   LoggedIn = $Model.username;
   OSVersion = $os.Caption;
    Model = $Model.Model;

   } | format-list | Out-String


 #$obj | convertTo-csv | out-string

 #$obj = $body
 #$Collection = [string]$body


 #[String]$Collection

 [string]$body

 Start-Process -FilePath "mailto:$to&bcc=$bcc&subject=$subject&body=$body"
}

$Collection
Posted
Updated 15-Aug-14 5:03am
v2
Comments
[no name] 15-Aug-14 11:03am    
And do you have some sort of a question you wanted to ask?
[no name] 15-Aug-14 11:08am    
Yes, I want to eliminate the first parm line to instead of asking the end users for their computer name to just go an retrieve it itself then complete the action. This way the end users do not have to try an figure out how to retrieve the name.

 
Share this answer
 
Comments
[no name] 15-Aug-14 12:13pm    
I am using this line for the subject of the email
$subject = "### Incoming Ticket From $env:USERNAME , $env:COMPUTERNAME ###", <----the input

Now it produces this in my subject line, do you know how to fix it to only show the Quoted?
52MHMVW3-NC0ZBN, 1289523444E : ### Incoming Ticket### <--- the output in outlook.
[no name] 15-Aug-14 12:15pm    
Nevermind it was the start-process line that was throwing that issue.
PHP
[CmdletBinding()]
param ($computername = (Read-Host "Please state the problem you are having"),


   $subject = "### Incoming Ticket From User: $env:USERNAME Computer: $env:COMPUTERNAME ###",

   $to = "NCIT.Help@us.af.mil",

   $bcc = '',

   $body = $Collection,

  [string]$ErrorLog = 'c:\powershell\useful\errorlog\retry.txt',

   [switch]$LogErrors
    )

 [Array]$Collection = foreach($computer in $computername)

 {


$body = New-Object -TypeName PSObject -Property @{
   Problem = $computer;

   } | format-list | out-string






 #$obj | convertTo-csv | out-string

 #$obj = $body
 #$Collection = [string]$body


 #[String]$Collection

 [string]$body





 Start-Process -FilePath "mailto:$to&subject=$subject&body=$body"
}


$Collection
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900