PS C:\> cat D:\test.cmd
@echo %1 %2 %3 %4 >d:\111
PS C:\> ([WMICLASS]"\\localhost\ROOT\CIMV2:win32_process").Create("d:\test.cmd /sALL /rs /msi EULA_ACCEPT=YES")
__GENUS : 2
__CLASS : __PARAMETERS
__SUPERCLASS :
__DYNASTY : __PARAMETERS
__RELPATH :
__PROPERTY_COUNT : 2
__DERIVATION : {}
__SERVER :
__NAMESPACE :
__PATH :
ProcessId : 20280
ReturnValue : 0
PSComputerName :
PS C:\> cat D:\111
/sALL /rs /msi EULA_ACCEPT
Get-NetAdapter
в powershell это то же самое что Get-NetAdapter | Write-Output
, аналог C# - yield Get-NetAdapter
Get-NetAdapter; Get-NetAdapter
вернёт массив, например@{
ModuleVersion = '1.0'
GUID = '72d739dd-bddf-4d7c-a358-1a40e2ff961d'
Description = 'test module'
NestedModules = @('testmodule.psm1')
}
function get-tf1 {
'tf1'
}
WindowsPowerShell/
Modules/
Scripts/
Microsoft.PowerShell_profile.ps1
$home = Split-Path $profile
$env:Path += (";{0}\Scripts" -f $home)
pomoika/
assorted/
pomoika.psd1 (содержимое опущено)
pomoika.pm1:
Try {
Get-ChildItem "$PSScriptRoot\assorted\*.ps1" -Exclude *.tests.ps1, *profile.ps1 | ForEach-Object {
$Function = $_.Name
. $_.FullName
}
} Catch {
Write-Warning ("{0}: {1}" -f $Function,$_.Exception.Message)
Continue
}
консоль в VSCode.
Get-PSDrive | Select-Object *
- без двоеточия в концеforeach (var prop in obj.Properties)
{
Console.WriteLine("{0,20}: {1}", prop.Name, prop.Value);
}
Aliases created by using New-Alias are not saved after you exit the session or close Windows PowerShell. You can use the Export-Alias cmdlet to save your alias information to a file. You can later use Import-Alias to retrieve that saved alias information.
смог перехватить ошибки вот так