Sunteți pe pagina 1din 4

Get-Command -Module ADDSDeployment

Get-Help Install-WindowsFeature examples / Detailed /-full / -Online


Update-Help
Get-WindowsFeature -Name Print* -ComputerName SEA-SRV-1 | Where-Object InstallState -eq InstalledInstallWindowsFeature Migration ComputerName SERVER7
Import-Module ServerManager
Add-WindowsFeature Migration
Get-SmigServerFeature
Uninstall-WindowsFeature Server-Gui-Mgmt-Infra Restart
Install-WindowsFeature Server-Gui-Mgmt-Infra,Server-Gui-Shell -Restart -Source
C:\mountdir\windows\winsxs
Install-WindowsFeature Server-Gui-Mgmt-Infra-Restart -Source C:\mountdir\windows\winsxs
dism /get-wiminfo /wimfile:D:\sources\install.wim
dism /mount-wim /wimfile:D:\sources\install.wim /Index:<n> /mountdir:C:\mountdir /readonly
Install-WindowsFeature Server-Gui-Mgmt-Infra,Server-Gui-Shell -Restart -vhd C:\Users\Public\Documents\HyperV\Virtual Hard Disks\SERVER6.vhdx -Source C:\mountdir\windows\winsxs
Configure-SMRemoting get / -Disable / -Enable
Install-WindowsFeature -Name RSAT -IncludeAllSubFeature -ComputerName SEA-SRV-1
Invoke-Command -ComputerName SEA-SRV-1,SEA-SRV-3 -ScriptBlock {Install-WindowsFeature -Name XPSViewer}
Start-Job -ScriptBlock {Install-WindowsFeature -name XPS-Viewer -ComputerName SEA-DC-1}
Get-Job -Name Job4
Get-Job -Name Job4 | Select-Object State
$job = Start-Job -ScriptBlock {Install-WindowsFeature -name XPS-Viewer -ComputerName SEA-DC-1}
Receive-Job -Job $job
$trigger = New-JobTrigger -Once -At 6:40PM
Register-ScheduledJob -Name InstallXPS -ScriptBlock {Install-WindowsFeature -Name XPS-Viewer -ComputerName
SEA-DC-1} -Trigger $trigger
$script = {Start-Job -ScriptBlock {Install-WindowsFeature -Name Windows-Server-Backup}}$script2 = {Start-Job ScriptBlock {Uninstall-WindowsFeature -Name Windows-Server-Backup}}
$SEASRV1 = New-PSSession -ComputerName SEA-SRV-1
Invoke-Command $SEASRV1 $script
Disconnect-PSSession -Name $SEASRV1
Connect-PSSession -Name $SEASRV1
Import-Module ADDSDeployment
Install-ADDSForest `
-CreateDnsDelegation:$false
-DatabasePath C:\Windows\NTDS `
-DomainMode Win2012 `
-DomainName corp.contoso.com
-DomainNetbiosName CORP `
-ForestMode Win2012 `
-InstallDns:$true `
-LogPath C:\Windows\NTDS `
-NoRebootOnCompletion:$false `
-SysvolPath C:\Windows\SYSVOL `
-Force:$true
dsquery * cn=schema,cn=configuration,dc=fabrikam,dc=com -scope base
-attr objectVersion
Set-Item wsman:\localhost\Client\TrustedHosts -Value SEA-SRV-1
Get-Item wsman:\\localhost\Client\TrustedHosts
Test-ADDSForestInstallation -DomainName corp.adatum.com
Set-Execution Policy Unrestricted
Invoke-Command -ComputerName SEA-SRV-1 -FilePath C:\scripts\script1.ps1
Install-ADDSDomainController -InstallDns -Credential
(Get-Credential CORP\Administrator) -DomainName corp.adatum.com
Set-ADForestMode
Enable-ADOptionalFeature
New/Remove/Set-ADFineGrainedPasswordPolicy
Get-ADUserResultantPasswordPolicy
Get/New/Remove/Set-ADUser
-AccountPassword (Read-Host -AsSecureString "AccountPassword")

New-ADUser -DisplayName:"Karen Berg" -GivenName:"Karen" -Name:"Karen Berg"


-Path:"OU=Seattle Users OU,OU=Seattle OU,DC=corp,DC=contoso,DC=com"
-SamAccountName:"kberg" -Server:"SEA-SRV-1.corp.contoso.com"
-Surname:"Berg" -Type:"user" -UserPrincipalName:kberg@corp.contoso.com
Set-ADAccountPassword -Identity:"CN=Karen Berg,OU=Seattle Users OU,
OU=Seattle OU,DC=corp,DC=contoso,DC=com" -NewPassword:"System.Security.SecureString"
-Reset:$null -Server:"SEA-SRV-1.corp.contoso.com"
Enable-ADAccount -Identity:"CN=Karen Berg,OU=Seattle Users OU,
OU=Seattle OU,DC=corp,DC=contoso,DC=com" -Server:"SEA-SRV-1.corp.contoso.com"
Set-ADObject -Identity:"CN=Karen Berg,OU=Seattle Users OU,
OU=Seattle OU,DC=corp,DC=contoso,DC=com" -ProtectedFromAccidentalDeletion:$true
-Server:"SEA-SRV-1.corp.contoso.com"
Set-ADAccountExpiration -DateTime:"09/02/2012 00:00:00" -Identity:"CN=Karen Berg,
OU=Seattle Users OU,OU=Seattle OU,DC=corp,DC=contoso,DC=com"
-Server:"SEA-SRV-1.corp.contoso.com"
Set-ADAccountControl -AccountNotDelegated:$false -AllowReversiblePasswordEncryption:$true
-CannotChangePassword:$true -DoesNotRequirePreAuth:$false
-Identity:"CN=Karen Berg,OU=Seattle Users OU,OU=Seattle OU,DC=corp,DC=contoso,
DC=com" -PasswordNeverExpires:$true -Server:"SEA-SRV-1.corp.contoso.com"
-UseDESKeyOnly:$false
Set-ADUser -ChangePasswordAtLogon:$false -Identity:"CN=Karen Berg,
OU=Seattle Users OU,OU=Seattle OU,DC=corp,DC=contoso,DC=com"
-Server:"SEA-SRV-1.corp.contoso.com" -SmartcardLogonRequired:$false
-PassThru | Enable-ADAccount
The PassThru parameter, which has been added to the New-ADUser command just
shown, returns the newly created user account object so that it can be piped into the
EnableADAccount cmdlet to enable the new account.
Import-Csv C:\data\new-users.csv | New-ADUser -PassThru | Set-ADAccountPassword -Reset `
-NewPassword (ConvertTo-SecureString -AsPlainText "Pa$$w0rd" -Force)
Get-ADReplicationSite -Filter * | ft Name
Get-ADDomainController -Filter * | ft Hostname
New-ADReplicationSite Branch-Office-One
Set-ADReplicationSiteLink Hub-to-Branch-Office-One -Cost 100 -ReplicationFrequencyInMinutes 15
Get-Command *net* | Sort-Object ModuleName | Format-Table ModuleName `
-HideTableHeaders | Out-String | Out-File c:\data\test.txt
Get-Content C:\data\test.txt | Get-Unique
Show-Command New-NetIPAddress
Get-NetIPAddress -InterfaceAlias Ethernet
New-NetIPAddress -InterfaceAlias Ethernet -IPAddress 172.16.11.237 `
-AddressFamily IPv4 -PrefixLength 24
Get-NetAdapter | Where-Object -FilterScript {$_.LinkSpeed -eq "100 Mbps"}
Get-NetAdapterBinding -InterfaceAlias "Ethernet 2"
Get-DhcpServerv4Scope
Add-DhcpServerv4Scope -EndRange 172.16.12.100 -Name test2 `
-StartRange 172.16.12.50 -SubnetMask 255.255.255.0 -State InActive
Add-DhcpServerv4ExclusionRange -EndRange 172.16.12.75 -ScopeId 172.16.12.0 `
-StartRange 172.16.12.70
Add-DhcpServerv4Reservation -ClientId EE-05-B0-DA-04-00 `
-IPAddress 172.16.12.88 -ScopeId 172.16.12.0 -Description "File server"
Set-DhcpServerv4OptionValue -Router 172.16.12.1 -ScopeId 172.16.12.0
Get-DnsServerZone
Get-DnsServerResourceRecord -ZoneName corp.contoso.com |`
Where-Object {$_.RecordType -eq "A"}
Add-DnsServerResourceRecordA -IPv4Address 172.16.11.239 -Name SEA-TEST `
-ZoneName corp.contoso.com
Configure forwarders
Add-DnsServerForwarder
Create a stub zone
Add-DnsServerStubZone
Display the contents of the DNS server cache Show-DnsServerCache
Clear the DNS server cache
Clear-DnsServerCache
Display full configuration details of the DNS server
Get-DnsServer
Display statistics for the DNS server
Get-DnsServerStatistics

Import root hints


Import-DnsServerRootHint
Configure the DNS server cache settings
Set-DnsServerCache
Configure DNS server scavenging
Set-DnsServerScavenging
Initiate scavenging
Start-DnsServerScavenging
Get-NetAdapter | fl Name,ifIndex
New-NetIPAddress -InterfaceAlias "Ethernet" -IPAddress 2001:DB8:3FA9::D3:9C5A `
-PrefixLength 64 -DefaultGateway 2001:DB8:3FA9::0C01
Get-NetIPAddress | where {$_.InterfaceAlias -eq "Ethernet"}
Get-NetIPAddress -AddressFamily IPv6 | where {$_.InterfaceAlias -eq "Ethernet"}
Get-NetIPInterface -AddressFamily IPv6
Add-DhcpServerInDC -DnsName SERVER1
Add-DhcpServerv4Failover -Name "SERVER1 to SERVER2" -ScopeId 10.10.0.0 `
-PartnerServer SERVER2 -ComputerName SERVER1 -LoadBalancePercent 50 `
-AutoStateTransition $true
Add-DnsServerForwarder -IPAddress 10.10.0.1 -ComputerName SERVER2
Get-DnsServerForwarder -ComputerName SERVER2
Get-VMHost -ComputerName HOST4 | Format-List *
Get-VMSwitch | Format-List *
Set-VMHost -ComputerName HOST4 -VirtualHardDiskPath "E:\VM Storage"
New-VMSwitch -Name "CONTOSO Virtual Switch" `
-NetAdapterName "Broadcom NetXtreme Gigabit Ethernet #2" -ComputerName HOST4
New-VM -ComputerName HOST4 -Name SRV-A -MemoryStartupBytes 1GB `
-BootDevice CD -SwitchName "CONTOSO Virtual Switch" -NewVHDSizeBytes 500GB -NewVHDPath SRV-A.vhdx
New-VHD -SizeBytes 500GB -Path "C:\Users\Public\Documents\Hyper-V\Virtual Hard Disks\SRV-A-data.vhdx"
Add-VMHardDiskDrive -VMName SRV-A `
-Path "C:\Users\Public\Documents\Hyper-V\Virtual Hard Disks\SRV-A-data.vhdx" `
-ControllerType IDE -ControllerNumber 0 -ControllerLocation 1
Get-VMHardDiskDrive -VMName SRV-A | Format-List ControllerNumber,ControllerLocation,Path
Add-VMNetworkAdapter -VMName SRV-B -VMNetworkAdapterName "Network Adapter 2" `
-SwitchName "MANAGEMENT Virtual Switch"
Set-VM -Name SRV-A -NewVMName "SQL Workload" -ComputerName HOST4
Stop-VM -Name SRV-B -ComputerName HOST4
Get-VMSnapshot -VMName SRV-B -ComputerName HOST4
Enable-VMResourceMetering -VMName SRV-B
Measure-VM -Name SRV-B
Get-StoragePool
Get-PhysicalDisk
Get-StorageSubSystem
New-VirtualDisk -StoragePoolFriendlyName "Archive Pool" `
-FriendlyName "Archive Disk" -ResiliencySettingName Mirror -ProvisioningType Thin -Size 2TB
Initialize-Disk -Number 4
Get-Disk -Number 4
Get-Volume
New-Partition -DiskNumber 4 -UseMaximumSize AssignDriveLetter
Format-Volume -DriveLetter E -FileSystem NTFS
New-Item -Path "E:\Shares\Archived Content" -ItemType Directory
New-SmbShare -Name "Archive Share" -Path "E:\Shares\Archived Content" -ChangeAccess CONTOSO\Sales
Set-SmbShare -Name "Archive Share" -FolderEnumerationMode AccessBased `
-Confirm:$false
For example, if a target named fabrikam-db is created on a target server named HOST7, the IQN for this target
would be
iqn.1991-05.com.microsoft:host7-fabrikam-db-target
Get-IscsiVirtualDisk
New-IscsiVirtualDisk -Path X:\iSCSIVirtualDisks\data.vhd -Size 50GB
New-IscsiServerTarget -TargetName fabrikam-data
-InitiatorIds "IQN:iqn.1991-05.com.microsoft:host4.corp.fabrikam.com"
Add-IscsiVirtualDiskTargetMapping -TargetName fabrikam-data -Path X:\iSCSIVirtualDisks\data.vhd
Get-IscsiConnection -ConnectionIdentifier "fffffa80144a8020-1" | Get-IscsiSession
Connect-IscsiTarget NodeAddress "iqn.1991-05.com.microsoft:host7-fabrikam-db-target"
Register-IscsiSession -SessionIdentifier "fffffa80144a8020-4000013700000003"
Get-Printer -ComputerName HOST7 | Format-List Name,DriverName
Get-PrintJob -ComputerName HOST7 -PrinterName "HP LaserJet 5200 PCL6"

Get-PrintConfiguration -ComputerName HOST7 -PrinterName "HP LaserJet 5200 PCL6"


Get-PrinterProperty -ComputerName HOST7 -PrinterName "Samsung CLP-410 Series PCL6"
Get-PrinterDriver -ComputerName HOST7 -Name "Samsung*"
Remove-PrintJob -PrinterName "HP LaserJet 5200 PCL6" -ID 3
Add-PrinterDriver -ComputerName HOST7 -Name "Dell Color Laser PCL6 Class Driver"
Add-PrinterPort -ComputerName HOST7 -Name "172.16.11.63" -PrinterHostAddress "172.16.11.63"
Set-PrintConfiguration -ComputerName HOST7 -PrinterName "Sales Printer" -PaperSize Legal
Get-GPStarterGPO -Name "Computers-Desktop"
New-GPO -Name "BO-1-Desktops" -StarterGpoName "Computers-Desktop"
New-GPLink -Name "BO-1-Desktops" -Target "ou=BO-1-SEA,dc=corp,dc=fabrikam,dc=com"
Get-ADComputer -Filter * -SearchBase "ou=Desktops,ou=Computers,ou=HQ-NYC,dc=corp,dc=fabrikam,dc=com" | `
foreach{Invoke-GPUpdate -Computer $_.Name -force -RandomDelayInMinutes 0}
Get-ChildItem "C:\GPOBackups" Recurse
Get-NetFirewallProfile -Name Domain -PolicyStore ActiveStore
Get-NetFirewallRule -PolicyStore ActiveStore -DisplayGroup Network Discovery -Direction Inbound | `
ft Name,DisplayName,Enabled,Action -AutoSize
New-NetFirewallRule -DisplayName Block Outbound Port 80
-Direction Outbound -LocalPort 80 -Protocol TCP -Action Block
Get-NetFirewallProfile -Name Domain -PolicyStore corp.fabrikam.com\Sales | fl NotifyOnListen
Get-NetIPsecMainModeCryptoSet -PolicyStore ActiveStore
Get-NetIPsecPhase1AuthSet -PolicyStore ActiveStore
New-NetIPsecRule -DisplayName Server Isolation Rule -InboundSecurity Require -OutboundSecurity Require
Get-NetIPsecMainModeSA
Get-NetIPsecQuickModeSA

S-ar putea să vă placă și