Начиная с Java 5 вы можете использовать Arrays.toString(arr)
или Arrays.deepToString(arr)
для массивов внутри массивов. Обратите внимание, что версия Object[]
вызывает .toString()
для каждого объекта в массиве.
Примеры:
String[] array = new String[] {"John", "Mary", "Bob"};
System.out.println(Arrays.toString(array));
Выход:
[John, Mary, Bob]
String[][] deepArray = new String[][] {{"John", "Mary"}, {"Alice", "Bob"}};
System.out.println(Arrays.toString(deepArray));
//output: [[Ljava.lang.String;@106d69c, [Ljava.lang.String;@52e922]
System.out.println(Arrays.deepToString(deepArray));
Выход:
[[John, Mary], [Alice, Bob]]
double
Массив: double[] doubleArray = { 7.0, 9.0, 5.0, 1.0, 3.0 };
System.out.println(Arrays.toString(doubleArray));
Выход:
[7.0, 9.0, 5.0, 1.0, 3.0 ]
int
Массив: int[] intArray = { 7, 9, 5, 1, 3 };
System.out.println(Arrays.toString(intArray));
Выход:
[7, 9, 5, 1, 3 ]
Вы можете попробовать использовать .net:
$Reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $computer1)
$RegKey= $Reg.OpenSubKey("SOFTWARE\\Veritas\\NetBackup\\CurrentVersion")
$NetbackupVersion1 = $RegKey.GetValue("PackageVersion")
Если вам нужен идентификатор пользователя SID и удаленная папка HKEY_USERS, вы можете следовать этому сценарию:
<# Replace following domain.name with yours and userAccountName with remote username #>
$userLogin = New-Object System.Security.Principal.NTAccount(“domain.name“,”userAccountName“)
$userSID = $userLogin.Translate([System.Security.Principal.SecurityIdentifier])
<# We will open HKEY_USERS and with accurate user’s SID from remoteComputer #>
$remoteRegistry = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey(‘Users’,”remoteComputer“)
<# We will then retrieve LocalName value from Control Panel / International subkeys #>
$key = $userSID.value+”\Control Panel\International”
$openKey = $remoteRegistry.OpenSubKey($key)
<# We can now retrieve any values #>
$localName = $openKey.GetValue(‘LocaleName’)
Источник: http://techsultan.com/how-to-browse-remote -registry-в-PowerShell /
Для удаленного реестра вы должны использовать .NET с powershell 2.0
$w32reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine',$computer1)
$keypath = 'SOFTWARE\Veritas\NetBackup\CurrentVersion'
$netbackup = $w32reg.OpenSubKey($keypath)
$NetbackupVersion1 = $netbackup.GetValue('PackageVersion')
Если у вас есть дистанционное управление Powershell и настройка CredSSP, вы можете обновить свой код до следующего:
$Session = New-PSSession -ComputerName $Computer1 -Authentication CredSSP
$NetbackupVersion1 = Invoke-Command -Session $Session -ScriptBlock { $(Get-ItemProperty hklm:\SOFTWARE\Veritas\NetBackup\CurrentVersion).PackageVersion}
Remove-PSSession $Session
Попробуйте Remote Registry Module , поставщик реестра не может работать удаленно:
Import-Module PSRemoteRegistry
Get-RegValue -ComputerName $Computer1 -Key SOFTWARE\Veritas\NetBackup\CurrentVersion -Value PackageVersion
другой вариант ... требуется удалять ...
(invoke-command -ComputerName mymachine -ScriptBlock {Get-ItemProperty HKLM:\SOFTWARE\VanDyke\VShell\License -Name Version }).version
Использование модуля python и wmi.
import wmi
conn = wmi.WMI('172.20.58.34', user='UserName', password='Password')
command = r'cmd /c reg query "HKLM\SOFTWARE\Microsoft" /ve > C:\output.txt'
conn.Win32_Process.Create(CommandLine=command)
Подробнее $ reg /? в командной строке.