惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Secure Thoughts
S
Securelist
P
Proofpoint News Feed
D
DataBreaches.Net
Cisco Talos Blog
Cisco Talos Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
Project Zero
Project Zero
A
About on SuperTechFans
罗磊的独立博客
WordPress大学
WordPress大学
月光博客
月光博客
Latest news
Latest news
C
Cyber Attacks, Cyber Crime and Cyber Security
GbyAI
GbyAI
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
博客园 - 三生石上(FineUI控件)
F
Fortinet All Blogs
W
WeLiveSecurity
Attack and Defense Labs
Attack and Defense Labs
V
Visual Studio Blog
Blog — PlanetScale
Blog — PlanetScale
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
P
Privacy International News Feed
AI
AI
博客园 - 司徒正美
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Stack Overflow Blog
Stack Overflow Blog
M
MIT News - Artificial intelligence
Help Net Security
Help Net Security
T
Tor Project blog
V
Vulnerabilities – Threatpost
C
Cisco Blogs
I
Intezer
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
MyScale Blog
MyScale Blog
雷峰网
雷峰网
MongoDB | Blog
MongoDB | Blog
Forbes - Security
Forbes - Security
V
V2EX
Apple Machine Learning Research
Apple Machine Learning Research
T
Threat Research - Cisco Blogs
B
Blog RSS Feed
博客园 - 叶小钗
N
News and Events Feed by Topic
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Simon Willison's Weblog
Simon Willison's Weblog
C
CERT Recently Published Vulnerability Notes
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
N
News and Events Feed by Topic

博客园 - 挖土.

学笛子 PowerShell: Try...Catch...Finally 实现方法 How to set the compuder to auto login 让 PowerShell 2.0 支持 DotNet FrameWork 4.0 PowerShell 调用.netFramework中的静态函数 PowerGUI Visual Studio is now in beta! PowerShell 中定义和使用泛型 PowerShell 如何引用DLL PowerShell中Add-Content 和 Out-File 的区别 给string加几个扩展方法 加快 c++ Builder 5编译速度 Windows 7 下的 SUBST 命令 How to configure the BDE for Windows Vista/7 - 挖土. Linker problems with Borland builder SQL 中的中位值计算 Windows 7的“上帝模式” XML 序列化和反序列化详例代码 给存储过程传递一个表 VSIdeTesthost installation issue - 挖土.
用 Powershell 安装Dotnet FrameWorrk 4.0
挖土. · 2010-12-08 · via 博客园 - 挖土.

在微软的技术论坛上看到这个脚本,感觉自己的PowerShell 理念,还有很多不熟悉,好好研究了一下这个脚本,记录在自己的Blog上。


怎样同时为网络中很多电脑安装Dotnet Framework 4.0。

 1 $Hosts= Get-Content -Path "C:\hosts.txt"
 2 [ScriptBlock] $script = {
 3     #$ErrorActionPreference = "Stop"
 4     $MachineName= gc env:computername
 5     C:\Windows\System32\net.exe use "\\RemoteMachine\SharedFolder\DotnetFrameWork 4.0" password /user:domain\username 
 6     if(!(Test-Path "C:\Temp"))
 7     {
 8         New-Item -Path "C:\Temp" -ItemType directory
 9     }
10     Copy-Item -Path "\\RemoteMachine\SharedFolder\DotnetFrameWork 4.0\dotNetFx40_Full_x86_x64.exe" -Destination "C:\Temp" -Force -Recurse    
11     function LaunchProcessAndWait([string] $FileName, [string] $CommandLineArgs)
12     {
13         #preferences
14         $ErrorActionPreference="Stop"
15         try
16         {
17             Write-Host "Starting process $FileName on machine $($MachineName)"
18             $p = Start-Process -FilePath $FileName -ArgumentList $CommandLineArgs -Wait -PassThru
19             Write-Host "The process $FileName exit code is $($p.exitcode)"
20             return $p.ExitCode            
21         }
22         catch
23         {
24             Write-Host "Error launching process $FileName"
25             throw
26         }
27     }
28     LaunchProcessAndWait "C:\Temp\dotNetFx40_Full_x86_x64.exe" "/I /q"
29 }
30 $cred = Get-Credential
31 $sessions = $Hosts | New-PSSession -Credential $cred
32 Invoke-Command -ScriptBlock $script -Session $sessions
33 $sessions | Remove-PSSession

另外的解决方法: 

-CredSSP 非常重要. 否则安装会被远程机的 UNC 阻止而失败,需要为所有的远程机启用 CredSSP. This works only from Vista SP1 onwards since CredSSP is not available on XP SP3.

代码

1 $cred = Get-Credential
2 Invoke-Command -ComputerName "Server01" -ScriptBlock { Start-Process -FilePath "\\Staging\Share\dotNetFx40_Full_x86_x64.exe" -ArgumentsList "/q /norestart" } -CredSSP -Crdential $cred