InstallPeterDDns.ps1
<#PSScriptInfo .VERSION 1.1 .GUID 2ca708fa-736f-4ed1-bf46-1400aac58e37 .AUTHOR Peter .COMPANYNAME .COPYRIGHT .TAGS .LICENSEURI .PROJECTURI .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS .EXTERNALSCRIPTDEPENDENCIES .RELEASENOTES .PRIVATEDATA #> <# .DESCRIPTION Installer for peter's ddns implemention client #> $ak = Read-Host -Prompt 'Input aliyun access key' $sk = Read-Host -Prompt 'Input aliyun secret key' $domain = Read-Host -Prompt 'Input your domain, like "peterzhang.top"' $rr = Read-Host -Prompt 'Input the resource record like the "www" in "www.peterzhang.top"' function test { Trap{ Continue } $job=Get-ScheduledJob -Name PeterDDnsUpload if($job -ne $null){ echo 'Removing existed DDNS upload task...' $job | Unregister-ScheduledJob } } test echo 'Installing DDNS upload task...' $jobopt = New-ScheduledJobOption -StartIfOnBattery Register-ScheduledJob -Name PeterDDnsUpload -ScriptBlock { C:/Windows/System32/ddns_aliyun.exe -a $ak -s $sk -d $domain -r $rr } -ScheduledJobOption $jobopt $job=Get-ScheduledJob -Name PeterDDnsUpload # ���ض������ļ� echo 'Downloading DDNS client...' Invoke-WebRequest -Uri http://ftp.peterzhang.top/ddns_aliyun.exe -OutFile C:\Windows\System32\ddns_aliyun.exe $jobt=New-JobTrigger -Once -At (Get-Date) -RepetitionInterval '00:10:00' -RepeatIndefinitely Add-JobTrigger -Trigger $jobt $job #$jobt2 = New-JobTrigger -Once -At (Get-Date).AddSeconds(2) #Add-JobTrigger -Trigger $jobt2 $job echo 'Running test...' C:/Windows/System32/ddns_aliyun.exe -a $ak -s $sk -d $domain -r $rr echo 'DDNS upload task installing accomplished !' |