New-SmbMapping command to map a remote network share to a local drive letter.
New-SmbMapping -LocalPath Y: -RemotePath \\server\ShareName
From a “Hey, Scripting Guy! Blog” post.
An alternative to using the NETDOM command line program to rename and join computers to an Active Directory Domain is to use these Windows PowerShell 2.0 command:
(Get-WmiObject win32_computersystem).rename("newname") add-computer -Credential iammred\administrator -DomainName iammred.net Restart-Computer
In the first command, I use the Get-WmiObject cmdlet to retrieve the Win32_ComputerSystem Windows Management Instrumentation class. (The Get-WmiObject cmdlet has an alias of gwmi, and it will also take credentials if required.) Because this class returns only one instance, I can use my group and dot trick (see My Ten Favorite Windows PowerShell Tricks) to directly call the Rename method to rename the computer.
After I rename the computer, I use the Add-Computer cmdlet to join the computer to the domain. The Add-Computer cmdlet allows me to specify the credentials that have rights to add computers to the domain, in addition to the name of the domain to join. Although I did not do it in my example, there is also an ou parameter that allows you to specify the path to the OU that will contain the newly created computer account.
The last command, Restart-Computer, appears without any parameters. This means that the computer will restart within one minute, and it will attempt to cause processes to politely exit (generally a good thing). For emergency type of situations, there is the Force switch that will cause the computer to immediately restart, and not wait on processes to politely exit. The use of this optional parameter can lead to data loss in some situations.