相关疑难解决方法(0)

New-Object:术语New-Object不被识别为cmdlet的名称

我想为SharePoint中的app dev配置高可信应用程序,最后这样做我需要先在powershell编辑器中插入一些命令,如:

$publicCertPath = "C:\Certs\HighTrustSampleCert.cer" 
$certificate = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2($publicCertPath)
Run Code Online (Sandbox Code Playgroud)

我在Windows Server 2012 R2上使用Windows PowerShell,其中包括Windows PowerShell 4,默认情况下包含新对象cmd-let ...但我不明白,为什么我的系统不识别该命令....时间我收到以下错误:New-Object:术语'New-Object'不被识别为cmdlet的名称.

每次打开电源外壳时都会显示以下错误:

*选择 :

术语"选择对象"不被识别为cmdlet,函数,脚本文件或可操作程序的名称.检查名称的拼写,或者如果包含路径,请验证路径是否正确,然后重试.在C:\ Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\CONFIG\POWERSHELL\Registration\SharePoint.ps1:1 char:16 + $ ver = $ host | select version + ~~~~~~ + CategoryInfo:ObjectNotFound:(Select-Object:String)[],逗号ndNotFoundException + FullyQualifiedErrorId:CommandNotFoundException设置位置:术语"设置位置"不被识别为cmdlet的名称,功能,脚本文件或可操作程序.检查名称的拼写,或者如果包含路径,请验证路径是否正确,然后再次尝试在C:\ Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\CONFIG\POWERSHELL\Registration\SharePoint. ps1:4 char:1 + Set-location $ home + ~~~~~~~~~~~~ + CategoryInfo:ObjectNotFound:(Set-location:String)[],Comman dNotFoundException + FullyQualifiedErrorId:CommandNotFoundException*

我认为这是正常的,直到今天......它与错误有任何关系吗?这是洞(新对象)异常堆栈:

New-Object:术语"New-Object"不被识别为cmdlet,函数,脚本文件或可操作程序的名称.检查名称的拼写,或者如果包含路径,请验证路径是否正确,然后重试.在行:1 char:16 + $ certificate = New-Object System.Security.Cryptography.X509Certificates.X509Cert ... + ~~~~~~~~~~ + CategoryInfo:ObjectNotFound:(New-Object:String)[ ],CommandN otFoundException + FullyQualifiedErrorId:CommandNotFoundException …

powershell sharepoint-2013 windows-server-2012

6
推荐指数
1
解决办法
1万
查看次数

powershell将透明png转换为jpg

我正在尝试将一堆透明 png 批量转换为 jpg,下面的鹅卵石 powershell 可以工作,但每当我转换时,所有图像都会显示为黑色。我在这里尝试了答案 将透明 PNG 转换为具有非黑色背景颜色的 JPG 但我得到“使用”关键字不受支持(在模块中也找不到它)

$files = Get-ChildItem "C:\Pictures\test" -Filter *.png -file -Recurse | 
foreach-object {

    $Source = $_.FullName
    $test = [System.IO.Path]::GetDirectoryName($source)
    $base= $_.BaseName+".jpg"
    $basedir = $test+"\"+$base
    Write-Host $basedir
    Add-Type -AssemblyName system.drawing
    $imageFormat = "System.Drawing.Imaging.ImageFormat" -as [type]
    $image = [drawing.image]::FromFile($Source)
    $image.Save($basedir, $imageFormat::jpeg)
}  
Run Code Online (Sandbox Code Playgroud)

据我了解,您需要创建一个具有白色背景的新位图图形,并在其上绘制此图像,但我一生都不知道如何添加它。

powershell

4
推荐指数
1
解决办法
4755
查看次数

在SQL中插入日期

我指定了以下日期时间:

$dateChanged = Get-Date -Format ("yyyy-MM-dd hh:mm:ss.fff")
Run Code Online (Sandbox Code Playgroud)

我想使用以下PowerShell将其插入到SQL datetime字段中:

INSERT INTO myTable (name, dateChanged) VALUES ($name, $dateChanged);
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

使用"0"参数调用"ExecuteNonQuery"的异常:"'11'附近的语法不正确."

注意:这里的当前时间是11:28.

我尝试重新格式化dateChanged变量无济于事.

powershell

0
推荐指数
1
解决办法
499
查看次数