PowerShell - Anton-L-GitHub/Learning GitHub Wiki
TOM
- Finns stöd att köra PowerShell mot linux/unix-miljöer
Verb-Substantiv -attribut | Verb-Substantiv -växel
$min_variabel = 5;
$total = 5;
for ($diskIndex=0; $diskIndex -lt $total; $diskIndex++) {
$diskId = "{0:00}" -f ($diskIndex + 1)
$diskNamn = "Extradisk$diskID"
Write-Host "Skapar disk" ($diskIndex + 1) "av" $total ":" $diskNamn
NEW-VHD -Dynamic C:\VM\DC\$diskNamn.vhdx -SizeBytes 60GB
Add-VMHardDiskDrive -VMName DC -ControllerType SCSI -Path C:\vm\DC\$diskNamn.vhdx
}
-
|
= Nästa del i pipen -
>
= Ger outputen till ...
Cmdlet | Description |
---|---|
New-ADUser | Creates user accounts |
Set-ADUser | Modifies properties of user accounts |
Remove-ADUser | Deletes user accounts |
Set-ADAccountPassword | Resets the password of a user account |
Set-ADAccountExpiration | Modifies the expiration date of a user account |
Unlock-ADAccount | Unlocks a user account after it hasbecome locked after too many incorrect login attempts |
Enable-ADAccount | Enables a user account |
Disable-ADAccount | Disables a user account |
New-ADUser "Sten Faerch" –AccountPassword (Read-Host–AsSecureString "Enter password") -Department IT
or a better one
New-ADUser
-Name "Staffan Stalledräng"
-GivenName "Staffan"
-Surname "Stalledräng"
-SamAccountName = "staffan"
-UserPrincipalName "[email protected]"
-Description "Kung"
-Path "OU=Användare,OU=Stockholm,DC=jultomten,DC"
-AccountPassword (ConvertTo-SecureString -AsPlainText "Linux4Ever" -Force) -passThru | Enable-ADAccount
cmdlet | Description |
---|---|
New-ADGroup | Creates new groups |
Set-ADGroup | Modifies properties of groups |
Get-ADGroup | Displays properties of groups |
Remove-ADGroup | Deletes groups |
Add-ADGroupMember | Adds members to groups |
Get-ADGroupMember | Displays membership of groups |
Remove-ADGroupMember | Removes members from groups |
Add-ADPrincipalGroupMembership | Adds group membership to objects |
Get-ADPrincipalGroupMembership | Displays group membership of objects |
Remove-ADPrincipalGroupMembership | Removes group membership from an object |
New-ADGroup –Name "CustomerManagement" –Path "ou=managers,dc=adatum,dc=com" –GroupScope Global –GroupCategory Security
Add-ADGroupMember –Name “CustomerManagement” –Members "Joe"
cmdlet | Description |
---|---|
New-ADComputer | Creates new computer accounts |
Set-ADComputer | Modifies properties of computer accounts |
Get-ADComputer | Displays properties of computer accounts |
Remove-ADComputer | Deletes computer accounts |
Test-ComputerSecureChannel | Verifies or repairs the trust relationship between a computer and the domain |
Reset-ComputerMachinePassword | Resets the password for the computer account |
New-ADComputer –Name “LON-SVR8” -Path "ou=marketing,dc=adatum,dc=com" -Enabled $true
Test-ComputerSecureChannel -Repair
cmdlet | Description |
---|---|
New -ADOrganizationalUnit | Creates OUs |
Set-ADOrganizationalUnit | Modifies properties of OUs |
Get-ADOrganizationalUnit | Views properties of OUs |
Remove-ADOrganizationalUnit | Delete OUs |
New-ADOrganizationalUnit –Name “Sales” –Path "ou=marketing,dc=adatum,dc=com" –ProtectedFromAccidentalDeletion $true
Install-ADDSDomainController
Install-WindowsFeature <Feature> -ComputerName <Computername>
Get-ADUser -Filter * SearchBase "OU=Test,DC=domaincontroller,DC=local" | Set-ADuser -Department "Hej"
Make new virtual harddrive
New-VHD -Dynamic "C:\VM\lab\Extradisk.vhdx" -SizeBytes 60GB
Inspect VM
Import-Module Hyper-V
Enable-VMResourceMetering Surfdator1
Measure-VM Surfdator1
TOM
Get-ChildItem
CD / LS
Get-ChildItem
Visa objektets Metoder, Properties, aliases, osv.
Get-Member