-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathImport-StartLayoutSetting.ps1
More file actions
81 lines (66 loc) · 2.53 KB
/
Import-StartLayoutSetting.ps1
File metadata and controls
81 lines (66 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
function Import-StartLayoutSetting {
<#
.SYNOPSIS
Import start layout settings file.
.DESCRIPTION
Import start layout settings file.
.PARAMETER Path
Accepts a single xml file.
.PARAMETER LogPath
Path of the logfile you want it to log to. Default is C:\Temp.
.INPUTS
Description of objects that can be piped to the script.
.OUTPUTS
Description of objects that are output by the script.
.EXAMPLE
Import-StartLayoutSetting -Path "\\server\path\taskbartest.xml"
.LINK
Links to further documentation.
.NOTES
Detail on what the script does, if this is needed.
#>
[CmdletBinding()]
param (
[Parameter(Mandatory=$false,
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true)]
[ValidateNotNullOrEmpty()]
[ValidateScript( {
if (-Not ($_ | Test-Path) ) {
throw "File does not exist"
}
if (-Not ($_ | Test-Path -PathType Leaf) ) {
throw "The path argument must be a file. Folder paths are not allowed."
}
if ($_ -notmatch "(\.xml)") {
throw "The file specified in the path argument must be .xml"
}
return $true
})]
[string]$Path,
[Parameter(Mandatory=$false,
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true)]
[ValidateNotNullOrEmpty()]
[String]$LogPath = "C:\Temp"
)
begin {
if (!("PSLogger" -as [type])) {
$callingSCript = ($MyInvocation.MyCommand.Name) -split('.ps1')
."\\Server\Path\Here\Logging.ps1"
$logger = [PSLogger]::new($logPath,$callingScript)
}
$logger.Notice("Starting $($MyInvocation.MyCommand) script")
$winProductName = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name ProductName).ProductName
}
process {
if (($winProductName -like "*10 Pro*" -or $winProductName -like "*10 enterprise*") -and $env:username -like "Some NonDomain User*") {
Write-Output "Importing Start Menu Layout..."
$logger.informational("Importing Start Menu Layout...")
Import-StartLayout -LayoutPath $Path -MountPath "C:\"
}
}
end {
$logger.Notice("Finished $($MyInvocation.MyCommand) script")
}
}