开发者

How to write a powershell script to initiate user profile creation on server 2008

开发者 https://www.devze.com 2023-02-14 04:42 出处:网络
I\'m trying to automate application installa开发者_开发技巧tion on new server instances, but I\'m running into an issue when the user I\'m impersonating hasn\'t logged onto the system before.

I'm trying to automate application installa开发者_开发技巧tion on new server instances, but I'm running into an issue when the user I'm impersonating hasn't logged onto the system before.

It seems there are some necessary files or registry entries created during profile creation at first logon that the application needs to access when installing.

My question is primarily how I can use powershell to automate the initition of a domain account profile on a Server 2008 instance?

My initial extremely hacky thought was to initiate an rdp session from a connection file using mstsc.exe, wait for the initial setup to complete, then log the user off, but I'm thinking there has to be a cleaner way.

Also, these processes must all be run locally from the machine using a local user account that has admin rights.


You could try running psexec from within PowerShell to create the user profile on the remote system before you start the install process.

psexec.exe \\Server.domain.com cmd

exit


I know this is an old thread but it was one of the results when I was looking for a way to create a user profile on several remote machines on a domain. Here's how I finally did it, though it is likely not the most efficient method:

Import-Module ActiveDirectory
$scriptblock = {}
$Cred = Get-Credential $env:userdomain\$env:username
$comps = Get-ADComputer -Filter "Name -like 'WS*'" | Select Name -expandproperty Name
foreach ($comp in $comps)
   {
   Invoke-Command -ComputerName $Comp -Scriptblock ${Scriptblock} -Credential $Cred -Authentication CredSSP
   }
0

精彩评论

暂无评论...
验证码 换一张
取 消