[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"menus-public":3,"blog-10055":83,"blog-10055-comments":91},[4,15,43,66],{"id":5,"title":6,"link":7,"icon":8,"target":9,"sort_order":10,"is_active":11,"parent_id":12,"created_at":13,"children":14},10001,"首页","\u002F","","_blank",0,true,null,"2026-04-04T12:03:45",[],{"id":16,"title":17,"link":18,"icon":8,"target":19,"sort_order":20,"is_active":11,"parent_id":12,"created_at":21,"children":22},10038,"墨言博客","\u002Fblog","_self",1,"2026-10-30T23:08:14",[23,29,36],{"id":24,"title":25,"link":26,"icon":8,"target":19,"sort_order":20,"is_active":11,"parent_id":16,"created_at":27,"children":28},10039,"技术前沿","\u002Fblog?category=10001","2026-10-30T23:10:46",[],{"id":30,"title":31,"link":32,"icon":8,"target":19,"sort_order":33,"is_active":11,"parent_id":16,"created_at":34,"children":35},10042,"生活随笔","\u002Fblog?category=20007",2,"2026-10-30T23:55:19",[],{"id":37,"title":38,"link":39,"icon":8,"target":19,"sort_order":40,"is_active":11,"parent_id":16,"created_at":41,"children":42},10043,"旅游日记","\u002Fblog?category=20006",3,"2026-10-31T00:00:11",[],{"id":33,"title":44,"link":45,"icon":8,"target":19,"sort_order":33,"is_active":11,"parent_id":12,"created_at":46,"children":47},"新闻中心","\u002Fnews","2026-10-24T19:09:40",[48,54,60],{"id":49,"title":50,"link":51,"icon":8,"target":19,"sort_order":20,"is_active":11,"parent_id":33,"created_at":52,"children":53},10046,"产品动态","\u002Fnews?category=20010","2026-10-31T00:17:38",[],{"id":55,"title":56,"link":57,"icon":8,"target":19,"sort_order":33,"is_active":11,"parent_id":33,"created_at":58,"children":59},10047,"新闻热点","\u002Fnews?category=20009","2026-10-31T00:17:55",[],{"id":61,"title":62,"link":63,"icon":8,"target":19,"sort_order":40,"is_active":11,"parent_id":33,"created_at":64,"children":65},10045,"公司动态","\u002Fnews?category=20008","2026-10-31T00:17:11",[],{"id":67,"title":68,"link":69,"icon":8,"target":19,"sort_order":67,"is_active":11,"parent_id":12,"created_at":46,"children":70},4,"精彩视频","\u002Fvideo",[71,77],{"id":72,"title":73,"link":74,"icon":8,"target":19,"sort_order":10,"is_active":11,"parent_id":67,"created_at":75,"children":76},13,"活动记录","\u002Fvideo?category=6","2026-10-25T21:04:39",[],{"id":78,"title":79,"link":80,"icon":8,"target":19,"sort_order":20,"is_active":11,"parent_id":67,"created_at":81,"children":82},11,"产品展示","\u002Fvideo?category=5","2026-10-25T21:02:59",[],{"id":84,"category_id":5,"title":85,"author":8,"summary":86,"cover":87,"content":88,"tags":8,"seo_title":8,"seo_description":8,"seo_keywords":8,"og_image":8,"views":72,"comment_count":10,"is_top":89,"is_published":11,"created_at":90},10055,"powershell5及powershell7","PowerShell 5.1 与 PowerShell 7 并非简单的“升级”关系，它们是两个独立的产品，可以并行安装和运行。PowerShell 5.1 是 Windows 的内置组件，而 PowerShell 7 是需要单独安装的、面向未来的跨平台版本。","\u002Fstatic\u002Fuploads\u002Fblogs\u002F1793008327745-720344879.jpg","PowerShell 5.1 与 PowerShell 7 并非简单的“升级”关系，它们是**两个独立的产品，可以并行安装和运行**。PowerShell 5.1 是 Windows 的内置组件，而 PowerShell 7 是需要单独安装的、面向未来的跨平台版本。\n\n以下是它们在核心维度的主要区别：\n\n### 🏗️ 核心架构与定位\n\n| 维度 | Windows PowerShell 5.1 | PowerShell 7 |\n| :--- | :--- | :--- |\n| **核心定位** | Windows 内置的**传统\u002F维护模式**版本 | **活跃开发的主线**，面向现代自动化 |\n| **底层框架** | .NET Framework v4.5 | .NET (原 .NET Core)，版本随 PowerShell 更新 |\n| **跨平台性** | **仅限 Windows** | **跨平台**：Windows, macOS, Linux |\n| **可执行文件** | `powershell.exe` | `pwsh.exe` |\n| **开发状态** | 不再添加新功能，支持周期跟随 Windows | 微软**主要开发线**，持续增加新功能 |\n| **安装方式** | 随 Windows 预装 | 需**单独安装**（MSI, ZIP, Store 等） |\n\n### ⚙️ 功能与性能特性\n\nPowerShell 7 引入了大量新功能，旨在提升脚本能力和执行效率。\n\n*   **并行处理**：这是最受关注的改进之一。PowerShell 7 新增了 **`ForEach-Object -Parallel`** 参数，允许你并行处理管道中的多个项目，能显著缩短可并行工作负载的执行时间。\n*   **新语言特性**：支持**三元运算符** (`? :`)、空合并运算符 (`??`) 等现代语言特性，使脚本更简洁。\n*   **性能提升**：得益于 .NET Core 的优化，PowerShell 7 的**启动速度通常比 5.1 快约 30%**。\n*   **现代化远程处理**：支持基于 **SSH 的远程处理**，与 5.1 基于 WinRM 的远程方式不同，这使其能更好地管理 Linux 等非 Windows 系统。\n*   **容器支持**：原生支持 **Docker 容器**，便于在容器化环境中使用。\n\n### 🔄 兼容性与迁移关键点\n\n尽管 PowerShell 7 是发展方向，但迁移时需注意以下关键差异：\n\n*   **模块兼容性**：许多旧模块仍依赖完整的 .NET Framework，无法直接在 PowerShell 7 中加载。为此，PowerShell 7 提供了 **Windows PowerShell 兼容性功能**。你可以通过 `Import-Module -UseWindowsPowerShell` 参数来加载这些旧模块，它会在后台启动一个 5.1 的进程来运行它们。\n*   **默认字符编码**：这是一个常见的迁移陷阱。**PowerShell 5.1 的默认编码因命令而异**（例如 `Out-File` 是 UTF-16LE，`Get-Content` 是 ANSI），而 **PowerShell 7 统一使用不带 BOM 的 UTF-8**。如果你的脚本处理包含中文、日文等非英文字符的文件，迁移到 7 后可能会因编码不匹配而出现乱码。\n*   **Cmdlet 行为差异**：部分 Cmdlet 的默认行为或输出格式可能有所不同。例如，`Get-Process` 命令的默认显示列在 5.1 和 7 中就可能存在差异。在迁移自动化脚本时，需要对此进行测试。\n\n### 💎 总结与选择建议\n\n**PowerShell 5.1** 是稳定、兼容性优先的选择，适合维护现有的、依赖 .NET Framework 的传统 Windows 自动化脚本和系统管理任务。\n\n**PowerShell 7** 是面向未来的选择，适合编写**新的自动化脚本**，尤其是在需要跨平台管理（Windows\u002FLinux\u002FmacOS）、追求更高性能、使用并行处理或容器化环境时。由于二者可以并行共存，你可以同时在系统中保留两者，根据具体任务灵活选用。",false,"2026-10-26T17:52:17",{"list":92,"total":10,"page":20,"size":93},[],30]