帮助改进脚本 [英] Help with script improvement
本文介绍了帮助改进脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要脚本自动为用户获取计算机名称,并且还包含格式化在消息正文中的以下行:
问题
========
用户 陈述 问题 computer 或 issue
必需 信息
======================
计算机 名称: 前 fill 来自 script 操作
IP 地址: 前 填充 来自 script actions
Mac 地址: 前 填充 来自 script actions
Computer 域: 前 填充 来自 script actions
这样一旦用户执行脚本,它将开发一个包含有用信息的电子邮件票据到帮助台组织框。
[CmdletBinding()]
param($ computername =(Read-Host 输入计算机名),
$ subject = ' ###入境机票###',
$ 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',
[转] $ LogErrors
)
[数组] $ Collection = foreach($ computer < span class =code-keyword> 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;
} |格式列表| 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
解决方案
computername =(Read-Host 输入计算机名),
subject = ' ###入境票证###',
to = ' Help@us.com',
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:
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.
[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
解决方案
computername = (Read-Host "Enter Computer Name"),
subject = '### Inbound Ticket ###',
to = 'Help@us.com',
这篇关于帮助改进脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文