PowerShell过程无需导出文件即可导入

如何解决PowerShell过程无需导出文件即可导入

以下过程有效,但需要使用输出文件然后再次导入的方法。我敢肯定,没有导出/导入步骤,必须有更好的方法来编码此过程。

代码

Get-Content -Path 'C:\Temp\Patch_Summary.csv' | Select-Object -Skip 6 | Out-File 'C:\Temp\TempPatchFile.csv' -Force
$PatchFile = Import-Csv 'K:\_Users\Keith\Documents\AOS Patch Certification\TempPatchFile.csv' | Select-Object @{ expression = {$_.Details_Table0_Title}; label = 'Name' },UniqueUpdateID

foreach ($Patch in $PatchFile) {
  switch -WildCard ($Patch.Name) {
    '*2012*' { $Patch | Add-Member -MemberType NoteProperty -Name 'OS' -Value '2012' }
    '*2016*' { $Patch | Add-Member -MemberType NoteProperty -Name 'OS' -Value '2016' }
    '*2019*' { $Patch | Add-Member -MemberType NoteProperty -Name 'OS' -Value '2019' }
    Default {}
  }
}

$PatchFile = $PatchFile | Sort-Object -Property OS,Name

Patch_Summary.csv

DescriptionLabelTextbox,DescriptionTextbox
Description,This report returns the software updates that are contained in a specific deployment.

Header_Table1_CollectionName,Header_Table1_Available,Header_Table1_Deadline,Textbox1,Details_Table1_CollectionName,Details_Table1_Available,Details_Table1_Deadline,DeploymentID
Collection Name,Available,Deadline,Deployment ID,.APOM_Patch_Certification,9/10/2020 5:58:00 AM,{B7EE09E8-9DD8-4DE5-AC38-4555AD9610FA}

Header_Table0_Title,Header_Table0_BulletinID,Header_Table0_ArticleID,Header_Table0_Present,Header_Table0_Missing,Header_Table0_NotApplicable,Header_Table0_Unknown,Header_Table0_Failed,Header_Table0_Pending,Textbox3,Details_Table0_Title,Details_Table0_BulletinID,Details_Table0_ArticleID,Details_Table0_Present,Details_Table0_Missing,Details_Table0_NotApplicable,Details_Table0_Unknown,Details_Table0_Failed,Details_Table0_Pending,UniqueUpdateID
Title,Bulletin ID,Article ID,Installed,Required,Not Required,Unknown,Failed,Pending,Update ID,"2020-07 Cumulative Update for .NET Framework 3.5,4.7.2 and 4.8 for Windows Server 2019 for x64 (KB4566516)",4566516,5,0d506775-e391-41bd-b932-d79df9147c9b
Title,2020-08 Cumulative Security Update for Internet Explorer 11 for Windows Server 2012 R2 for x64-based systems (KB4571687),4571687,1,3,0f07444e-6221-4077-b693-9d8e7d64e872
Title,"2020-08 Cumulative Update for .NET Framework 3.5,4.7.2 and 4.8 for Windows Server 2019 for x64 (KB4570505)",4570505,4,35e0f439-aec4-4398-879b-7866e0a8eb62
Title,2020-08 Cumulative Update for .NET Framework 4.8 for Windows Server 2016 (1803) for x64 (KB4569749),4569749,d95875ba-af5b-441c-ba93-8c111f49ba71
Title,2020-08 Cumulative Update for .NET Framework 4.8 for Windows Server 2016 for x64 (KB4569746),4569746,b3d9d297-418f-46e3-86cc-ed6362eb154b
Title,2020-08 Cumulative Update for Windows Server 2016 for x64-based Systems (KB4571694),4571694,cf7a53b4-c18c-4c38-b4ef-711043f4d178
Title,2020-08 Cumulative Update for Windows Server 2019 for x64-based Systems (KB4565349),4565349,1e857e5a-9432-4eaa-8c29-a755cc55f91d
Title,"2020-08 Security and Quality Rollup for .NET Framework 3.5,4.5.2,4.6,4.6.1,4.6.2,4.7,4.7.1,4.7.2,4.8 for Windows 8.1 and Server 2012 R2 for x64 (KB4570508)",4570508,2,0b02eea9-9517-4f0f-adb4-1381bde7a3d4
Title,2020-08 Security Monthly Quality Rollup for Windows Server 2012 R2 for x64-based Systems (KB4571703),4571703,41841c9a-956c-4b83-a626-58a1848f515b
Title,2020-08 Security Only Quality Update for Windows Server 2012 R2 for x64-based Systems (KB4571723),4571723,218e6900-fb95-4be6-be8d-a246fbf73ad7
Title,"2020-08 Security Only Update for .NET Framework 3.5,4.8 for Windows 8.1 and Server 2012 R2 for x64 (KB4570502)",4570502,c72fc911-8cbc-4a9a-bd12-073b2b7ec0bb   
Title,2020-08 Servicing Stack Update for Windows Server 2019 for x64-based Systems (KB4566424),4566424,47056470-c0fd-466f-845b-66f418c46420

所需结果

Name                                                                                                                                                                UniqueUpdateID                       OS
----                                                                                                                                                                --------------                       --
2020-08 Cumulative Security Update for Internet Explorer 11 for Windows Server 2012 R2 for x64-based systems (KB4571687)                                            0f07444e-6221-4077-b693-9d8e7d64e872 2012
2020-08 Security and Quality Rollup for .NET Framework 3.5,4.8 for Windows 8.1 and Server 2012 R2 for x64 (KB4570508) 0b02eea9-9517-4f0f-adb4-1381bde7a3d4 2012
2020-08 Security Monthly Quality Rollup for Windows Server 2012 R2 for x64-based Systems (KB4571703)                                                                41841c9a-956c-4b83-a626-58a1848f515b 2012
2020-08 Security Only Quality Update for Windows Server 2012 R2 for x64-based Systems (KB4571723)                                                                   218e6900-fb95-4be6-be8d-a246fbf73ad7 2012
2020-08 Security Only Update for .NET Framework 3.5,4.8 for Windows 8.1 and Server 2012 R2 for x64 (KB4570502)        c72fc911-8cbc-4a9a-bd12-073b2b7ec0bb 2012
2020-08 Cumulative Update for .NET Framework 4.8 for Windows Server 2016 (1803) for x64 (KB4569749)                                                                 d95875ba-af5b-441c-ba93-8c111f49ba71 2016
2020-08 Cumulative Update for .NET Framework 4.8 for Windows Server 2016 for x64 (KB4569746)                                                                        b3d9d297-418f-46e3-86cc-ed6362eb154b 2016
2020-08 Cumulative Update for Windows Server 2016 for x64-based Systems (KB4571694)                                                                                 cf7a53b4-c18c-4c38-b4ef-711043f4d178 2016
2020-07 Cumulative Update for .NET Framework 3.5,4.7.2 and 4.8 for Windows Server 2019 for x64 (KB4566516)                                                         0d506775-e391-41bd-b932-d79df9147c9b 2019
2020-08 Cumulative Update for .NET Framework 3.5,4.7.2 and 4.8 for Windows Server 2019 for x64 (KB4570505)                                                         35e0f439-aec4-4398-879b-7866e0a8eb62 2019
2020-08 Cumulative Update for Windows Server 2019 for x64-based Systems (KB4565349)                                                                                 1e857e5a-9432-4eaa-8c29-a755cc55f91d 2019
2020-08 Servicing Stack Update for Windows Server 2019 for x64-based Systems (KB4566424)                                                                            47056470-c0fd-466f-845b-66f418c46420 2019

解决方法

$PatchFile = Get-Content -Path 'C:\Temp\Patch_Summary.csv' | Select-Object -Skip 6 | ConvertFrom-Csv | Select-Object @{ expression = {$_.Details_Table0_Title}; label = 'Name' },UniqueUpdateID

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams['font.sans-serif'] = ['SimHei'] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -> systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping("/hires") public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate<String
使用vite构建项目报错 C:\Users\ychen\work>npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-
参考1 参考2 解决方案 # 点击安装源 协议选择 http:// 路径填写 mirrors.aliyun.com/centos/8.3.2011/BaseOS/x86_64/os URL类型 软件库URL 其他路径 # 版本 7 mirrors.aliyun.com/centos/7/os/x86
报错1 [root@slave1 data_mocker]# kafka-console-consumer.sh --bootstrap-server slave1:9092 --topic topic_db [2023-12-19 18:31:12,770] WARN [Consumer clie
错误1 # 重写数据 hive (edu)> insert overwrite table dwd_trade_cart_add_inc > select data.id, > data.user_id, > data.course_id, > date_format(
错误1 hive (edu)> insert into huanhuan values(1,'haoge'); Query ID = root_20240110071417_fe1517ad-3607-41f4-bdcf-d00b98ac443e Total jobs = 1
报错1:执行到如下就不执行了,没有显示Successfully registered new MBean. [root@slave1 bin]# /usr/local/software/flume-1.9.0/bin/flume-ng agent -n a1 -c /usr/local/softwa
虚拟及没有启动任何服务器查看jps会显示jps,如果没有显示任何东西 [root@slave2 ~]# jps 9647 Jps 解决方案 # 进入/tmp查看 [root@slave1 dfs]# cd /tmp [root@slave1 tmp]# ll 总用量 48 drwxr-xr-x. 2
报错1 hive> show databases; OK Failed with exception java.io.IOException:java.lang.RuntimeException: Error in configuring object Time taken: 0.474 se
报错1 [root@localhost ~]# vim -bash: vim: 未找到命令 安装vim yum -y install vim* # 查看是否安装成功 [root@hadoop01 hadoop]# rpm -qa |grep vim vim-X11-7.4.629-8.el7_9.x
修改hadoop配置 vi /usr/local/software/hadoop-2.9.2/etc/hadoop/yarn-site.xml # 添加如下 <configuration> <property> <name>yarn.nodemanager.res