我遇到了一些关于运行PowerShell命令的问题.它所做的只是运行一个将在CMD提示窗口中运行的命令.
这是命令:
"C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\i386\CmRcViewer.exe" PCNAME
我已经尝试了以下但没有成功(我尝试过多次迭代尝试并获得一个有效.语法可能都搞砸了):
$TEXT = $textbox.Text #$textbox is where the user enters the PC name.
$CMDCOMMAND = "C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\i386\CmRcViewer.exe"
Start-Process '"$CMDCOMMAND" $TEXT'
#iex -Command ('"C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\i386\CmRcViewer.exe"' $TEXT)
Run Code Online (Sandbox Code Playgroud)
该命令将只打开SCCM远程连接窗口到用户在文本框中指定的计算机.
Test-Path在if语句中使用时,我希望获得if语句成功的路径.
例如,这些文件存在于C中:
C:\Test6_1_15.txt
C:\Test6_2_15.txt
C:\Test6_3_15.txt
C:\Test6_4_15.txt
Run Code Online (Sandbox Code Playgroud)
我在"then"分支怎么办?
$Path = "C:\Test6_*_15.txt"
if (Test-Path $Path)
{
# if test passes because there are 4 files that fit the test, but I want to be
# able to output the file that made the if statement succeed.
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试按下一个按钮打开一个outlook草稿,我们可以在"To:"中键入并单击"发送".
我的大部分内容都使用以下代码:
$SUBJECT = ('Ticket: ' + $textticketnumber.text)
CreateLink #Function that gets a weblink and stores it to variable $rtblink.Text
$BODY = $rtblink.Text
$EMAILSIG = Get-Content ($env:USERPROFILE + "\AppData\Roaming\Microsoft\Signatures\*.htm")
$ol = New-Object -comObject Outlook.Application
$mail = $ol.CreateItem(0)
$mail.Subject = "$SUBJECT"
$mail.Body = "`n$BODY`n$EMAILSIG"
$inspector = $mail.GetInspector
$inspector.Display()
Run Code Online (Sandbox Code Playgroud)
问题是电子邮件正文的原始HTML代码不是正确的签名.我可以将get-content更改为*.txt而不是.htm但是签名中没有格式化,而且它将所有内容都放在一行上.
有没有办法使代码的主体与html一起使用,或者是否有另一种方法将签名插入到具有正确格式的电子邮件中?