# 1번
Get-VpnS2SInterface | Fl Destination,ConnectionState,ResponderAuthenticationMethod
tnc 30.0.0.2 | fl PingSucceeded

Get-VpnS2SInterface | Fl Destination,ConnectionState,ResponderAuthenticationMethod
tnc 20.0.0.2 | fl PingSucceeded

"10.10.0.10", "10.10.0.11", "10.20.0.10", "10.20.0.11", "10.40.0.10" | % { tnc $_ | select RemoteAddress, PingSucceeded }

"10.10.0.10", "10.10.0.11", "10.20.0.10", "10.20.0.11", "10.40.0.10" | % { tnc $_ | select RemoteAddress, PingSucceeded }

# 2번
Get-DnsServerZone | where ZoneType -eq "Secondary" | ft ZoneName, MasterServers
Get-DnsServerResourceRecord -zonename "0.30.10.in-addr.arpa" -RRtype "PTR" | select @{Name='RecordData';Expression={$_.RecordData.PtrDomainName}}

"DC1.PARIS.LOCAL", "NW-SRV.PARIS.LOCAL", "FILE-SRV.PARIS.LOCAL", "WEB-SRV.PARIS.LOCAL", "APP.PARIS.LOCAL", "WWW.PARIS.LOCAL", "EXTERNAL.PARIS.LOCAL", "WIN-CLIENT1.PARIS.LOCAL", "DC2.LYON.PARIS.LOCAL" | Resolve-DnsName -Type A -DnsOnly -QuickTimeout | select Name, IPAddress

"10.10.0.10", "10.10.0.11", "10.20.0.10", "10.20.0.11" | Resolve-DnsName -Type PTR -DnsOnly -QuickTimeout | select Name, NameHost

# 3번
"ADFS.PARIS.LOCAL", "COUNTRY.PARIS.LOCAL", "FTP.PARIS.LOCAL" | Resolve-DnsName -Type A -DnsOnly -QuickTimeout | select Name, IPAddress

# 4번
"DC1.PARIS.LOCAL", "DC2.LYON.PARIS.LOCAL", "WIN-CLIENT2.LYON.PARIS.LOCAL" | Resolve-DnsName -Type A -DnsOnly -QuickTimeout | select Name, IPAddress

# 5번
Get-DhcpServerSetting | fl Is*
Get-DhcpServerv4Scope | fl Name, State, *Range, *Duration
Get-DhcpServerv4Scope | Get-DhcpServerv4ExclusionRange | fl *Range
Get-DhcpServerv4Scope | Get-DhcpServerv4OptionValue | ft Name, Value

ipconfig /release; ipconfig /renew
ipconfig /all | Select-String "DHCP 서버"

# 6번
Get-DhcpServerSetting | fl Is*
Get-DhcpServerv4Scope | fl Name, State, *Range, *Duration
Get-DhcpServerv4Scope | Get-DhcpServerv4ExclusionRange | fl *Range
Get-DhcpServerv4Scope | Get-DhcpServerv4OptionValue | ft Name, Value

ipconfig /release; ipconfig /renew
ipconfig /all | Select-String "DHCP 서버"

# 7번
Get-ADDomain | fl ChildDomains
Get-ADDomainController | fl Forest, Domain, Enabled, HostName

# 8번
Get-ADDomain | fl ParentDomain
Get-ADDomainController | fl Forest, Domain, Enabled, HostName

# 9번
"HR", "MKT", "SALES", "TECH" | % { Get-ADOrganizationalUnit -Filter * | where Name -eq "$_" | select Name }
"HR", "MKT", "SALES", "TECH" | % { Get-ADGroup -Filter * -SearchBase "OU=$_,DC=paris,DC=local" | select DistinguishedName }
(Get-ADComputer -Filter *).Count
"HR", "MKT", "SALES", "TECH" | % { [pscustomobject]@{OU=$_; Count = (Get-ADUser -Filter "SamAccountName -like '$_*'"  -SearchBase "OU=$_,DC=paris,DC=local").Count} }
C:\create_user.ps1 -count 100
"HR", "MKT", "SALES", "TECH" | % { [pscustomobject]@{OU=$_; Count = (Get-ADUser -Filter "SamAccountName -like '$_*'"  -SearchBase "OU=$_,DC=paris,DC=local").Count} }
"HR","MKT","SALES","TECH" | % { Get-ADGroup -Filter * -SearchBase "OU=$_,DC=paris,DC=local" | % { [pscustomobject]@{ Group=$_.Name; MemberCount=(Get-ADGroupMember $_).Count } } }

# 10번
Get-ADOrganizationalUnit -Filter * | where Name -eq REMOTE | fl Name
Get-ADGroup -Filter * -SearchBase "OU=REMOTE,DC=lyon,DC=paris,DC=local" | fl DistinguishedName
(Get-ADComputer -Filter *).Count
(Get-ADUser -Filter "SamAccountName -like 'remote*'" -SearchBase "OU=REMOTE,DC=lyon,DC=paris,DC=local").Count
(Get-ADGroup -Filter * -SearchBase "OU=REMOTE,DC=lyon,DC=paris,DC=local" | Get-ADGroupMember).Count

# 11번
Set-ADAccountPassword 'hr20' -OldPassword (ConvertTo-SecureString -AsPlainText -Force -String Skill39**) -NewPassword (ConvertTo-SecureString -AsPlainText -Force -String Skill39!@#)
Set-ADAccountPassword 'hr20' -OldPassword (ConvertTo-SecureString -AsPlainText -Force -String Skill39**) -NewPassword (ConvertTo-SecureString -AsPlainText -Force -String Skill39!@#worldskills)

# 12번
$Env:Skill39
Get-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Control\Lsa | fl NoLMHash
Get-ItemProperty HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU | fl Schedule*
Get-LocalUser -Name "Administrator" | fl Name, Enabled
control /name Microsoft.FileHistory

# 13번
GUI 작업

# 14번
GUI 작업

# 15번
$env:HOMEDRIVE
$env:HOMESHARE
T:
fsutil file createnew T:\smalllfile.txt 1048575
fsutil file createnew T:\largefile.txt 52428800
Copy-Item "C:\Windows\system32\calc.exe" -Destination T:\

# 16번
Get-SmbShare | where Path -like "C:\GroupShare*" | ft Name, Path
"CommonShare", "HR", "MKT", "SALES", "TECH" | % { icacls C:\GroupShare\$_ | select-string $_; "" }

Get-SmbShare | where Path -like "C:\GroupShare*" | ft Name, Path
"CommonShare", "HR", "MKT", "SALES", "TECH" | % { icacls C:\GroupShare\$_ | select-string $_; "" }

# 17번
Get-DfsnRoot -Path \\paris.local\CSDrive | fl Path, State
Get-DfsnFolder -Path \\paris.local\CSDrive\* | Get-DfsnFolderTarget | ft Path, TargetPath, State
Get-DfsrConnection | ft SourceComputerName, Enabled, State
Get-DfsReplicatedFolder | ft FolderName

# 18번
Get-PSDrive X | fl DisplayRoot
New-Item -Path "X:\test.txt" -ItemType File -Force | fl Exists

Get-PSDrive X, Z | ft Name, DisplayRoot
New-Item -Path "X:\test.txt" -ItemType File -Force | fl Exists
New-Item -Path "Z:\test.txt" -ItemType File -Force | fl Exists

Get-PSDrive X, Z | ft Name, DisplayRoot
New-Item -Path "X:\test.txt" -ItemType File -Force | fl Exists
New-Item -Path "Z:\test.txt" -ItemType File -Force | fl Exists

Get-PSDrive X, Z | ft Name, DisplayRoot
New-Item -Path "X:\test.txt" -ItemType File -Force | fl Exists
New-Item -Path "Z:\test.txt" -ItemType File -Force | fl Exists

Get-PSDrive X, Z | ft Name, DisplayRoot
New-Item -Path "X:\test.txt" -ItemType File -Force | fl Exists
New-Item -Path "Z:\test.txt" -ItemType File -Force | fl Exists

# 19번
Resolve-DnsName external.paris.com -Type A -DnsOnly -QuickTimeout | fl Name, IPAddress

iisreset /stop

iisreset

curl https://external.paris.com -TimeoutSec 10 | fl StatusCode

iisreset

curl https://external.paris.com -TimeoutSec 10 | fl StatusCode

# 20번
GUI 작업

# 21번
GUI 작업

# 22번
* 작업 전 심사위원 지시하에 신중하게 진행하세요.

sed -i 's/40/111/g;s/78/222/g;s/87/333/g' /opt/ansible/inventory/group_vars/paris/shares.yaml
sed -i 's/55/123/g;s/63/321/g' /opt/ansible/inventory/group_vars/lyon/shares.yaml

cd /opt/ansible
ansible-playbook manage-shares.yaml

Get-ADGroup -Filter * | where { $_.Name -like '*111*' -or $_.Name -like '*222*' -or $_.Name -like '*333*' } | select Name

Get-ADGroup -Filter * | where { $_.Name -like '*123*' -or $_.Name -like '*321*' } | select Name

# 23번
Get-ChildItem C:\ProjectShare | where { $_.Name -like '*111*' -or $_.Name -like '*222*' -or $_.Name -like '*333*' } | select Name
Get-ChildItem C:\ProjectShare | where { $_.Name -like '*111*' -or $_.Name -like '*222*' -or $_.Name -like '*333*' } | % { icacls $_.FullName } | Select-String Paris

Get-ChildItem C:\ProjectShare | where { $_.Name -like '*123*' -or $_.Name -like '*321*' } | select Name
Get-ChildItem C:\ProjectShare | where { $_.Name -like '*123*' -or $_.Name -like '*321*' } | % { icacls $_.FullName } | Select-String Lyon

# 24번
Get-ChildItem "C:\inetpub\country" -Directory | Measure-Object | Select-Object -ExpandProperty Count
Get-Website -Name "country"

cd /opt/ansible/
ansible-playbook countries.yaml

Get-ChildItem "C:\inetpub\country" -Directory | Measure-Object | Select-Object -ExpandProperty Count
Get-Website -Name "country"

# 25번
Get-ADFSProperties | ft HostName
Get-AdfsRelyingPartyTrust -Name country | Select-Object WSFedEndpoint

# 26번
GUI 작업

# 27번
GUI 작업

# 28번
"Department : $((Get-ADUser hr1 -Properties Department).Department)"

# 29번
$val=(Import-Csv C:\countries.csv | Get-Random); Set-ADUser hr1 -Department $val.Code; "Department : $($val.Code) ($($val.Name))"

# 30번
GUI 작업

# 31번
GUI 작업

# 32번
Skill39**

# 33번
echo "Mount K Drive in Client" > C:\Users\administrator\Desktop\mountfile.txt

# 34번
K Drive

# 35번
IPCONFIG-DENY

ipconfig

# 36번
IPCONFIG-ALLOW

ipconfig

# 37번
$busy=0.94;$c=[Environment]::ProcessorCount; 1..$c|%{Start-Job{param($b)$sw=[Diagnostics.Stopwatch]::StartNew(); $t=[int64]([Diagnostics.Stopwatch]::Frequency*0.1); while(1){$t0=$sw.ElapsedTicks; while(($sw.ElapsedTicks-$t0)-lt($t*$b)){[void][math]::Sqrt(12345)}; Start-Sleep -Milliseconds 10}} -ArgumentList $busy | Out-Null }

Get-Job | Stop-Job; Get-Job | Remove-Job