$params = @{
Param1 = "value1"
}
if ($something) { $params.Param2 = "*value" }
MyFunction @params
Function Get-OtherCompProcess {
Param(
#здесь все обычные параметры для get-process кроме computername
)}
$PSBoundParameters.computername='othercomp'
Get-Process @PSBoundParameters
function Switch-Item {
param ([switch]$on)
if ($on) { "Switch on" }
else { "Switch off" }
}
MyUtils/
MyUtils.psd1
MyUtils.psm1
functions/
Get-Something.ps1
Get-SomethingOther.ps1
@{
ModuleVersion = '1.0'
GUID = '72d739dd-bddf-4d7c-a358-1a40e2ff961d'
Description = 'MyUtils module'
NestedModules = @('MyUtils.psm1')
}
Try {
Get-ChildItem "$PSScriptRoot\functions\*.ps1" -Exclude *.tests.ps1, *profile.ps1 |
ForEach-Object {
$Function = $_.Name
. $_.FullName
}
} Catch {
Write-Warning ("{0}: {1}" -f $Function,$_.Exception.Message)
Continue
}
function Get-Something {
param(
$parameter
)
Write-Host "I'm Get-Something with $parameter"
}
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\SOFTWARE\Classes\runapp]
"URL Protocol"=""
@="URL:Universal run app"
[HKEY_CURRENT_USER\SOFTWARE\Classes\runapp\shell]
[HKEY_CURRENT_USER\SOFTWARE\Classes\runapp\shell\open]
[HKEY_CURRENT_USER\SOFTWARE\Classes\runapp\shell\open\command]
@="mshta javascript:new(ActiveXObject)('WScript.Shell').Run(decodeURI('%1'.substr(7))),window.close()"
<a href="runapp:notepad C:\\Users\\User\\Desktop\\test.txt">Открыть test.txt</a>
Выучил основы языка, но правильной архитектуре приложений очень мало где учат.
data: () => ({
selected: [],
}),
methods: {
key: (x, y) => `${y}.${x}`,
select({ buttons, target: { dataset: { key } } }) {
if (buttons) {
const index = this.selected.indexOf(key);
if (index !== -1) {
this.selected.splice(index, 1);
} else {
this.selected.push(key);
}
}
},
},
<table>
<tr v-for="y in 10">
<td
v-for="x in 10"
@mousedown="select"
@mouseover="select"
:data-key="key(x, y)"
:class="{ selected: selected.includes(key(x, y)) }"
>{{ key(x, y) }}</td>
</tr>
</table>
data: () => ({
items: [...Array(10)].map(() => Array(10).fill(false)),
}),
methods: {
select(row, index, e) {
if (e.buttons) {
this.$set(row, index, !row[index]);
}
},
},
<table>
<tr v-for="(row, y) in items">
<td
v-for="(cell, x) in row"
@mousedown="select(row, x, $event)"
@mouseover="select(row, x, $event)"
:class="{ selected: cell }"
>{{ y + 1 }}.{{ x + 1 }}</td>
</tr>
</table>