Forskel mellem versioner af "PowerShell"

Fra NørderiWiki
Skift til: Navigation, Søgning
(AD: DisplayName)
(AD)
Linje 4: Linje 4:
  
 
= AD =
 
= AD =
New-ADGroup -Name smc-regnskab -Path "OU=Groups,OU=SMC,OU=Hosting,DC=kmhost,DC=local" -groupScope universal
 
  
 
<pre style="white-space: pre-wrap;  
 
<pre style="white-space: pre-wrap;  
Linje 11: Linje 10:
 
white-space: -o-pre-wrap;  
 
white-space: -o-pre-wrap;  
 
word-wrap: break-word">
 
word-wrap: break-word">
import-csv .\Brugere1.csv | %{
+
import-module ActiveDirectory
new-aduser -Name $_.DisplayName -DisplayName $_.DisplayName -GivenName $_.GivenName -SamAccountName $_.SamAccountName -UserPrincipalName $_.UserPrincipalName -Surname $_.Surname -Path 'OU=Users,DC=domain,DC=local' -CannotChangePassword $false -ChangePasswordAtLogon $false -ProfilePath "\\server\profiles\$($_.SamAccountName)" -HomeDrive 'Z' -HomeDirectory "\\server\user-home\$($_.SamAccountName)";
+
 
Set-ADAccountPassword -identity $_.SamAccountName -NewPassword (ConvertTo-SecureString -AsPlainText '!23456Pw' -Force) -Reset;
+
$OU_Name = 'IT'
 +
$StartPassword = '123456Pw'
 +
 
 +
New-ADOrganizationalUnit -Name $OU_Name -Path "OU=Users,DC=domain,DC=local"
 +
New-ADGroup -Name "$OU_Name-Users" -Path "OU=$OU_Name,OU=Users,DC=domain,DC=local" -groupScope global
 +
New-ADOrganizationalUnit -Name Users -Path "OU=$OU_Name,OU=Users,DC=domain,DC=local"
 +
 
 +
import-csv .\"$OU_Name-Brugere.csv" | %{
 +
new-aduser -Name $_.DisplayName -DisplayName $_.DisplayName -GivenName $_.GivenName -SamAccountName $_.SamAccountName -UserPrincipalName $_.UserPrincipalName -Surname $_.Surname -Path "OU=Users,OU=$OU_Name,OU=Users,DC=domain,DC=local" -CannotChangePassword $false -ChangePasswordAtLogon $false -ProfilePath "\\server\profiles\$($_.SamAccountName)" -HomeDrive 'Z' -HomeDirectory "\\server\user-homes\$($_.SamAccountName)";
 +
Set-ADAccountPassword -identity $_.SamAccountName -NewPassword (ConvertTo-SecureString -AsPlainText $StartPassword -Force) -Reset;
 
Enable-ADAccount -identity $_.SamAccountName
 
Enable-ADAccount -identity $_.SamAccountName
Add-ADGroupMember -Identity Users -Member $_.SamAccountName
+
Add-ADGroupMember -Identity "$OU_Name-Users" -Member $_.SamAccountName
 
}
 
}
 
</pre>
 
</pre>

Versionen fra 25. jan 2013, 08:26

PowerShell er Microsoft's mere eller mindre efter ligning af UNIX's stærke kommandoer. PowerShell er bygget ind i det fleste server programmer fra MS idag, og kan der med administreres med PowerShell.

PowerHell.dk

Indholdsfortegnelse

import-module ActiveDirectory

$OU_Name = 'IT'
$StartPassword = '123456Pw'

New-ADOrganizationalUnit -Name $OU_Name -Path "OU=Users,DC=domain,DC=local"
New-ADGroup -Name "$OU_Name-Users" -Path "OU=$OU_Name,OU=Users,DC=domain,DC=local" -groupScope global
New-ADOrganizationalUnit -Name Users -Path "OU=$OU_Name,OU=Users,DC=domain,DC=local"

import-csv .\"$OU_Name-Brugere.csv" | %{
new-aduser -Name $_.DisplayName -DisplayName $_.DisplayName -GivenName $_.GivenName -SamAccountName $_.SamAccountName -UserPrincipalName $_.UserPrincipalName -Surname $_.Surname -Path "OU=Users,OU=$OU_Name,OU=Users,DC=domain,DC=local" -CannotChangePassword $false -ChangePasswordAtLogon $false -ProfilePath "\\server\profiles\$($_.SamAccountName)" -HomeDrive 'Z' -HomeDirectory "\\server\user-homes\$($_.SamAccountName)";
Set-ADAccountPassword -identity $_.SamAccountName -NewPassword (ConvertTo-SecureString -AsPlainText $StartPassword -Force) -Reset;
Enable-ADAccount -identity $_.SamAccountName
Add-ADGroupMember -Identity "$OU_Name-Users" -Member $_.SamAccountName
}

CSV fil:

SamAccountName,UserPrincipalName,GivenName,Surname,DisplayName

IIS

http://learn.iis.net/page.aspx/447/managing-iis-with-the-iis-70-powershell-snap-in/

New-WebVirtualDirectory http://technet.microsoft.com/en-us/library/ee790582.aspx

IIS:\>New-WebVirtualDirectory -Site "Default Web Site" -Name ContosoVDir -PhysicalPath c:\inetpub\contoso

New-Website http://technet.microsoft.com/en-us/library/ee790605.aspx

IIS:\>New-WebSite -Name TestSite -Port 80 -HostHeader TestSite -PhysicalPath "$env:systemdrive\inetpub\testsite"

Fundet på sexchange:

$objIIS = new-object System.DirectoryServices.DirectoryEntry("IIS://localhost/W3SVC/1/Root")
$children = $objIIS.psbase.children
$vDir = $children.add("NewFolder",$objIIS.psbase.SchemaClassName)
$vDir.psbase.CommitChanges()
$vDir.Path = "C:\Documents and Settings\blah\Desktop\new"
$vDir.defaultdoc = "Default.htm"
$vDir.psbase.CommitChanges()

Tips

http://myitforum.com/cs2/blogs/rcrumbaker/archive/2006/05/10/20079.aspx

ADSI Scripting with Windows PowerShell

http://larsjoergensen.net/tag/powershell

Links