跳到主要內容

發表文章

目前顯示的是有「powershell」標籤的文章

無法執行PowerShell腳本

前言 如果在執行PowerShell的時候遇到以下的錯誤訊息的話  ps1 is not digitally signed. You cannot run this script on the current system. 不妨試試以下的指令, 告訴系統暫時先放過這個腳本 powershell.exe -executionpolicy bypass -file .\Script.ps1

如何移植實體機上的Windows 10到 Hyper-V VM - Move Windows 10 From PC to Hyper-V VM

前言 自Windows 7之後多了一個有趣備份的功能, 可以將目前的環境壓成一個VHD檔保存, 將來可以用它來作還原 除此之外這份VHD檔還可以被Hyper-V 的虛擬機器掛載起來使用(達到移植的目的) 以下就示範如何使用這個技術來將實體機上的環境遷移到虛擬機器上跑... Step 1. 首先把目前環境壓成VHD wbAdmin start backup -backupTarget:F: -include:C: -allCritical -quiet 結束之後目的地會多一個資料夾WindowsImageBackup -----------------------------------開始移植--------------------------------------- Step 2. Create a Virtual Machine 使用PowerShell來建立VM New-VM -Name Win10VM -MemoryStartupBytes 8GB -BootDevice VHD -Path .\VMData -Generation 2 Step 3. Attach OS Image 這個步驟中我們需要掛載Windows作業系統的安裝光碟, 待會需要在安裝環境下建立開機檔案 用以下的指令來掛載 Add-VMDvdDrive -VMName Win10VM -Path "D:\OSCD_W10 RS2 Professional_64_EN [for DriverCD].iso" Step 4. Attach our backed VHD 在.\WindowsImageBackup\<PC名稱>\Backup 的目錄底下可以找到Step 1.備份出來的VHD檔(.vhdx) 把VHD掛到VM上 Add-VMHardDiskDrive -VMName Win10VM -ControllerType SCSI -ControllerNumber 0 -ControllerLocation 1 -Path "D:\backup\WindowsImageBackup\ANDY-PC...

使用MSBuild來自動化編譯及部屬ASP.NET Web應用程式到 Azure

Title: How to use MSBuild to deploy your .NET Web Application on Azure 前言 對於開發人員來說, routine的事情能夠自動化就自動化, 比如說編譯程式, 或是發布程式等等, 這些自動化之後, 才能將更多的專注力放在程式開發上, 以下就是介紹如何使用 MSBuild 來佈署.NET Framework的程式到Azure App Service上 MSBuild 用來佈署.Net framework到Azure 上的工具, 可以透過安裝Visual Studio來獲得, 使用方式如下: MSBuild <solution的位置> /p:DeployOnBuild  /p:PublishProfile /p:Password MSBuild 需要吃一個Publish Profile才能正常運作, 以下教學將會演示如何編輯Publish Profile, 並且使用 MSBuild 來做編譯以及佈署 必要條件 需要安裝Visual Studio 需要在Azure App Service建立服務   需要取得佈署帳密(Publish Profile) 需要安裝Azure Cli az webapp deployment list-publishing-profiles --name YOUR-APP-NAME --resource-group YOUR-RESOURCE-GROUP Step 1. 下載佈署範本 $appSolutionDeploymentProfile = ".\production.pubxml" wget https://gist.githubusercontent.com/andy51002000/37a0af3fec1caf2955f109c0b583b3e3/raw/9b2105abd05a304b8ea6045fe78c8de781f4d0a2/publish.pubxml -OutFile $appSolutionDeploymentProfile Step 2. 開始來編輯Publish Profile的內容 宣告...

使用Powershell處理Http Reqest

使用Powershell處理Http Request (How to handle HTTP request in powershell ) 前言 在Linux的世界裡我們可以用cURL發請求去取得Web 上的資源, 而在Windows則可以使用Invoke-WebRequest做到相同的事情 語法  Invoke-WebRequest -Uri $AppUrl -Method Get 例如 $request = 'http://andy.lai.org/ws/2/artist/5b11f4ce-a62d-471e-81fc-a69a8278c7da?inc=aliases&fmt=json' $response = Invoke-WebRequest $request 得到的response會長這樣 StatusCode : 200 StatusDescription : OK Content : [{"answer":{"action":{"type":"","uri":""},"image":[],"video":[],"title":"","text":"隨便就可以打開了","speak":""},"intent":"itent_on_computer","slots":[]},{"answer":{ "action":{"type":"","uri":""},"image":[],"v... RawContent : HTTP/1.1 200 OK Access-Control-Allow-Origin: * Connection: keep-alive Content-...