PowerShell使用教程

PowerShell使⽤教程
1、打开powershell 不说了
2、获取帮助:    get-help  (所有命令都是cmdlet格式,help也不例外)
3、查看有哪些命令:  get-command  (可看到命令类型有:Alias别名、Cmdlet命令、Function函数)
4、查看以 get开头的命令: get-command get-*
5、查看get-process命令的⽤法:  get-help get-process
6、⽤get-process查进程notepad :get-process -name *notepad*  (当前,你得先打开⼀个记事本)
7、获取stop-process在线帮助: get-help stop-process -Online
8、⽤stop-process杀除进程notepad:Stop-Process -Name "notepad"
想想还能⼲什么
9、下载⽂件
$webRequest = [System.Net.HttpWebRequest]::Create("/fwlink/?LinkID=149156")
感应门制作$webRequest.Method = "GET";
$webRequest.UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)"
$response = $webRequest.GetResponse()
$stream = $response.GetResponseStream()
$reader = New-Object System.IO.BinaryReader($stream)
$bytes = New-Object System.Byte[] $response.ContentLength
for ($read = 0; $read -ne $bytes.Length; $read += $reader.Read($bytes,$read,$bytes.Length - $read) ){ }
[System.IO.File]::WriteAllBytes("",$bytes);防尘接线盒
将上述代码copy到powershell 后,下载到哪⼉了?
执⾏pwd  显⽰c:\users\⽤户名到这个⽬录下到了  (原来在原代码中c:少了\,但容错能⼒很强,呵呵)10、下载并安装MICROSOFT® REPORT VIEWER 2015 RUNTIME
#添加程序集
Add-Type -AssemblyName System.IO
Add-Type -AssemblyName System.IO.Compression
铝钉机
碱式氧化锰Add-Type -AssemblyName System.IO.Compression.FileSystem
#下载地址
$DownloadUrl = "/download/A/1/2/A129F694-233C-4C7C-860F-F73139CF2E01/ENU/x86/ReportViewer.msi"
苹果削皮机
#下载到Temp⽬录
$TempPath = $env:TEMP
#下载的⽂件名
$FileName = "ReportViewer.msi"
#存储的完整⽂件路径
$FullPath = "$TempPath\$FileName"
#Download
$client = New-Object System.Net.WebClient
"Now is downloading MICROSOFT® REPORT VIEWER 2015 RUNTIME"
$client.DownloadFile($DownloadUrl, $FullPath)蓄电池隔板
"Download success"
#Install
< /i $FullPath /qr
"Press any key to exit"
Read-Host
11、卸载MICROSOFT® REPORT VIEWER 2015 RUNTIME
< /x "{3ECE8FC7-7020-4756-A71C-C345D4725B77}" /qr
可以指定msi安装包,也可以指定ProductCode,可以访问从注册表以下位置查ProductCode。
计算机\HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall
如果是压缩包式的安装包,如 Microsoft Visual C++ 2015 Redistributable,
可以直接使⽤ vc_ /?查看⾃动化安装的参数。
也可以使⽤Winrar等压缩软件,解压出msi安装包,继续使⽤执⾏⾃动化安装。这样就可以⾃动安装软件运⾏环境了。
注意:msiexec要以管理员权限运⾏,否则会弹出UAC对话框。要么就关闭UAC功能。

本文发布于:2024-09-21 05:32:18,感谢您对本站的认可!

本文链接:https://www.17tex.com/tex/4/101930.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:命令   安装   安装包   查看   管理员   下载
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2024 Comsenz Inc.Powered by © 易纺专利技术学习网 豫ICP备2022007602号 豫公网安备41160202000603 站长QQ:729038198 关于我们 投诉建议