我已经读过,在C#中,我们无法在远程计算机上创建专用队列: 无法在远程服务器上创建专用消息队列
我的问题是:在PowerShell脚本中,我们可以这样做吗?这是我的示例脚本:
echo "Loading System.Messaging..."
[Reflection.Assembly]::LoadWithPartialName( "System.Messaging" )
$msmq = [System.Messaging.MessageQueue]
echo "Create the queue"
$qName = "remoteserver\private$\testqueue"
if($msmq::Exists($qName))
{
echo ($qName + " already exists ")
}
else
{
echo ($qName + " doesn't exists and now to create ......")
$q = $msmq::Create( $qName, $TRUE )
echo "Private queues has been created"
}
Run Code Online (Sandbox Code Playgroud)
它说"无效的队列路径名称".我也尝试过一些格式:FormatName:DIRECT=OS:remoteserver\private$\testqueue
结果是一样的.任何可能性?
我目前正在制作一个脚本,该脚本应该连接到 42 个不同的本地服务器,并从活动目录获取特定组的用户(fj\xc3\xa4rrskrivbordsanv\xc3\xa4ndare(瑞典语远程桌面用户:D))。从服务器获取所有用户后,它必须将用户导出到我的桌面上的文件中
\n\ncsv 文件必须如下所示:
\n\nCompany;Users\nLawyerSweden;Mike\nLawyerSweden;Jennifer\nStockholm Candymakers;Pedro\n(Examples) \netc.\nRun Code Online (Sandbox Code Playgroud)\n\n这是目前的代码:
\n\ncls\n\n$MolnGroup = \'fj\xc3\xa4rrskrivbordsanv\xc3\xa4ndare\' \n$ActiveDirectory = \'activedirectory\' \n$script:CloudArray\nSet-Variable -Name OutputAnvandare -Value ($null) -Scope Script\nSet-Variable -Name OutputDomain -Value ($null) -Scope Script\n\nfunction ReadInfo {\n\nWrite-Host("A")\n\nGet-Variable -Exclude PWD,*Preference | Remove-Variable -EA 0\n\nif (Test-Path "C:\\file\\frickin\\path.txt") {\n\n Write-Host("File found")\n\n}else {\n\n Write-Host("Error: File not found, filepath might be invalid.")\n Exit\n}\n\n\n$filename = "C:\\File\\Freakin\'\\path\\super.txt"\n$Headers = "IPAddress", "Username", "Password", "Cloud"\n\n$Importedcsv = Import-csv $filename -Delimiter ";" -Header $Headers\n\n$PasswordsArray += @($Importedcsv.password)\n$AddressArray = @($Importedcsv | ForEach-Object { $_.IPAddress } )\n$UsernamesArray += …Run Code Online (Sandbox Code Playgroud) powershell scope powershell-2.0 powershell-remoting powershell-3.0
我是否正确当我在远程服务器上有一个加载某些功能的配置文件时,这些功能应该在远程PSSession中可用?
我的测试没有成功,是否有一个特殊的技巧让这个工作?
我想在网络共享上引用文件夹,以便在单个源上提供所有功能.
我收到此脚本的无效路径错误:
$buildZIP= 'starmatic'
echo $buildZIP
$command = ”\\XXXXXXXXXX\L$\Gopi_Prod_App\ToZipNew.ps1 $buildZIP”
Invoke-Expression -Command $command
Run Code Online (Sandbox Code Playgroud)
这是ToZipNew.ps1:
Param(
[Parameter(Position=1, Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string]$build
)
echo "$build"
$S = "L:\Gopi_Prod_App\$build\App_Data\*"
$D = "\Gopi_Prod_App\Starmatic_UI.zip"
echo $S
echo $D
Get-ChildItem "$S" | Compress-Archive -DestinationPath "$D" -Verbose
#Compress-Archive -Path "$S" -CompressionLevel Fastest -DestinationPath "$D"
Run Code Online (Sandbox Code Playgroud)
我得到的错误:
Compress-Archive:路径“ L:\ Gopi_Prod_App”不存在或不存在
有效的文件系统路径。
位于\\ XXXXXXXXXXX \ L $ \ Gopi_Prod_App \ ToZipNew.ps1:13 char:45
+ ... t-ChildItem“ $ S” | 压缩存档-DestinationPath“ $ D”-详细
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo:InvalidArgument:(L:\ Gopi_Prod_App:String)[Compress-Archive],InvalidOperationException
+ FullyQualifiedErrorId:ArchiveCmdletPathNotFound,压缩存档
使用 PowerShell 远程处理(Invoke-Command例如使用 cmdlet)时,需要身份验证方案。
选项包括 Kerberos、CredSSP、NTLM 和 Negotiate。
它们之间有什么区别?我应该用什么?
安装 HyperV 并出现
vEthernet(默认交换机)后,Hyper-V 虚拟以太网适配器
命令
Enable-PSRemoting(或 Set-WSManQuickConfig)
会引发异常:
et-WSManQuickConfig : <f:WSManFault xmlns:f="http://schemas.microsoft.com/wbem/wsman/1/wsmanfault" Code="2150859113" Machine="localhost"><f:Message><f:ProviderFault provider="Config provider" path="%systemroot%\system32
\WsmSvc.dll"><f:WSManFault xmlns:f="http://schemas.microsoft.com/wbem/wsman/1/wsmanfault" Code="2150859113" Machine="*******"><f:Message>WinRM firewall exception will not work since one of the network connection types
on this machine is set to Public. Change the network connection type to either Domain or Private and try again. </f:Message></f:WSManFault></f:ProviderFault></f:Message></f:WSManFault>
At line:1 char:1
+ Set-WSManQuickConfig
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Set-WSManQuickConfig], InvalidOperationException
+ FullyQualifiedErrorId : WsManError,Microsoft.WSMan.Management.SetWSManQuickConfigCommand
Run Code Online (Sandbox Code Playgroud)
禁用虚拟交换机可以使命令正常工作。
为什么会出现这种情况?可以解决吗?
操作系统:Windows 10;PS版本 - 5.1.18362.145
我正在尝试验证远程计算机是否可以连接到特定端口上的另一台计算机
伪代码
$RemoteSession = New-PSSession -ComputerName MyRemoteVM
Invoke-Command -Session $RemoteSession -ScriptBlock {$RsTestResults = New-Object System.Net.Sockets.TcpClient -Argument 2ndRemoteVM , 2ndRemoteVMPort}
Run Code Online (Sandbox Code Playgroud)
但是,我似乎无法获得该测试的结果,我尝试添加另一个 Invoke-Command,如下所示,但这没有帮助
$LocalResults = Invoke-Command -ScriptBlock {$RsTestResults}
Run Code Online (Sandbox Code Playgroud)
有什么想法吗?