Set the value of the LocalAccountTokenFilterPolicy registry entry to 1.
For example, the following command uses the New-ItemProperty cmdlet and the Windows PowerShell Registry Provider to create the LocalAccountTokenFilterPolicy registry entry on the local computer and set its value to 1.
new-itemproperty -name LocalAccountTokenFilterPolicy -path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -propertyType DWord -value 1
#читаем список всех компов
$all=Import-csv xxx
#проходим по списку в поисках живых где неустановлено
foreach ($comp in $all) {
# проверяем всякие условия
if (-not $comp.installed -and
(test-connection $comp.name) -and
(-not (test-path ....)) { #можно еще условий добавить
#install
Invoke-command -computername $comp.name {
#тут команды установки
# никаких повторных invoke-command и powershell НЕ надо
}
.....
#ставим флаг что установлено
$comp.installed=$true
}
}
#экспортируем обратно в csv с установленными флагами
$all | export-csv xxx
Adb devices | select-object -skip 1 | foreach-object -parallel {
$id=$_ -replace '\s+device'
Adb -s $id install some.apk
}
$fields = 'object1','object2','object3','object4','object5','object6'
$data = 'name object quantity
name1 object1 1
name1 object5 10
name1 object2 5
name2 object2 1
name2 object3 4' -split "`r`n" | ConvertFrom-Csv -Delimiter ' '
foreach($d in ($data | Group-Object -Property name)) {
$o = [ordered]@{ name = $d.name }
$name_data = $d.Group | Group-Object -Property object -AsHashTable
foreach ($field in $fields) {
if ($name_data.ContainsKey($field)) {
$o[$field] = $name_data[$field].quantity
}
else {
$o[$field] = 0
}
}
[PSCustomObject]$o
}
name : name1
object1 : 1
object2 : 5
object3 : 0
object4 : 0
object5 : 10
object6 : 0
name : name2
object1 : 0
object2 : 1
object3 : 4
object4 : 0
object5 : 0
object6 : 0
get-localuser | export-csv -delimiter ';' -encoding utf8 -notypeinformation -path d:\путь_к_файлу.csv
import-csv -delimiter ';' -encoding utf8 -path d:\путь_к_файлу.csv |
foreach-object {
$pass = New-Object System.Management.Automation.PSCredential 'a', ($_.password | ConvertTo-SecureString - AsPlainText -Force)
new-localuser -Name $_.Name -Password $pass.password ..... # тут другие нужные параметры
}
@echo off
@powershell.exe -ExecutionPolicy Bypass -Command "$fn = \"%~f0\"; $_=((Get-Content $fn) -join \"`n\");iex $_.Substring($_.IndexOf(\"goto :\"+\"EOF\")+9)"
@goto :EOF
Start-Process microsoft-edge:https://yoomoney.ru/moneylandia/lootboxes
Start-Sleep 5
Get-Process -Name "*msedge*" | Stop-Process
echo "$fn completed!"
pause
Get-Help Get-ADUser -Parameter Identity
Get-PnpDevice |
Where {$_.HardwareID -notmatch 'PRINTENUM*|ROOT*|SW*|ACPIAPIC*|MONITOR*'} |
Foreach { $_.HardwareID | Select -first 1 }
invoke-command -comp $comp {
# а здесь все красоты
# причём циклом
$source @(
@{ key name= '''; valuename=''},
@{ key name= '''; valuename=''}
)
foreach ($src in $source) {
get-itemproperty -path $src.keyname | select -expandproperty $src.valuename
}
}
$bits = (Get-WmiObject win32_operatingsystem).OSArchitecture -replace '\D+'
$filename = "C:\Admins\Add\BGInfo\Bginfo" + (if ($bits -eq '64) { '64' } else { '' } ) + ".exe"
$filename = "C:\Admins\Add\BGInfo\Bginfo" + @{'64'=64; '32'=32 }[$bits] + ".exe"
if (test-path $filename) .....