一個無法刪除的Windows同名資料夾
同事在一個意外之下,製造出了兩個同名資料夾:
好玩的事:一個可被刪除,另一個不管用什麼方式都無法被刪除。
在前面談到 PowerShell Core 的指令可能沒有 PowerShell 來的全面,預設 PowerShell Core 只提供最核心的模組功能,但放心,從 PowerShell 時期就能通過模組(Module)來擴充,我可以透過 https://www.powershellgallery.com 來查詢與安裝,或利用 Get-Module 來查詢:
PS C:\> Get-Module -ListAvailable
Directory: C:\program files\powershell\6\Modules
ModuleType Version Name PSEdition ExportedCommands
---------- ------- ---- --------- ----------------
Manifest 6.1.0.0 CimCmdlets Core {Get-CimAssociatedInstance, Get-CimClass, Get-CimInstance, Get-CimSession…}
Manifest 1.2.3.0 Microsoft.PowerShell.Archive Desk {Compress-Archive, Expand-Archive}
Manifest 6.1.0.0 Microsoft.PowerShell.Diagnostics Core {Get-WinEvent, New-WinEvent}
Manifest 6.1.0.0 Microsoft.PowerShell.Host Core {Start-Transcript, Stop-Transcript}
Manifest 6.1.0.0 Microsoft.PowerShell.Management Core {Add-Content, Clear-Content, Clear-ItemProperty, Join-Path…}
Manifest 6.1.0.0 Microsoft.PowerShell.Security Core {Get-Acl, Set-Acl, Get-PfxCertificate, Get-Credential…}
Manifest 6.1.0.0 Microsoft.PowerShell.Utility Core {Export-Alias, Get-Alias, Import-Alias, New-Alias…}
Manifest 6.1.0.0 Microsoft.WSMan.Management Core {Disable-WSManCredSSP, Enable-WSManCredSSP, Get-WSManCredSSP, Set-WSManQuickConfig…}
Script 1.3.2 PackageManagement Desk {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource…}
Script 2.1.3 PowerShellGet Desk {Find-Command, Find-DSCResource, Find-Module, Find-RoleCapability…}
Script 0.0 PSDesiredStateConfiguration Desk {ValidateNoCircleInNodeResources, StrongConnect, New-DscChecksum, Test-NodeResources…}
Script 6.1.0.0 PSDiagnostics Core {Disable-PSTrace, Disable-PSWSManCombinedTrace, Disable-WSManTrace, Enable-PSTrace…}
Script 2.0.0 PSReadLine Desk {Get-PSReadLineKeyHandler, Set-PSReadLineKeyHandler, Remove-PSReadLineKeyHandler, Get-PSReadLineOption…}
Binary 1.1.2 ThreadJob Desk Start-ThreadJob
因為教學與工作上的需求,經常使用到 Northwind 資料庫,但重覆性的建立工作,實在浪費不少時間。在容器化時代,當然用容器來解決這種工作內容最合適不過了。
在測試 .NET Core 註冊為 Windows Service 的過程中,發現 .NET Core 在離開 IIS 之後真的好好玩,連 ASP.NET Core 都可以不用理 IIS 也活的好好的。想把 ASP.NET Core 註冊為 Windows Service 來執行,最主要是想以得較高的身份驗證來執行一些之前在 IIS 裡不易處理的狀況。不過就在玩得正高興時,發現:
New-Service
Start-Service
Get-Service
Stop-Service
Remove-Service
最後一個 Remove-Service 怎麼試都會出錯,連看個說明文件也有事!
λ Get-Help Remove-Service
Get-Help : Get-Help 在此工作階段的說明檔中找不到 Remove-Service。若要下載更新的說明主題,請輸入: "Update-Help"。若要線上取得說明,請搜尋 TechN
et Library (網址為 https:/go.microsoft.com/fwlink/?LinkID=107116) 中的說明主題。
位於 線路:1 字元:1
+ Get-Help Remove-Service
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (:) [Get-Help], HelpNotFoundException
+ FullyQualifiedErrorId : HelpNotFound,Microsoft.PowerShell.Commands.GetHelpCommand
前篇說到,PowerShell Core(pwsh.exe) 目前使用上會有一個視窗跳動的問題,可以改用 cmder 或 Windows Terminal 等其他整合命令環境來解決。因為 cmder 需要其他組態,而 Windows Terminal 差不多是裝好即用,本篇說明 cmder 的相關組態。