Get-CimInstance在PowerShell中列出我的计算机上的打印机

时间:2017-10-12 07:20:47

标签: powershell

我正在尝试使用Get-CimInstance列出计算机上的所有打印机。我尝试在powershell中使用printerobject,但是在使用ciminstance时遇到错误。我收到一个错误,其中说出了powershell中的无效类。

def merge_news_category(x,y):
    return {x:y}
get_category_news = udf(lambda x,y: merge_news_category(x,y),MapType(StringType(),ArrayType(StringType(),DoubleType())))

res2 = res1.withColumn('recomendation',get_category_news(col('category'),col('news')))
res2.show(10)

2 个答案:

答案 0 :(得分:0)

您正在寻找的课程是" Win32_Printer":

Get-CimInstance Win32_Printer

答案 1 :(得分:0)

或者,您也可以尝试:

Get-CimInstance -Class CIM_Printer -ComputerName "nameoftheprinterserver"