powershell - Insert win32_PhysicalMemory PowerShell data into SQL Server table
问题描述
I am trying to insert all the data from Get-WmiObject win32_PhysicalMemory PowerShell code into SQL Server 2012:
$MemoryObjects = Get-WmiObject win32_PhysicalMemory foreach($i in $MemoryObjects) { $Sn = $computerBIOS.SerialNumber $Item = @{label=$_.Label} $Des = $_.Description $InsertQuery=" INSERT INTO [dbo].[MyTable] ([SerialNumber] ,[Item] ,[Value]) VALUES ('$Sn' ,'$Item' ,'$Des') GO " Invoke-SQLcmd -ServerInstance 'ServerName' -query $insertquery -U Username -P 'Password' -Database MyDB }
The code only inserts the serial number, it does not insert the label and its value. Any suggestion on how to do that? For each memory module, there are around 40 values, some of them are shown in the picture below. My SQL Server table has three columns (all varchar datatype). The first column is for the serial number, the second is for the label and the last one for the value. I am not sure how the last two columns.
解决方案
推荐阅读
- tensorflow - 是否有与 Tensorflow 类“tf.nn.rnn_cell.MultiRNNCell”等效的 Pytorch?
- mysql - 从 ID 列中返回重复 ID 的计数
- ios - Singletons in Swift 5
- javascript - 无法模拟外部节点模块
- python - 查找给定的线(方程)是否能够在 python 中成功分离两个点列表
- uikit - 如何在@IBsegueAction 函数中获得正确的行?
- vb.net - 在我的浏览器中从 Visual Studio 2013 调试 asp.net webform 时出现乱码
- c++ - How to reset std::count return value
- python-3.x - PhotoImage GIF 不会出现(请新手友好)
- wordpress - Wordpress - Footer not appearing on product pages