windows memo

# Docker toolbox
1. Docker Quikstart Terminal
2. `docker is configured to use the default machine with IP 192.168.99.100`
3. docker run -itd -p 8080:80 nginx
4. access http://192.168.99.100:8080 via your browser
## Proxy
machine: edit start.sh?
docker-server: //


# GnuTLS error -48: Key usage violation in certificate has been detected. (via filezilla client)
Replace old type SSL Cert.
https://forums.iis.net/t/1234970.aspx

```powershell
New-SelfSignedCertificate -CertStoreLocation cert:\LocalMachine\My -dnsname [your hostname]

Thumbprint                                Subject
----------                                -------
[get your Thumbprint after user it]       CN=[your hostname]

$password = ConvertTo-SecureString -String "your password, re-type it after" -Force -AsPlainText

Export-PfxCertificate -cert cert:\LocalMachine\My\[Thumbprint] -FilePath C:\cert.pfx -Password $password
```

W-Click `C:\cert.pfx` and import, ref this cert via IIS-manager.

# The server denied the logon with reason: 3489661694
https://social.technet.microsoft.com/Forums/ie/en-US/772a359d-f02a-4b41-9377-e3dbafb8cc6e/the-server-denied-the-logon-with-reason-3489661694?forum=winRDc

# IIS AppPool status
`Get-WebAppPoolState | fl *`

via IIS drive

```
Import-Module WebAdministration
ls IIS:AppPools
```

# How to find Windows uptime?
https://support.microsoft.com/en-us/help/555737/how-to-find-windows-uptime

```
net statistics server
# or
net stats srv
```
# reboot/shutdown
```
reboot： shutdown /r /t 0
shutdown： shutdown /s /t 0
chancel: shutdown /a
```

# How to create a trigger-start Windows service
sample:
https://code.msdn.microsoft.com/windowsapps/CSWin7TriggerStartService-acbedddb


# Run any scripts on machine shutdown
group policy 
https://zacheryolinske.wordpress.com/2015/03/01/how-to-shutdown-domain-users-client-computers-with-group-policy/

or task scheduler?


# WindowsUpdate
## windows update / microsoft up
## Powershell module
https://gallery.technet.microsoft.com/scriptcenter/2d191bcd-3308-4edd-9de2-88dff796b0bc/
https://www.petri.com/manage-windows-updates-with-powershell-module
### install
Unzip to 
`%USERPROFILE%\Documents\WindowsPowerShell\Modules`
Or
`%WINDIR%\System32\WindowsPowerShell\v1.0\Modules`

```powershell:
Import-Module PSWindowsUpdate
# list
Get-Command –module PSWindowsUpdate 
```

or 
https://www.powershellgallery.com/packages/PSWindowsUpdate/1.5.2.2

`Install-Module -Name PSWindowsUpdate -RequiredVersion 1.5.2.2`

### Command-let

### Update Category?
- `Critical Updates`
- `Security Updates`
- `Update Rollups`
- `Updates` < GUI treat it as `Option`

### typical update
```powershell:
Get-WUInstall -ListOnly -Category 'Security Updates','Critical Updates'
```

### silent update

```
Import-Module PSWindowsUpdate
Get-WUInstall -AcceptAll -IgnoreReboot -Category 'Security Updates','Critical Updates'
```

- IgnoreReboot
Do not ask for reboot if it needed, but do not reboot automaticaly
- AuroReboot
Do not ask for reboot if it needed.


# Non admin user's enviroment_vars
`control panel > user account > user account > edit env...` 

# ETW?
Event Tracing for Windows
http://tech.blog.aerie.jp/entry/2014/09/09/165448
## ETW == EventLog?
No. 

# Disable shutdown event tracker.
https://blogs.technet.microsoft.com/chenley/2011/03/05/how-to-disable-the-shutdown-tracker-in-windows-server-2008-r2/

# Enable task scheduler's history
http://www.powershellmagazine.com/2013/07/15/pstip-how-to-enable-event-logs-using-windows-powershell/
Why default was false ???

```powerhsell:
$logName = 'Microsoft-Windows-TaskScheduler/Operational'
$log = New-Object System.Diagnostics.Eventing.Reader.EventLogConfiguration $logName
$log.IsEnabled=$true
$log.SaveChanges()
```


# schtask
`schtasks` manage windows task-scheduler.

```
schtasks /create /tn <task-name> /tr "<execute command>" /sc daily /st 01:00 /rl highest /np /RU SYSTEM /F
```

# AWS cloudwatch logs
1. edit `cat "c:\program files\Amazon\Ec2ConfigService\Settings\Config.xml`
2. restert service `sc` or `start-service`