我正试图让应用程序使用PowerShell安装在远程服务器上。 这是我正在使用的脚本: $ cred = Get-Credential $ s = New-PSSession -ComputerName $ ServerName -Credential $ cred Invoke-Command -Session $ s -ScriptBlock {Start-Process -FilePath“c:\ windows \ system32 \ msiexec.exe”-ArgumentList“/ i \\ computer \ e $ \ installer.msi / qn”-Wait} Remove-PSSession -ComputerName $ ServerName 如果我直接在远程计算机上运行下面的命令,它会很好地执行: Start-Process -FilePath“c:\ windows \ system32 \ msiexec.exe”-ArgumentList“/ i \\ computer \ e […]
在PowerShell中,您可以运行以下命令来列出服务器上的所有不同的事件日志文件夹: Get-EventLog -list 有没有办法在Python中做到这一点? 我见过很多关于如何从特定文件夹(例如使用win32evtlog )获取日志的post,而不是如何检索所有事件日志文件夹的列表。 我正在运行Windows Server 2008。
我看到很多关于如何从映射的驱动器号获取UNCpath的问题,但是却没有发现相反的问题。 在不同的Windows 7企业机器上,我得到了具有完全相同的input,当前目录和networking驱动器映射的System.Windows.Forms.OpenFileDialog实例的FileName的不同答案: 一台计算机用UNCpath回答 PS A:\Liver\Department\Records\check log> .\sign-log.ps1 VERBOSE: Writing signature to \\liver53-pc.ad.institute.edu\Documents\Liver\Department\Records\check log\00\check log.xlsx.sig 其他人用映射的驱动器path回答 PS A:\Liver\Department\Records\check log> .\sign-log.ps1 VERBOSE: Writing signature to A:\Liver\Department\Records\check log\00\check log.xlsx.sig 我需要每台计算机都使用映射的驱动器path来回答:接收FileName的命令行程序不理解UNCpath。 这里是sign-log.ps1的内容: Add-Type -AssemblyName System.Windows.Forms function Sign-Log ($file = '.\check-log.xlsx') { $FileBrowser = New-Object System.Windows.Forms.OpenFileDialog -Property @{ Title = 'Select' ; InitialDirectory = (Get-Location).Path ; Filename = 'check […]
问题: 使用.ps1脚本在远程计算机( Win 2008 Server )上创buildnetworking共享,并提供username和password 。 这适用于当前用户有足够权限的地方 $share = Get-WmiObject Win32_Share -List -ComputerName 10.0.0.1 $share.create("C:\dir","foo", 0) 当targetServer是我的用户没有足够权限的机器时,我需要一种方法来提供username和password
我有一个.ps1 PowerShell脚本执行窗口,但我的整个数据是在Linux服务器,是否有任何可能的方式,通过我可以执行在红帽服务器的PowerShell脚本 PowerShell脚本是: Clear-Host $path="D:\Deep Backup 26-04-2013\New folder" $systemname=Read-Host 'Enter System Name' $files=Get-ChildItem $path -Recurse -Force -Include *_Registrar.zip*,*.reg.zip* $counter=1 foreach($file in $files) { $name=$file.name [void][system.reflection.Assembly]::LoadFrom("C:\Program Files\MySQL\MySQL Connector Net 6.5.4\Assemblies\v2.0\MySql.Data.dll") $dbconnect=New-Object MySql.Data.MySqlClient.MySqlConnection $dbconnect.ConnectionString="server=localhost;userid=root;password=nPr123*;database=test3;" $dbconnect.Open() $sql="insert into eid values('"+$name + "','"+$systemname+"')" $command=new-object MySql.Data.MySqlClient.MySqlCommand($sql,$dbconnect) $command.ExecuteNonQuery() } $sql="insert into eid_unique select distinct Packet_name, System_name from eid a where not […]
我正在开发一个项目,在这个项目中,我们使用configurationpipe理来远程部署软件,其中一部分将PowerShell脚本交付给Windows服务器,然后执行这些脚本以执行部分安装和/或configuration。 当前的部署方法将脚本写入磁盘,但不closures文件句柄。 这样做是为了通过防止任何其他进程在执行之前篡改文件来使脚本更“安全”。 为了运行该脚本,PowerShell必须从stdin中读取它,因为如果脚本无法获得独占访问权限,则不会运行脚本。 调用看起来像这样: powershell.exe -Command – < C:\temp\some_name.ps1 这有一些缺点,主要是我不能将parameter passing给脚本。 此外,从标准input读取大脚本获取时髦与坏字符,线返回等。 我想用更传统的方法调用脚本,例如 powershell.exe -File C:\temp\some_name.ps1 -Param value … 而且还要坚持在执行之前,确保没有任何东西可以篡改脚本。 为此,我想签署PowerShell脚本并运行“AllSigned”执行策略的PowerShell。 问题在于我无法在目标服务器上真正签名脚本,因为它与运行脚本的PowerShell有相同的问题…我必须释放独占锁才能让PowerShell签署文件,但是它可能会得到篡改。 然后我决定,如果我可以在服务器上签署脚本,将脚本发送到目标机器上,效果会更好。 但是,我们的configurationpipe理软件服务器都是Linux,而我一直在努力寻找一些在Linux上签署PowerShell脚本的方法。 Mono支持Authenticode,但开箱即用,只适用于exes和dll。 我已经尝试挖掘到PowerShell .Netfunction,但发现他们使用Cryptui.dll,这是Windows特定的。 在这一点上,我总是抓住签名添加到脚本中,否则我将不得不采取其他方式来运行不是真正的本地脚本。 如果可能的话,我希望能够在脚本的string表示中计算内存中的签名,但是如果这是我所能得到的,我将采用基于文件的方法。
我使用bash,并且已经这么做了十多年 – 但偶尔我会怀疑Linux shell的世界是否有任何重大的新发展。 几年前,微软发布了PowerShell,这看起来很有趣。 Linux shell中是否有类似的创新?
据我所读的MS文档, Get-ADTrust适用于Windows 8.1,Windows PowerShell 4.0,Windows Server 2012 R2。 这让我感到困惑,它可以安装在Windows 8.1或WP 4.0或WS 2012 R2? 目前,我尝试在WS 2008 R2上运行它,它给了我错误: Get-ADTrust:术语“Get-ADTrust”不被识别为cmdlet的名称, function,脚本文件或可操作的程序。 检查名称的拼写,或 如果包含path,请validationpath是否正确,然后重试。 在行:1 char:1 + Get-ADTrust + ~~~~~~~~~~~ + CategoryInfo:ObjectNotFound:(get-adtrust:String)[],CommandNotFoundException + FullyQualifiedErrorId:CommandNotFoundException 有没有办法进入WS 2008 R2?
我正在尝试使用Start-Job cmdlet并行地运行多个作业。 我有大量的环境设置被忽略,因为开始作业在新的会话中运行作业。 有没有办法维护环境设置。 我希望它基本上叉。
当我想从非pipe理员 Visual Studio 2015 Update 3(Win 7)执行powershell脚本时: 它似乎被组策略设置(输出窗口的结果)阻止: 1> This program is blocked by group policy. For more information, contact your … 如果我的Visual Studio以pipe理员模式运行,一切正常。 事情是,在pipe理和非pipe理模式下,PowerShell安装似乎是相同的 : 32位版本: 我也试图直接绕过这个政策: 甚至试图将执行策略设置放入test.ps1脚本本身: 没有什么帮助(使用混合版本) – 组策略阻止PowerShell。 如何理解正在发生的事情,并可能解决这个问题?