sal code "C:\Program Files (x86)\Microsoft VS Code\Code.exe" sal sublime "c:\hhdcommand\Sublime Text 2.0.2\sublime_text.exe" sal open "C:\Windows\SysWOW64\explorer.exe" sal vs2013 "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.com" sal vs2015 "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.com" sal blend2013 "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\blend.exe" sal blend2015 "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\blend.exe" sal nuget "C:\ProgramData\Microsoft\Windows\PowerShell\PowerShellGet\NuGet.exe" sal java "C:\Program Files (x86)\Java\jdk1.7.0_55\bin\java.exe" sal javac "C:\Program Files (x86)\Java\jdk1.7.0_55\bin\javac.exe" sal apt "C:\Program Files (x86)\Java\jdk1.7.0_55\bin\apt.exe" sal jar "C:\Program Files (x86)\Java\jdk1.7.0_55\bin\jar.exe" sal javadoc "C:\Program Files (x86)\Java\jdk1.7.0_55\bin\javadoc.exe" sal pi "C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell_ise.exe" sal zip Compress-Archive sal unzip Expand-Archive sal amcap "C:\hhdcommand\AMCap\amcap.exe" sal StillCap "C:\hhdcommand\AMCap\StillCap.exe" sal dbgview "C:\hhdcommand\dbgview\dbgview.exe" sal depends "C:\hhdcommand\depends\depends.exe" sal DSFMgr "C:\hhdcommand\DSFMgr\DSFMgr.exe" sal Everything "C:\hhdcommand\Everything-1.3.4.686.x64.Multilingual\Everything.exe" sal filezilla "C:\hhdcommand\FileZilla-3.21.0\filezilla.exe" sal fzputtygen "C:\hhdcommand\FileZilla-3.21.0\fzputtygen.exe" sal fzsftp "C:\hhdcommand\FileZilla-3.21.0\fzsftp.exe" sal postimage "C:\hhdcommand\PostimagePortable\postimage.exe" sal ProcessExplorer "C:\hhdcommand\ProcessExplorer\procexp.exe" sal ffmpeg "C:\hhdcommand\UmmyVideoDownloader\1.7.2.2\ffmpeg.exe" sal UmmyVideoDownloader "C:\hhdcommand\UmmyVideoDownloader\UmmyVideoDownloader.exe" sal WiresharkPortable "C:\hhdcommand\WiresharkPortable\WiresharkPortable.exe" sal YouTubeToMp3 "C:\hhdcommand\YouTubeToMP3-portable\YouTubeToMp3.exe" sal ffmpeg "C:\hhdcommand\YouTubeToMP3-portable\ffmpeg.exe" sal gacutil-NET-Global-Assembly-Cache-Utility "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6 Tools\x64\gacutil.exe" sal ildasm "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6 Tools\x64\ildasm.exe" sal ildasm-chm "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6 Tools\x64\ildasm.exe" sal FUSLOGVW-Assembly-Binding-Log-Viewer "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6 Tools\x64\FUSLOGVW.exe" sal clrver-NET-CLR-Version-Tool "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6 Tools\x64\clrver.exe" sal lc-NET-Licenses-file-and-adds-it-to-the-manifest-of-the-given-assembly "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6 Tools\x64\lc.exe" sal PEVerify-NET-Framework-PE-Verifier "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6 Tools\x64\PEVerify.exe" sal sn-NET-Framework-Strong-Name-Utility "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6 Tools\x64\sn.exe" sal AccCheckConsole "C:\Program Files (x86)\Windows Kits\10\bin\x64\AccChecker\AccCheckConsole.exe" sal acccheckui "C:\Program Files (x86)\Windows Kits\10\bin\x64\AccChecker\acccheckui.exe" sal VisualUIAVerifyNative "C:\Program Files (x86)\Windows Kits\10\bin\x64\UIAVerify\VisualUIAVerifyNative.exe" sal cert2spc "C:\Program Files (x86)\Windows Kits\10\bin\x64\cert2spc.exe" sal certmgr "C:\Program Files (x86)\Windows Kits\10\bin\x64\certmgr.exe" sal computerhardwareids-Using-the-BIOS-to-gather-information "C:\Program Files (x86)\Windows Kits\10\bin\x64\computerhardwareids.exe" sal filetypeverifier "C:\Program Files (x86)\Windows Kits\10\bin\x64\filetypeverifier.exe" sal filtreg-Filters-loaded-by-extension "C:\Program Files (x86)\Windows Kits\10\bin\x64\filtreg.exe" sal graphedt "C:\Program Files (x86)\Windows Kits\10\bin\x64\graphedt.exe" sal inspect-UIAccess "C:\Program Files (x86)\Windows Kits\10\bin\x64\inspect.exe" sal makecert "C:\Program Files (x86)\Windows Kits\10\bin\x64\makecert.exe" sal mt-Microsoft-Manifest-Tool "C:\Program Files (x86)\Windows Kits\10\bin\x64\mt.exe" sal oleview-OLE-COM-object-viewer "C:\Program Files (x86)\Windows Kits\10\bin\x64\oleview.exe" sal pktextract-from-cert "C:\Program Files (x86)\Windows Kits\10\bin\x64\pktextract.exe" sal pvk2pfx "C:\Program Files (x86)\Windows Kits\10\bin\x64\pvk2pfx.exe" sal signtool "C:\Program Files (x86)\Windows Kits\10\bin\x64\signtool.exe" sal uuidgen "C:\Program Files (x86)\Windows Kits\10\bin\x64\uuidgen.exe" sal tracefmt-format-message "C:\Program Files (x86)\Windows Kits\10\bin\x64\tracefmt.exe" sal tracelog "C:\Program Files (x86)\Windows Kits\10\bin\x64\tracelog.exe" sal sqlpackage "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\130\sqlpackage.exe" sal 7z 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Xamarin\Xamarin\4.1.1.3\7-Zip\7z.exe' sal msvsmon-x64 "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Remote Debugger\x64\msvsmon.exe" sal msvsmon-x86 "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Remote Debugger\x86\msvsmon.exe" sal errlook 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\errlook.exe' sal guidgen 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\guidgen.exe' sal spyxx 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\spyxx.exe' sal dotfuscated-HelloWorld 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\PreEmptive Solutions\Dotfuscator and Analytics Community Edition\samples\HelloWorld\dotfuscated\HelloWorld.exe' sal HelloWorld 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\PreEmptive Solutions\Dotfuscator and Analytics Community Edition\samples\HelloWorld\HelloWorld.exe' sal dotfuscator-Community-Edition 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\PreEmptive Solutions\Dotfuscator and Analytics Community Edition\dotfuscator.exe' sal dotfuscatorCLI-Community-Edition 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\PreEmptive Solutions\Dotfuscator and Analytics Community Edition\dotfuscatorCLI.exe' sal dotfuscator "C:\Program Files (x86)\PreEmptive Solutions\Dotfuscator Professional Edition Evaluation 4.21.0\dotfuscator.exe" sal dotfuscatorUI "C:\Program Files (x86)\PreEmptive Solutions\Dotfuscator Professional Edition Evaluation 4.21.0\dotfuscatorUI.exe" sal VSPerf-Data-Collector 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Performance Tools\VSPerf.exe' sal VSPerf-ASP-NET-Command 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Performance Tools\VSPerfASPNetCmd.exe' sal VSPerf-ASP-NET-Command 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Performance Tools\VSPerfCmd.exe' sal FxCopCmd 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Static Analysis Tools\FxCop\FxCopCmd.exe' sal bscmake-Browse-Information-Maintenance-Utility 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\bscmake.exe' sal cl-Microsoft-C-Cpp-Optimizing-Compiler 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\cl.exe' sal cvtres-Microsoft-Windows-Resource-To-Object-Converter 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\cvtres.exe' sal dumpbin-COFF-PE-Dumper 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\dumpbin.exe' sal editbin-COFF-PE-Editor 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\editbin.exe' sal lib-Library-Manager 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\lib.exe' sal link-Incremental-Linker 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\link.exe' sal ml 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\ml.exe' sal nmake 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\nmake.exe' sal undname-Cpp-Name-Undecorator 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\undname.exe' sal vcredist_arm-Microsoft-Visual-Cpp-2015-Redistributable-14.0.24215 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\redist\1033\vcredist_arm.exe' sal vcredist_x64-Microsoft-Visual-Cpp-2015-Redistributable-14.0.24215 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\redist\1033\vcredist_x64.exe' sal vcredist_x86-Microsoft-Visual-Cpp-2015-Redistributable-14.0.24215 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\redist\1033\vcredist_x86.exe' sal spyxx-chm 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\spyxx.chm' sal ok "C:\project\161010_CoconutClient\bin\CoconutBridge\Debug\OkposMock.exe" sal okd "C:\project\161010_CoconutClient\bin\CoconutBridge\Debug\OkdaemonMock.exe" sal dp "C:\project\161010_CoconutClient\bin\CoconutBridge\Debug\DangolMock.exe" sal hhdopen hhdvs2015openfile sal hhdupload hhdazurestorageuploadfile sal hhdopenprofileps1 hhdvs2015profileps1 <# .SYNOPSIS .EXAMPLE #> function hhdmoduleinstallimport { [CmdletBinding()] param ( [Parameter(Mandatory=$true, ValueFromPipeline=$true, ValueFromPipelinebyPropertyName=$true)] [System.String] $MODULE_NAME ) if((Get-InstalledModule -name $MODULE_NAME).count -eq 0) { write "install $MODULE_NAME ..." Install-Package $MODULE_NAME -Force -AllowClobber } else { write "$MODULE_NAME already installed !!!" } write "import $MODULE_NAME ..." Import-Module $MODULE_NAME -Force } <# .SYNOPSIS .EXAMPLE #> function hhdps { [CmdletBinding()] param ( ) ps | sort WS -Descending | select Id, Name, @{l="WS(M)"; e={[int]($_.WS / 1024 / 1024)}}, Path -First 10 | ft -AutoSize -Wrap } <# .SYNOPSIS .EXAMPLE #> function hhdgitgraph { [CmdletBinding()] param ( ) git log --pretty=format:"%h %s - %an %ar" --graph } <# .SYNOPSIS .EXAMPLE #> function hhdadblogcatmono { [CmdletBinding()] param ( ) adb logcat -s mono-stdout:v } <# .SYNOPSIS .EXAMPLE #> function hhdazureloginauto { [CmdletBinding()] param ( ) if ((Test-Path ~/*publishsettings) -eq $false) { Get-AzurePublishSettingsFile write ("save at {0}" -f (Resolve-Path ~).Path) } write "azure login ..." Import-AzurePublishSettingsFile ~\*.publishsettings } <# .SYNOPSIS .EXAMPLE #> function hhdazurecurrent { [CmdletBinding()] param ( ) write "azure subscription check ..." pause Get-AzureSubscription write "azure website check ..." pause Get-AzureWebsite Get-AzureWebHostingPlan write "azure sql database check ..." pause Get-AzureSqlDatabaseServer | Get-AzureSqlDatabase | hhdazuresqldatabasedetail write "azure storage account check ..." pause Get-AzureStorageAccount write "azure storage blob check ..." pause Get-AzureStorageAccount | Get-AzureStorageContainer | Get-AzureStorageBlob } <# .SYNOPSIS .EXAMPLE #> function hhdazurestartallwebsite { [CmdletBinding()] param ( ) write "azure website check ..." Get-AzureWebSite write "start all websites ..." Get-AzureWebSite | Start-AzureWebSite write "azure website check ..." Get-AzureWebSite } <# .SYNOPSIS .EXAMPLE #> function hhdazurestopallwebsite { [CmdletBinding()] param ( ) write "azure website check ..." Get-AzureWebSite write "stop all websites ..." Get-AzureWebSite | Stop-AzureWebSite write "azure website check ..." Get-AzureWebSite } <# .SYNOPSIS .EXAMPLE #> function hhdazuregetwebsiteloghhdyidbot { [CmdletBinding()] param ( ) Get-AzureWebsiteLog -Name hhdyidbot -Tail } <# .SYNOPSIS .EXAMPLE #> function hhdkillallpowershellwithoutme { [CmdletBinding()] param ( ) ps -Name *powershell* | where { $_.Id -ne $PID } | kill } <# .SYNOPSIS .EXAMPLE hhdiotconnect -servername "minwinpc" -password "p@ssw0rd" #> function hhdiotconnect { [CmdletBinding()] param ( [Parameter(Mandatory=$true, ValueFromPipeline=$true, ValueFromPipelinebyPropertyName=$true)] [System.String] $servername, [Parameter(Mandatory=$true, ValueFromPipeline=$true, ValueFromPipelinebyPropertyName=$true)] [System.String] $password ) write "start winrm service ..." net start winrm write "add TrustedHosts ..." Set-Item WSMan:\localhost\Client\TrustedHosts -Value $servername $passwordEnc = ConvertTo-SecureString $password -AsPlainText -Force $cred = New-Object System.Management.Automation.PSCredential("$servername\administrator", $passwordEnc) write "enter pssession ..." Enter-PSSession -ComputerName $servername -Credential $cred } <# .SYNOPSIS .EXAMPLE #> function hhdiotconnectminwinpc { [CmdletBinding()] param ( ) hhdiotconnect -servername "minwinpc" -password "p@ssw0rd" } <# .SYNOPSIS .EXAMPLE #> function hhdiotconnectfirstrp3 { [CmdletBinding()] param ( ) hhdiotconnect -servername "firstrp3" -password "p@ssw0rd" } <# .SYNOPSIS .EXAMPLE #> function hhdiotmountdrivefirstrp3 { [CmdletBinding()] param ( ) write " `$servername = `"firstrp2`" `$password = `"password`" `$passwordEnc = ConvertTo-SecureString `$password -AsPlainText -Force `$cred = New-Object System.Management.Automation.PSCredential(`"`$servername\administrator`", `$passwordEnc) New-PSDrive -Name iot -PSProvider FileSystem -Root \\`$servername\c$ -Credential `$cred "; } <# .SYNOPSIS .EXAMPLE #> function mycomplexfunc { [CmdletBinding()] param ( [Parameter(Mandatory=$true, ValueFromPipeline=$true, ValueFromPipelinebyPropertyName=$true)] [System.Diagnostics.Process] $process, [System.String] $prefix, [System.String[]] $strArray ) $obj = New-Object -typename PSObject $obj | Add-Member -MemberType NoteProperty -Name prefix -Value $prefix $obj | Add-Member -MemberType NoteProperty -Name ProcessName -Value $process.Name $obj | Add-Member -MemberType NoteProperty -Name ProcessId -Value $process.Id write ("strArray.Length : " + $strArray.Length) if ($strArray.Length -gt 0) { $rand = New-Object -TypeName System.Random $idx = $rand.Next($strArray.Length) write ("idx : " + $idx) $randValue = $strArray[$idx] write ("randValue : " + $randValue) $obj | Add-Member -MemberType NoteProperty -Name randValue -Value $randValue } Write-Output $obj } <# .SYNOPSIS .EXAMPLE #> function hhdazuresqldatabasedetail { [CmdletBinding()] param ( [Parameter(Mandatory=$true, ValueFromPipeline=$true, ValueFromPipelinebyPropertyName=$true)] [Microsoft.WindowsAzure.Commands.SqlDatabase.Services.Server.Database] $dbObj ) $obj = New-Object -typename PSObject $dbType = [Microsoft.WindowsAzure.Commands.SqlDatabase.Services.Server.Database] $methodList = $dbType.GetMethods() | where { $_.Name -like "get_*" } foreach ($method in $methodList) { $name = $method.Name.TrimStart("get_") $value = $method.Invoke($dbObj, $null) if ([string]::IsNullOrWhiteSpace($value)) { continue } $obj | Add-Member -MemberType NoteProperty -Name $name -Value $value } #pyx1rbr0s0.database.windows.net #Server=tcp:pyx1rbr0s0.database.windows.net,1433;Data Source=pyx1rbr0s0.database.windows.net;Initial Catalog=hhdyidbot;Persist Security Info=False;User ID={your_username};Password={your_password};Pooling=False;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30; $serverName = $dbObj.Context.ServerName $dbName = $dbObj.Name $obj | Add-Member -MemberType NoteProperty -Name ServerAddress -Value "$serverName.database.windows.net" $obj | Add-Member -MemberType NoteProperty -Name ConnectionString -Value "Server=tcp:$serverName.database.windows.net,1433;Data Source=$serverName.database.windows.net;Initial Catalog=$dbName;Persist Security Info=False;User ID={your_username};Password={your_password};Pooling=False;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;" Write-Output $obj } <# .SYNOPSIS .EXAMPLE #> function hhdnetworkgetpubip { [CmdletBinding()] param ( ) $myPubIp = (Invoke-WebRequest -Uri http://icanhazip.com).Content return $myPubIp } <# .SYNOPSIS .EXAMPLE #> function hhdwmigetprogram { [CmdletBinding()] param ( ) gwmi -Class win32_product } <# .SYNOPSIS .EXAMPLE #> function hhdmoduleloadfromdll { [CmdletBinding()] param ( [Parameter(Mandatory=$true, ValueFromPipeline=$true, ValueFromPipelinebyPropertyName=$true)] [System.String] $dllpath ) if (Test-Path $dllpath -eq $false) { write "no file ${dllpath} ..." return } Add-Type -Path $dllpath Import-Module $dllpath } <# .SYNOPSIS .EXAMPLE #> function hhdnugetrestore { [CmdletBinding()] param ( [Parameter(Mandatory=$true, ValueFromPipeline=$true, ValueFromPipelinebyPropertyName=$true)] [System.IO.FileInfo] $slnfile ) nuget restore -SolutionDirectory $slnfile.FullName -PackagesDirectory packages } <# .SYNOPSIS .EXAMPLE #> function hhdgcmgetscriptcontent { [CmdletBinding()] param ( [Parameter(Mandatory=$true, ValueFromPipeline=$true, ValueFromPipelinebyPropertyName=$true)] [System.String] $cmdname ) return (gcm $cmdname).ScriptBlock } <# .SYNOPSIS .EXAMPLE #> function hhdfileappendtime { [CmdletBinding()] param ( [Parameter(Mandatory=$true, ValueFromPipeline=$true, ValueFromPipelinebyPropertyName=$true)] [System.IO.FileInfo] $file, [switch] [Parameter(Mandatory=$false, ValueFromPipeline=$true, ValueFromPipelinebyPropertyName=$true)] $changedatealwaysnew = $false ) if($file.Name.StartsWith(".")) { write "${file}.Name start with . so skip ..." return } $isProcessed = $false $date6 = $file.LastWriteTime.ToString("yyMMdd") $isPrefixNum = $false if($file.Name.Length -gt 6) { $first6 = $file.Name.SubString(0, 6) for($i = 0; $i -lt $first6.Length; $i++) { $isPrefixNum = @("0", "1", "2", "3", "4", "5", "6", "7", "8", "9") -contains $first6[$i] if ($isPrefixNum -eq $false) { $isPrefixNum = $false break; } } } if($isPrefixNum) { if ($changedatealwaysnew) { $newFileName = $date6 + $file.Name.Substring(6, $file.Name.Length - 6) mv $file $newFileName write "${file}.Name -> ${newFileName} !!!" } else { write "${file}.Name is PrefixNum and is not changedatealwaysnew ..." } } else { $newFileName = $date6 + " " + $file.Name write "${file}.Name -> ${newFileName}" mv $file $newFileName } } <# .SYNOPSIS .EXAMPLE #> function hhdfilewritefortest { [CmdletBinding()] param ( [Parameter(Mandatory=$true, ValueFromPipeline=$true, ValueFromPipelinebyPropertyName=$true)] [System.IO.FileInfo] $file ) Read-Host | Out-File $file } <# .SYNOPSIS .EXAMPLE #> function hhdnetworkgetipmacaddress { [CmdletBinding()] param ( ) Get-WmiObject win32_networkadapterconfiguration | select description, macaddress, ipaddress | ? { $_.macaddress -ne $null} | fl } <# .SYNOPSIS .EXAMPLE #> function hhdcdaddpath { [CmdletBinding()] param ( [Parameter(Mandatory=$true, ValueFromPipeline=$true, ValueFromPipelinebyPropertyName=$true)] [System.String] $name, [Parameter(Mandatory=$true, ValueFromPipeline=$true, ValueFromPipelinebyPropertyName=$true)] [System.String] $path ) $g_hhdFavList | ? {$_.name -eq $name} | set rmList $rmList | % { $g_hhdFavList.Remove($_) } $newObj = New-Object psobject $newObj | Add-Member -Name name -Value $name -MemberType NoteProperty $newObj | Add-Member -Name path -Value $path -MemberType NoteProperty $g_hhdFavList.Add($newObj) $g_hhdFavList | ConvertTo-Json | Out-File -FilePath ~/hhdFavList.json } <# .SYNOPSIS .EXAMPLE #> function hhdcodeprofileps1 { [CmdletBinding()] param ( ) code ""C:\hhdcommand\PsDev\PsScripts\profile.ps1"" } <# .SYNOPSIS .EXAMPLE #> function hhdgitposhinit { write "change prompt ..." if((gcm prompt).ScriptBlock -like "*PM>*") { write "this is visual studio powershell window !!!" write "skip setup prompt ..." } else { write "this is normal environment !!!" write "import module posh-git ..." hhdmoduleinstallimport -MODULE_NAME posh-git function global:prompt { $realLASTEXITCODE = $LASTEXITCODE Write-Host ($pwd.ProviderPath) -nonewline Write-VcsStatus $global:LASTEXITCODE = $realLASTEXITCODE return "> " } } } <# .SYNOPSIS .EXAMPLE #> function hhdgitstashsave { [CmdletBinding()] param ( [Parameter(Mandatory=$false, ValueFromPipeline=$true, ValueFromPipelinebyPropertyName=$true)] [System.String] $stashName ) Read-Host "git status ..." git status Read-Host "git stash list ..." git stash list Read-Host "git stash save -u `"$stashName`" ..." git stash save -u "$stashName" } <# .SYNOPSIS .EXAMPLE #> function hhdgitstashapply { [CmdletBinding()] param ( [Parameter(Mandatory=$false, ValueFromPipeline=$true, ValueFromPipelinebyPropertyName=$true)] [System.Int32] $stashNumber ) Read-Host "git status ..." git status Read-Host "git stash list ..." git stash list if ($stashName -eq "") { Read-Host "git stash pop ..." git stash pop } else { Read-Host "git stash apply `"stash@{$stashNumber}`" ..." git stash apply "stash@{$stashNumber}" } } <# .SYNOPSIS .EXAMPLE #> function hhdgitaddcommitpush { [CmdletBinding()] param ( [Parameter(Mandatory=$false, ValueFromPipeline=$true, ValueFromPipelinebyPropertyName=$true)] [System.String] $commitMsg ) Read-Host "git status ..." git status Read-Host "git add * ..." git add * if ($commitMsg -eq "") { $commitMsg = "modify" } Read-Host "git commit -m `"$commitMsg`" ..." git commit -m "$commitMsg" Read-Host "git pull ..." git pull Read-Host "git push ..." git push } <# .SYNOPSIS .EXAMPLE #> function hhdgitresetclean { [CmdletBinding()] param ( ) git reset --hard HEAD git clean -fd } <# .SYNOPSIS .EXAMPLE #> function hhdkillwithchild { [CmdletBinding()] param ( [Parameter(Mandatory=$false, ValueFromPipeline=$true, ValueFromPipelinebyPropertyName=$true)] [System.String[]] $processNameList ) $processNameList | % { ps "*$_*" } | % { taskkill /PID $_.id /T /F } } <# .SYNOPSIS .EXAMPLE #> function hhdkillvsgarbage { [CmdletBinding()] param ( ) hhdkillwithchild -processName vshub hhdkillwithchild -processName msbuild } <# .SYNOPSIS .EXAMPLE #> function hhdonedriveupload { [CmdletBinding()] param ( [Parameter(Mandatory=$false, ValueFromPipeline=$true, ValueFromPipelinebyPropertyName=$true)] [System.String] $filePath ) hhdmoduleinstallimport -MODULE_NAME OneDrive $authRes = Get-ODAuthentication -ClientID "00000000401C7029" $uploadRes = Add-ODItem -AccessToken $authRes.access_token -Path "/publish" -LocalFile $filePath $uploadResObj = $uploadRes | ConvertFrom-Json $createLinkRes = Invoke-WebRequest ("https://api.onedrive.com/v1.0/drive/items/{0}/action.createLink" -f $uploadResObj.id) -Headers @{"Authorization"="bearer " + $authRes.access_token; "Content-Type"="application/json" } -Body '{ "type": "view" }' -Method Post $createLinkResObj = $createLinkRes | ConvertFrom-Json $createLinkResObj.link.webUrl | clip return $createLinkResObj.link.webUrl } <# .SYNOPSIS .EXAMPLE #> function hhdimagegetwin10spotlightlockscreen { [CmdletBinding()] param ( [Parameter(Mandatory=$false, ValueFromPipeline=$true, ValueFromPipelinebyPropertyName=$true)] [System.String] $dirName = "tmp" ) $fileList = ls ~\AppData\Local\Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\LocalState\Assets\* | ? { $_.Length -gt 100000 } write $fileList md $dirName $fileList | % { cp $_.FullName "$dirName\$($_.Name).png" } } <# .SYNOPSIS .EXAMPLE #> function hhdvs2015openfile { [CmdletBinding()] param ( [Parameter(Mandatory=$false, ValueFromPipeline=$true, ValueFromPipelinebyPropertyName=$true)] [System.String] $FILE_NAME ) ls $FILE_NAME -File | select FullName ls $FILE_NAME | % { vs2015 /Edit $_.FullName } } <# .SYNOPSIS .EXAMPLE #> function hhdvs2015profileps1 { [CmdletBinding()] param ( ) hhdvs2015openfile C:\hhdcommand\PsDev\PsScripts\profile.ps1 } <# .SYNOPSIS .EXAMPLE #> function hhdazurestorageuploadfile { [CmdletBinding()] param ( [Parameter(Mandatory=$false, ValueFromPipeline=$true, ValueFromPipelinebyPropertyName=$true)] [string] $FILE_NAME, [parameter(Mandatory = $false)] [ValidateSet("None", "Prefix", "Postfix")] [string] $ADD_TIMESTAMP_STR = "None" ) $AZURE_STORAGE_CONNECTION_STR = "DefaultEndpointsProtocol=https;AccountName=hhdpublish;AccountKey=3y07DG/iIvULhXaX0hzV8LU+6JWXP1EbeEzRfAP8hOhfXrRlnI+IEbbOfCwwF+UMIJxbqwGPtFcxKNXDzuwezw==;EndpointSuffix=core.windows.net" $storageCtx = New-AzureStorageContext -ConnectionString $AZURE_STORAGE_CONNECTION_STR # New-AzureStorageContainer -Context $storageCtx -Name "publish" -Permission Container ls $FILE_NAME -File -Force | % { $blobName = "" if($ADD_TIMESTAMP_STR -eq "Prefix") { $dtStr = $_.LastWriteTime.ToString("yyMMdd-HHmm") $blobName = "$dtStr $($_.Name)" } elseif($ADD_TIMESTAMP_STR -eq "Postfix") { $dtStr = $_.LastWriteTime.ToString("yyMMdd-HHmm") $fileName = [System.IO.Path]::GetFileNameWithoutExtension($_.Name) $blobName = "$fileName $dtStr$($_.Extension)" } else { $blobName = $_.Name } $blob = Set-AzureStorageBlobContent -Context $storageCtx -Container "publish" -File $_.FullName -Blob $blobName -Force $obj = New-Object -typename PSObject $obj | Add-Member -MemberType NoteProperty -Name LocalFilePath -Value $_.FullName $obj | Add-Member -MemberType NoteProperty -Name DownloadUrl -Value $blob.ICloudBlob.Uri.AbsoluteUri write $obj } | fl } write "main start ..." write "OutputEncoding = UTF8 ..." $OutputEncoding = New-Object -TypeName System.Text.UTF8Encoding -Verbose write "Set-ExecutionPolicy Bypass ..." Set-ExecutionPolicy Bypass -Scope Process -Force -Verbose write "configure path ..." $oldPath = Get-Content Env:\Path Set-Item Env:\Path " $oldPath; C:\hhdcommand\PortableGit\bin; C:\Program Files\nodejs\; " -Verbose cat Env:\Path if(!(Test-Path /temp)) { md /temp -Verbose } cd /temp -Verbose write "update profile.ps1 ..." if (Test-Path C:\hhdcommand\PsDev\PsScripts\profile.ps1) { write "update profile.ps1 ..." cp -Force C:\hhdcommand\PsDev\PsScripts\profile.ps1 "C:\Windows\System32\WindowsPowerShell\v1.0" -Verbose cp -Force C:\hhdcommand\PsDev\PsScripts\profile.ps1 "C:\Windows\SysWOW64\WindowsPowerShell\v1.0" -Verbose write "open profile.ps1 ..." } else { write "skip update profile.ps1 ..." } write "load hhdfavList.json ..." cat ~/hhdfavList.json | ConvertFrom-Json | set temp $g_hhdDirBackwardStack = New-Object -TypeName System.Collections.Stack $g_hhdDirForwardStack = New-Object -TypeName System.Collections.Stack $g_hhdFavList = New-Object System.Collections.Generic.List[psobject] $temp | % { $newObj = New-Object psobject $newObj | Add-Member -MemberType NoteProperty -Name name -Value $_.name $newObj | Add-Member -MemberType NoteProperty -Name path -Value $_.path $g_hhdFavList.Add($newObj) } $g_hhdFavList | % { $exp = "function hhdcd{0} {{ cd {1} }}" -f $_.name, $_.path write ("exp : {0}" -f $exp) Invoke-Expression $exp }