Skip to content

Commit cacc160

Browse files
committed
More options, ADMX change, installer change, lang gpo
1 parent 72e4302 commit cacc160

33 files changed

+602
-112
lines changed

admx/adm/LazyAdmin.adm

Lines changed: 0 additions & 26 deletions
This file was deleted.

build/Start-ParamProcess.ps1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#https://nsis.sourceforge.io/PowerShell_support
2+
3+
[CmdletBinding()]
4+
param (
5+
[Parameter()]
6+
$Ar
7+
)
8+
$Ar | Out-File "C:\share\pwsh.txt" -Append

build/installer.nsh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
; References: https://nsis.sourceforge.io/Docs/AppendixE.html https://nsis.sourceforge.io/Docs/Chapter4.html
2+
!include ${PROJECT_DIR}\build\psexec.nsh
23

34
!macro preInit
45

56
!define regkey "Software\LazyAdmin"
67
!define masterdefinitionkey "MasterDefinitionUrl"
8+
!define customlanguagekey "CustomLanguageUrl"
79

810
!define exampleMasterDefinition "https://raw.githubusercontent.com/houby-studio/lazy-admin/master/scripts-definitions/master-definition-example.json"
911

@@ -17,10 +19,20 @@
1719
${EndIf}
1820
; Check if URL parameter was set and write to registry, otherwise skip
1921
${GetParameters} $R0
22+
;InitPluginsDir
23+
;SetOutPath "$PLUGINSDIR\PowerShell"
24+
;File "${PROJECT_DIR}\build\Start-ParamProcess.ps1"
25+
;${PowerShellExecFileLog} "$PLUGINSDIR\PowerShell\Start-ParamProcess.ps1 -Ar '$R0'"
2026
${GetOptions} $R0 `/URL=` $R1
2127
IfErrors 0 +2
2228
Goto +2
2329
WriteRegStr HKLM "${regkey}" "${masterdefinitionkey}" $R1
30+
; Check if LANGURL parameter was set and write to registry, otherwise skip
31+
${GetParameters} $R0
32+
${GetOptions} $R0 `/LANGURL=` $R1
33+
IfErrors 0 +2
34+
Goto +2
35+
WriteRegStr HKLM "${regkey}" "${customlanguagekey}" $R1
2436
${endIf}
2537

2638
!macroend

build/psexec.nsh

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
!ifndef PSEXEC_INCLUDED
2+
!define PSEXEC_INCLUDED
3+
4+
!macro PowerShellExecMacro PSCommand
5+
InitPluginsDir
6+
;Save command in a temp file
7+
Push $R1
8+
FileOpen $R1 $PLUGINSDIR\tempfile.ps1 w
9+
FileWrite $R1 "${PSCommand}"
10+
FileClose $R1
11+
Pop $R1
12+
13+
!insertmacro PowerShellExecFileMacro "$PLUGINSDIR\tempfile.ps1"
14+
!macroend
15+
16+
!macro PowerShellExecLogMacro PSCommand
17+
InitPluginsDir
18+
;Save command in a temp file
19+
Push $R1
20+
FileOpen $R1 $PLUGINSDIR\tempfile.ps1 w
21+
FileWrite $R1 "${PSCommand}"
22+
FileClose $R1
23+
Pop $R1
24+
25+
!insertmacro PowerShellExecFileLogMacro "$PLUGINSDIR\tempfile.ps1"
26+
!macroend
27+
28+
!macro PowerShellExecFileMacro PSFile
29+
!define PSExecID ${__LINE__}
30+
Push $R0
31+
32+
nsExec::ExecToStack 'powershell -inputformat none -ExecutionPolicy RemoteSigned -File "${PSFile}" '
33+
34+
Pop $R0 ;return value is first on stack
35+
;script output is second on stack, leave on top of it
36+
IntCmp $R0 0 finish_${PSExecID}
37+
SetErrorLevel 2
38+
39+
finish_${PSExecID}:
40+
Exch ;now $R0 on top of stack, followed by script output
41+
Pop $R0
42+
!undef PSExecID
43+
!macroend
44+
45+
!macro PowerShellExecFileLogMacro PSFile
46+
!define PSExecID ${__LINE__}
47+
Push $R0
48+
49+
nsExec::ExecToLog 'powershell -inputformat none -ExecutionPolicy RemoteSigned -File "${PSFile}" '
50+
Pop $R0 ;return value is on stack
51+
IntCmp $R0 0 finish_${PSExecID}
52+
SetErrorLevel 2
53+
54+
finish_${PSExecID}:
55+
Pop $R0
56+
!undef PSExecID
57+
!macroend
58+
59+
!define PowerShellExec `!insertmacro PowerShellExecMacro`
60+
!define PowerShellExecLog `!insertmacro PowerShellExecLogMacro`
61+
!define PowerShellExecFile `!insertmacro PowerShellExecFileMacro`
62+
!define PowerShellExecFileLog `!insertmacro PowerShellExecFileLogMacro`
63+
64+
!endif

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,4 @@
5151
"browserslist": [
5252
"last 1 version, not dead, ie >= 11"
5353
]
54-
}
54+
}
5.52 KB
Binary file not shown.

admx/README.md renamed to policies/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ Alternatively if installing on local computer copy to C:\Windows\PolicyDefinitio
1818
Yes, we are lazy admins too, so we store command to migrate ADM to ADMX in git repo to save time.
1919
It may be useful to you if you need to modify our policies.
2020

21-
`"%PROGRAMFILES(x86)%\FullArmor\ADMX Migrator\faAdmxConv.exe" "C:\git\lazy-admin\admx\adm\LazyAdmin.adm" "C:\git\lazy-admin\admx"`
21+
`"%PROGRAMFILES(x86)%\FullArmor\ADMX Migrator\faAdmxConv.exe" "C:\git\lazy-admin\policies\adm\LazyAdmin.adm" "C:\git\lazy-admin\policies\admx"`

policies/adm/LazyAdmin.adm

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
;Configure Lazy Admin application
2+
;Created by Houby-Studio
3+
;Last Update 2020-08-29
4+
;ADMX Migrator: https://www.microsoft.com/en-us/download/details.aspx?id=15058
5+
;After making changes, run command
6+
;"%PROGRAMFILES(x86)%\FullArmor\ADMX Migrator\faAdmxConv.exe" "{pathToAdm}\LazyAdmin.adm" "{pathToAdmx}"
7+
CLASS MACHINE
8+
9+
CATEGORY "Lazy Admin"
10+
POLICY !!MasterDefinitionUrlPolicy
11+
KEYNAME "Software\LazyAdmin"
12+
SUPPORTED !!MasterDefinitionUrlSupported
13+
EXPLAIN !!MasterDefinitionUrlExplain
14+
PART !!MasterDefinitionUrlPathText TEXT
15+
END PART
16+
PART "Url:" EDITTEXT REQUIRED
17+
VALUENAME "MasterDefinitionUrl"
18+
END PART
19+
END POLICY
20+
POLICY !!CustomLanguageUrlPolicy
21+
KEYNAME "Software\LazyAdmin"
22+
SUPPORTED !!CustomLanguageUrlSupported
23+
EXPLAIN !!CustomLanguageUrlExplain
24+
PART !!CustomLanguageUrlPathText TEXT
25+
END PART
26+
PART "Url:" EDITTEXT REQUIRED
27+
VALUENAME "CustomLanguageUrl"
28+
END PART
29+
END POLICY
30+
END CATEGORY
31+
32+
[strings]
33+
MasterDefinitionUrlPolicy="Scripts Definition URL"
34+
MasterDefinitionUrlPathText="Specify full URL path to your definitions file."
35+
MasterDefinitionUrlSupported="Windows Vista and above"
36+
MasterDefinitionUrlExplain="Full URL Path to scripts definition in JSON format for Lazy Admin.\n\nExample: https://raw.githubusercontent.com/houby-studio/lazy-admin/master/scripts-definitions/definition-lazy-admin-base.json\n\nExample: \\fileserver.local\share\definition-lazy-admin-base.json\n\nNote: You should create your own definitions file and point your administrators to it to use all your company's PowerShell Cmdlets in Lazy Admin.\n\nIf you enable this policy, the URL you specify will be used by Lazy Admin to download latest definitions.\n\nIf you disable this policy, Lazy Admin won't be able to download any definitions.\n\nIf you do not configure this policy, user has to configure definitions URL manually or use default example URL.\n\nYou can read more about Lazy Admin policies by visiting the following URL: https://github.com/houby-studio/lazy-admin/wiki"
37+
CustomLanguageUrlPolicy="Custom Language URL"
38+
CustomLanguageUrlPathText="Specify full URL path to your custom translation file."
39+
CustomLanguageUrlSupported="Windows Vista and above"
40+
CustomLanguageUrlExplain="Full URL Path to custom translation in JSON format for Lazy Admin.\n\nExample: https://raw.githubusercontent.com/houby-studio/lazy-admin/master/src/i18n/custom-language.json\n\nExample: \\fileserver.local\share\custom-language.json\n\nNote: You should create your translation file if you want to use language, which is not provided with Lazy Admin. Feel free to provide us with your translation and we will include it in next version.\n\nIf you enable this policy, the URL you specify will be used by Lazy Admin to download custom translation.\n\nIf you disable or do not configure this policy, Lazy Admin won't download custom languages.\n\nYou can read more about Lazy Admin custom translation by visiting the following URL: https://github.com/houby-studio/lazy-admin/wiki"

admx/LazyAdmin.admx renamed to policies/admx/LazyAdmin.admx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<policyDefinitions revision="1.0" schemaVersion="1.0">
33
<policyNamespaces>
4-
<target prefix="fullarmor" namespace="FullArmor.97b05ae5-486a-4252-90d2-76fdd32b4233" />
4+
<target prefix="fullarmor" namespace="FullArmor.97e185f4-faf3-4141-891f-450c67c9bf59" />
55
<using prefix="windows" namespace="Microsoft.Policies.Windows" />
66
</policyNamespaces>
7-
<supersededAdm fileName="LazyAdmin.adm" />
7+
<supersededAdm fileName="C:\git\lazy-admin\admx\adm\LazyAdmin.adm" />
88
<resources minRequiredRevision="1.0" />
99
<supportedOn>
1010
<definitions>
1111
<definition name="MasterDefinitionUrlSupported" displayName="$(string.MasterDefinitionUrlSupported)" />
12+
<definition name="CustomLanguageUrlSupported" displayName="$(string.CustomLanguageUrlSupported)" />
1213
<definition name="SUPPORTED_NotSpecified" displayName="$(string.ADMXMigrator_NoSupportedOn)" />
1314
</definitions>
1415
</supportedOn>
@@ -23,5 +24,12 @@
2324
<text id="Url" valueName="MasterDefinitionUrl" required="true" />
2425
</elements>
2526
</policy>
27+
<policy name="CustomLanguageUrlPolicy" class="Machine" displayName="$(string.CustomLanguageUrlPolicy)" explainText="$(string.CustomLanguageUrlExplain)" presentation="$(presentation.CustomLanguageUrlPolicy)" key="Software\LazyAdmin">
28+
<parentCategory ref="LazyAdmin" />
29+
<supportedOn ref="CustomLanguageUrlSupported" />
30+
<elements>
31+
<text id="Url" valueName="CustomLanguageUrl" required="true" />
32+
</elements>
33+
</policy>
2634
</policies>
2735
</policyDefinitions>

admx/cs-CZ/LazyAdmin.adml renamed to policies/admx/cs-CZ/LazyAdmin.adml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,21 @@ Pokud nastavení této zásady zakážete, Lazy Admin nebude schopen žádné de
2121

2222
Pokud nastavení této zásady nenakonfigurujete, uživatel bude muset URL vyplnit manuálně nebo se použije ukázková URL.
2323

24+
O aplikaci Lazy Admin se můžete dočíst více na URL adrese: https://github.com/houby-studio/lazy-admin/wiki</string>
25+
<string id="CustomLanguageUrlPolicy">URL vlastního jazyka</string>
26+
<string id="CustomLanguageUrlPathText">Zadejte plnou URL cestu k souboru s vlastním překladem.</string>
27+
<string id="CustomLanguageUrlSupported">Minimálně Windows Vista</string>
28+
<string id="CustomLanguageUrlExplain">Plná URL Cesta k vlastními překladu ve formátu JSON pro Lazy Admina.
29+
30+
Příklad: https://raw.githubusercontent.com/houby-studio/lazy-admin/master/src/i18n/custom-language.json
31+
Příklad: \\fileserver.local\share\custom-language.json
32+
33+
Poznámka: Vytvořit vlastní soubor překladů můžete v případě, pokud chcete používat jazyk, který není součástí Lazy Admina. Pokud vytvoříte nějaký překlad, zašlete nám jej prosím a my jej zahrneme v další verzi.
34+
35+
Pokud nastavení této zásady povolíte, zadaná URL adresa bude použita aplikací Lazy Admin ke stažení vlastního překladu.
36+
37+
Pokud nastavení této zásady zakážete nebo nenakonfigurujete, Lazy Admin nestáhne žádné vlastní překlady.
38+
2439
O aplikaci Lazy Admin se můžete dočíst více na URL adrese: https://github.com/houby-studio/lazy-admin/wiki</string>
2540
<string id="ADMXMigrator_UnresolvedString">ADMX Migrator encountered a string that is not present in the source ADM string table.</string>
2641
<string id="ADMXMigrator_NoSupportedOn">ADMX Migrator encountered a policy that does not have a supportedOn value.</string>
@@ -32,6 +47,12 @@ O aplikaci Lazy Admin se můžete dočíst více na URL adrese: https://github.c
3247
<label>Url:</label>
3348
</textBox>
3449
</presentation>
50+
<presentation id="CustomLanguageUrlPolicy">
51+
<text>Zadejte plnou URL cestu k vašemu souboru s vlastním překladem.</text>
52+
<textBox refId="Url">
53+
<label>Url:</label>
54+
</textBox>
55+
</presentation>
3556
</presentationTable>
3657
</resources>
3758
</policyDefinitionResources>

admx/en-US/LazyAdmin.adml renamed to policies/admx/en-US/LazyAdmin.adml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,21 @@ If you disable this policy, Lazy Admin won't be able to download any definitions
2222
If you do not configure this policy, user has to configure definitions URL manually or use default example URL.
2323

2424
You can read more about Lazy Admin policies by visiting the following URL: https://github.com/houby-studio/lazy-admin/wiki</string>
25+
<string id="CustomLanguageUrlPolicy">Custom Language URL</string>
26+
<string id="CustomLanguageUrlPathText">Specify full URL path to your custom translation file.</string>
27+
<string id="CustomLanguageUrlSupported">Windows Vista and above</string>
28+
<string id="CustomLanguageUrlExplain">Full URL Path to custom translation in JSON format for Lazy Admin.
29+
30+
Example: https://raw.githubusercontent.com/houby-studio/lazy-admin/master/src/i18n/custom-language.json
31+
Example: \\fileserver.local\share\custom-language.json
32+
33+
Note: You should create your translation file if you want to use language, which is not provided with Lazy Admin. Feel free to provide us with your translation and we will include it in next version.
34+
35+
If you enable this policy, the URL you specify will be used by Lazy Admin to download custom translation.
36+
37+
If you disable or do not configure this policy, Lazy Admin won't download custom languages.
38+
39+
You can read more about Lazy Admin custom translation by visiting the following URL: https://github.com/houby-studio/lazy-admin/wiki</string>
2540
<string id="ADMXMigrator_UnresolvedString">ADMX Migrator encountered a string that is not present in the source ADM string table.</string>
2641
<string id="ADMXMigrator_NoSupportedOn">ADMX Migrator encountered a policy that does not have a supportedOn value.</string>
2742
</stringTable>
@@ -32,6 +47,12 @@ You can read more about Lazy Admin policies by visiting the following URL: https
3247
<label>Url:</label>
3348
</textBox>
3449
</presentation>
50+
<presentation id="CustomLanguageUrlPolicy">
51+
<text>Specify full URL path to your custom translation file.</text>
52+
<textBox refId="Url">
53+
<label>Url:</label>
54+
</textBox>
55+
</presentation>
3556
</presentationTable>
3657
</resources>
3758
</policyDefinitionResources>

scripts-definitions/base-module-example.json

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
{
22
"base-module-example": {
3-
"version": "0.1.9",
3+
"version": "0.2.0",
44
"icon": "mdi-powershell",
55
"displayName": {
66
"default": "Base commands",
77
"en-us": "Base commands",
8-
"cs-cz": "Základní příkazy"
8+
"cs-cz": "Základní příkazy",
9+
"de-de": "Basisbefehle"
910
},
1011
"description": {
1112
"default": "General purpose commands",
1213
"en-us": "General purpose commands",
13-
"cs-cz": "Příkazy pro obecné použití"
14+
"cs-cz": "Příkazy pro obecné použití",
15+
"de-de": "Allzweckbefehle"
1416
},
1517
"definition": [
1618
{
@@ -491,12 +493,20 @@
491493
"login": [
492494
{
493495
"name": "Az",
494-
"description": "Azure PowerShell Module",
496+
"description": {
497+
"default": "Azure PowerShell module",
498+
"en-us": "Azure PowerShell module",
499+
"cs-cz": "Azure PowerShell modul"
500+
},
495501
"commandBlock": "Connect-AzAccount"
496502
},
497503
{
498504
"name": "Test",
499-
"description": "Test PowerShell Module",
505+
"description": {
506+
"default": "Test login, doesn't really log to any service.",
507+
"en-us": "Test login, doesn't really log to any service.",
508+
"cs-cz": "Testovací přihlášení, nikam se nepřihlašuje."
509+
},
500510
"commandBlock": "Get-Location"
501511
}
502512
],

src/boot/components.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import ResultsDialog from 'components/ResultsDialog.vue'
99
import ExecuteDialog from 'components/ExecuteDialog.vue'
1010
import CommandDialog from 'components/CommandDialog.vue'
1111
import ScriptsTable from 'components/ScriptsTable.vue'
12+
import LanguagePicker from 'components/LanguagePicker.vue'
1213

1314
// add components to Vue
1415
export default async ({ Vue }) => {
@@ -22,4 +23,5 @@ export default async ({ Vue }) => {
2223
Vue.component('ExecuteDialog', ExecuteDialog)
2324
Vue.component('CommandDialog', CommandDialog)
2425
Vue.component('ScriptsTable', ScriptsTable)
26+
Vue.component('LanguagePicker', LanguagePicker)
2527
}

src/boot/i18n.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ import messages from 'src/i18n'
55
Vue.use(VueI18n)
66

77
const i18n = new VueI18n({
8-
language: 'cs-cz',
8+
language: 'en-us',
99
fallbackLocale: 'en-us',
10-
messages
10+
messages,
11+
silentTranslationWarn: true
1112
})
1213

1314
export default ({ app, store }) => {

src/boot/utils.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,25 @@ const utils = {
4646
}
4747
})
4848
},
49-
downloadDefinitions (downloadUrl, done) {
49+
getRegLanguage (done) {
50+
// Attempt to retrieve registry value containing custom language url
51+
regedit.list('HKLM\\SOFTWARE\\LazyAdmin', function (err, result) {
52+
if (err) {
53+
return done(Error('Custom language fetch failed. Could not locate LazyAdmin registry hive.'))
54+
}
55+
try {
56+
let langUrl = result['HKLM\\SOFTWARE\\LazyAdmin'].values['CustomLanguageUrl'].value
57+
if (langUrl) {
58+
return done(null, langUrl)
59+
} else {
60+
return done(Error('Custom language fetch failed. CustomLanguageUrl registry key has no value.'))
61+
}
62+
} catch {
63+
return done(Error('Custom language update failed. Could not read CustomLanguageUrl registry key value.'))
64+
}
65+
})
66+
},
67+
downloadUrl (downloadUrl, done) {
5068
if (fs.existsSync(downloadUrl)) {
5169
fs.readFile(downloadUrl, { encoding: 'utf-8' }, function (e, data) {
5270
if (e) {

0 commit comments

Comments
 (0)