Powes Hell

download Powes Hell

of 4

Transcript of Powes Hell

  • 7/26/2019 Powes Hell

    1/4

    Get-Command -Module ADDSDeploymentGet-Help Install-WindowsFeatureexamples /Detailed /-full / -OnlineUpdate-HelpGet-WindowsFeature -Name Print* -ComputerName SEA-SRV-1 | Where-Object InstallState -eq InstalledInstall-WindowsFeature MigrationComputerName SERVER7Import-Module ServerManagerAdd-WindowsFeature Migration

    Get-SmigServerFeatureUninstall-WindowsFeature Server-Gui-Mgmt-InfraRestartInstall-WindowsFeature Server-Gui-Mgmt-Infra,Server-Gui-Shell -Restart -SourceC:\mountdir\windows\winsxsInstall-WindowsFeature Server-Gui-Mgmt-Infra-Restart -Source C:\mountdir\windows\winsxs

    dism /get-wiminfo /wimfile:D:\sources\install.wimdism /mount-wim /wimfile:D:\sources\install.wim /Index: /mountdir:C:\mountdir /readonlyInstall-WindowsFeature Server-Gui-Mgmt-Infra,Server-Gui-Shell -Restart -vhd C:\Users\Public\Documents\Hyper-V\Virtual Hard Disks\SERVER6.vhdx -Source C:\mountdir\windows\winsxsConfigure-SMRemotingget / -Disable / -EnableInstall-WindowsFeature -Name RSAT -IncludeAllSubFeature -ComputerName SEA-SRV-1Invoke-Command -ComputerName SEA-SRV-1,SEA-SRV-3 -ScriptBlock {Install-WindowsFeature -Name XPS-Viewer}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:40PMRegister-ScheduledJob -Name InstallXPS -ScriptBlock {Install-WindowsFeature -Name XPS-Viewer -ComputerNameSEA-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-1Invoke-Command $SEASRV1 $scriptDisconnect-PSSession -Name $SEASRV1Connect-PSSession -Name $SEASRV1Import-Module ADDSDeploymentInstall-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:$truedsquery * cn=schema,cn=configuration,dc=fabrikam,dc=com -scope base-attr objectVersionSet-Item wsman:\localhost\Client\TrustedHosts -Value SEA-SRV-1Get-Item wsman:\\localhost\Client\TrustedHostsTest-ADDSForestInstallation -DomainName corp.adatum.comSet-Execution Policy UnrestrictedInvoke-Command -ComputerName SEA-SRV-1 -FilePath C:\scripts\script1.ps1Install-ADDSDomainController -InstallDns -Credential(Get-Credential CORP\Administrator) -DomainName corp.adatum.comSet-ADForestModeEnable-ADOptionalFeatureNew/Remove/Set-ADFineGrainedPasswordPolicyGet-ADUserResultantPasswordPolicyGet/New/Remove/Set-ADUser-AccountPassword (Read-Host -AsSecureString "AccountPassword")

  • 7/26/2019 Powes Hell

    2/4

    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:[email protected] -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:$falseSet-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

    ThePassThru parameter, which has been added to the New-ADUser command justshown, returns the newly created user account object so that it can be piped into theEnable-ADAccount 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 NameGet-ADDomainController -Filter * | ft HostnameNew-ADReplicationSite Branch-Office-OneSet-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.txtGet-Content C:\data\test.txt | Get-Unique

    Show-Command New-NetIPAddressGet-NetIPAddress -InterfaceAlias EthernetNew-NetIPAddress -InterfaceAlias Ethernet -IPAddress 172.16.11.237 `-AddressFamily IPv4 -PrefixLength 24Get-NetAdapter | Where-Object -FilterScript {$_.LinkSpeed -eq "100 Mbps"}Get-NetAdapterBinding -InterfaceAlias "Ethernet 2"Get-DhcpServerv4ScopeAdd-DhcpServerv4Scope -EndRange 172.16.12.100 -Name test2 `-StartRange 172.16.12.50 -SubnetMask 255.255.255.0 -State InActiveAdd-DhcpServerv4ExclusionRange -EndRange 172.16.12.75 -ScopeId 172.16.12.0 `-StartRange 172.16.12.70Add-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.0Get-DnsServerZoneGet-DnsServerResourceRecord -ZoneName corp.contoso.com |`Where-Object {$_.RecordType -eq "A"}Add-DnsServerResourceRecordA -IPv4Address 172.16.11.239 -Name SEA-TEST `-ZoneName corp.contoso.comConfigure forwarders Add-DnsServerForwarderCreate a stub zone Add-DnsServerStubZoneDisplay the contents of the DNS server cache Show-DnsServerCacheClear the DNS server cache Clear-DnsServerCacheDisplay full configuration details of the DNS server Get-DnsServerDisplay statistics for the DNS server Get-DnsServerStatistics

  • 7/26/2019 Powes Hell

    3/4

    Import root hints Import-DnsServerRootHintConfigure the DNS server cache settings Set-DnsServerCacheConfigure DNS server scavenging Set-DnsServerScavengingInitiate scavenging Start-DnsServerScavengingGet-NetAdapter | fl Name,ifIndexNew-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 IPv6Add-DhcpServerInDC -DnsName SERVER1Add-DhcpServerv4Failover -Name "SERVER1 to SERVER2" -ScopeId 10.10.0.0 `-PartnerServer SERVER2 -ComputerName SERVER1 -LoadBalancePercent 50 `-AutoStateTransition $trueAdd-DnsServerForwarder -IPAddress 10.10.0.1 -ComputerName SERVER2Get-DnsServerForwarder -ComputerName SERVER2Get-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 HOST4New-VM -ComputerName HOST4 -Name SRV-A -MemoryStartupBytes 1GB `

    -BootDevice CD -SwitchName "CONTOSO Virtual Switch" -NewVHDSizeBytes 500GB -NewVHDPath SRV-A.vhdxNew-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 1Get-VMHardDiskDrive -VMName SRV-A | Format-List ControllerNumber,ControllerLocation,PathAdd-VMNetworkAdapter -VMName SRV-B -VMNetworkAdapterName "Network Adapter 2" `-SwitchName "MANAGEMENT Virtual Switch"Set-VM -Name SRV-A -NewVMName "SQL Workload" -ComputerName HOST4Stop-VM -Name SRV-B -ComputerName HOST4Get-VMSnapshot -VMName SRV-B -ComputerName HOST4Enable-VMResourceMetering -VMName SRV-BMeasure-VM -Name SRV-BGet-StoragePoolGet-PhysicalDisk

    Get-StorageSubSystemNew-VirtualDisk -StoragePoolFriendlyName "Archive Pool" `-FriendlyName "Archive Disk" -ResiliencySettingName Mirror -ProvisioningType Thin -Size 2TBInitialize-Disk -Number 4Get-Disk -Number 4Get-VolumeNew-Partition -DiskNumber 4 -UseMaximumSizeAssignDriveLetterFormat-Volume -DriveLetter E -FileSystem NTFSNew-Item -Path "E:\Shares\Archived Content" -ItemType DirectoryNew-SmbShare -Name "Archive Share" -Path "E:\Shares\Archived Content" -ChangeAccess CONTOSO\SalesSet-SmbShare -Name "Archive Share" -FolderEnumerationMode AccessBased `-Confirm:$falseFor example, if a target named fabrikam-db is created on a target server named HOST7, the IQN for this targetwould beiqn.1991-05.com.microsoft:host7-fabrikam-db-targetGet-IscsiVirtualDiskNew-IscsiVirtualDisk -Path X:\iSCSIVirtualDisks\data.vhd -Size 50GBNew-IscsiServerTarget -TargetName fabrikam-data-InitiatorIds "IQN:iqn.1991-05.com.microsoft:host4.corp.fabrikam.com"Add-IscsiVirtualDiskTargetMapping -TargetName fabrikam-data -Path X:\iSCSIVirtualDisks\data.vhdGet-IscsiConnection -ConnectionIdentifier "fffffa80144a8020-1" | Get-IscsiSessionConnect-IscsiTargetNodeAddress "iqn.1991-05.com.microsoft:host7-fabrikam-db-target"Register-IscsiSession -SessionIdentifier "fffffa80144a8020-4000013700000003"Get-Printer -ComputerName HOST7 | Format-List Name,DriverNameGet-PrintJob -ComputerName HOST7 -PrinterName "HP LaserJet 5200 PCL6"

  • 7/26/2019 Powes Hell

    4/4

    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 3Add-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"RecurseGet-NetFirewallProfile -Name Domain -PolicyStore ActiveStoreGet-NetFirewallRule -PolicyStore ActiveStore -DisplayGroup Network Discovery -Direction Inbound | `ft Name,DisplayName,Enabled,Action -AutoSizeNew-NetFirewallRule -DisplayName Block Outbound Port 80-Direction Outbound -LocalPort 80 -Protocol TCP -Action BlockGet-NetFirewallProfile -Name Domain -PolicyStore corp.fabrikam.com\Sales | fl NotifyOnListenGet-NetIPsecMainModeCryptoSet -PolicyStore ActiveStoreGet-NetIPsecPhase1AuthSet -PolicyStore ActiveStoreNew-NetIPsecRule -DisplayName Server Isolation Rule -InboundSecurity Require -OutboundSecurity Require

    Get-NetIPsecMainModeSAGet-NetIPsecQuickModeSA