Compare commits
No commits in common. "c64f3f1bb71470a0cfe57b5b48d6c00b4877cf31" and "7d7c775044485a7a8f0c995a417142588a5f0a30" have entirely different histories.
c64f3f1bb7
...
7d7c775044
|
@ -10,12 +10,12 @@ Positional parameters:
|
||||||
[2] b - backup
|
[2] b - backup
|
||||||
r - restore
|
r - restore
|
||||||
|
|
||||||
Administrator rights are not required for restore and required for backup.
|
Administrator rights are not required
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
|
||||||
:Start
|
:Start
|
||||||
set workingdir="%USERPROFILE%\AppData\Roaming\1C\1CEStart"
|
set workingdir="%USERPROFILE%\AppData\Roaming\1C\1CEStart"
|
||||||
set archivedir="%SYSTEMDRIVE%\Users\Default\AppData\Roaming\1C\1CEStart"
|
set archivedir="D:\settings"
|
||||||
set choice=%~2
|
set choice=%~2
|
||||||
|
|
||||||
:Set_Choice
|
:Set_Choice
|
||||||
|
|
83
README.md
83
README.md
|
@ -1,22 +1,14 @@
|
||||||
# Tweaks for Windows
|
# Tweaks for Windows
|
||||||
|
|
||||||
Tools for managing Windows setting
|
Tools for managing Windows setting
|
||||||
|
|
||||||
* [`hvswitch`.cmd](https://git.hmp.today/pavel.muhortov/tweaks-for-windows#hvswitch-cmd)
|
* [`hvswitch`.cmd](https://git.hmp.today/pavel.muhortov/tweaks-for-windows#hvswitch-cmd)
|
||||||
* [`rdpusers`.cmd](https://git.hmp.today/pavel.muhortov/tweaks-for-windows#rdpusers-cmd)
|
* [`rdpusers`.cmd](https://git.hmp.today/pavel.muhortov/tweaks-for-windows#rdpusers-cmd)
|
||||||
* [`1cibases`.cmd](https://git.hmp.today/pavel.muhortov/tweaks-for-windows#1cibases-cmd)
|
* [`1cibases`.cmd](https://git.hmp.today/pavel.muhortov/tweaks-for-windows#1cibases-cmd)
|
||||||
* [`dfs-set-active`.ps1](https://git.hmp.today/pavel.muhortov/tweaks-for-windows#dfs-set-active-ps1)
|
|
||||||
|
|
||||||
____
|
____
|
||||||
|
|
||||||
## `hvswitch`.cmd
|
## `hvswitch`.cmd
|
||||||
|
**Description:** Microsoft Hyper-V switch on/off
|
||||||
**Description:**
|
**Dependencies:** Windows (tested version 10.0.19043)
|
||||||
> Microsoft Hyper-V switch on/off
|
|
||||||
|
|
||||||
**Dependencies:**
|
|
||||||
>
|
|
||||||
> * Windows (tested version 10.0.19043)
|
|
||||||
|
|
||||||
| POSITION | PARAMETERS | DESCRIPTION | DEFAULT |
|
| POSITION | PARAMETERS | DESCRIPTION | DEFAULT |
|
||||||
|-----------|--------------|------------------------|---------------|
|
|-----------|--------------|------------------------|---------------|
|
||||||
|
@ -24,88 +16,41 @@ ____
|
||||||
| 2 | **[y]** |enable Hyper-V, if it off| `None` |
|
| 2 | **[y]** |enable Hyper-V, if it off| `None` |
|
||||||
| 2 | **[n]** |disable Hyper-V, if it on| `None` |
|
| 2 | **[n]** |disable Hyper-V, if it on| `None` |
|
||||||
|
|
||||||
Example usage in terminal:
|
|
||||||
|
|
||||||
|
Example usage in terminal:
|
||||||
```cmd
|
```cmd
|
||||||
.\hvswitch.cmd qn y
|
.\hvswitch.cmd qn y
|
||||||
```
|
```
|
||||||
|
|
||||||
____
|
____
|
||||||
|
|
||||||
## `rdpusers`.cmd
|
## `rdpusers`.cmd
|
||||||
|
**Description:** RDS Shadow Connection
|
||||||
|
**Dependencies:** Windows (tested version 6.3.9600), permission on target hostname (*gpedit.msc -> Computer Configuration -> Policies -> Administrative Templates -> Windows components -> Remote Desktop Services -> Remote Session Host -> Connections -> Set rules for remote control of Remote Desktop Services user sessions: Full Control without users's permission*)
|
||||||
|
|
||||||
**Description:**
|
|
||||||
> RDS Shadow Connection
|
|
||||||
|
|
||||||
**Dependencies:**
|
|
||||||
>
|
|
||||||
> * Windows (tested version 6.3.9600)
|
|
||||||
> * permission on target hostname (*gpedit.msc -> Computer Configuration -> Policies -> Administrative Templates -> Windows components -> Remote Desktop Services -> Remote Session Host -> Connections -> Set rules for remote control of Remote Desktop Services user sessions: Full Control without users's permission*)
|
|
||||||
|
|
||||||
| POSITION | PARAMETERS | DESCRIPTION | DEFAULT |
|
| POSITION | PARAMETERS | DESCRIPTION | DEFAULT |
|
||||||
|-----------|--------------|------------------------|---------------|
|
|-----------|--------------|------------------------|---------------|
|
||||||
| 1 | **[host]** |hostname or address with sessions for connect|`None`|
|
| 1 | **[host]** |hostname or address with sessions for connect| `None` |
|
||||||
|
|
||||||
|
|
||||||
Example usage in terminal:
|
Example usage in terminal:
|
||||||
|
|
||||||
```cmd
|
```cmd
|
||||||
.\rdpusers.cmd ts.domain.local
|
.\rdpusers.cmd ts.domain.local
|
||||||
```
|
```
|
||||||
|
|
||||||
____
|
____
|
||||||
|
|
||||||
## `1cibases`.cmd
|
## `1cibases`.cmd
|
||||||
|
**Description:** 1CEStart backup/restore settings
|
||||||
**Description:**
|
**Dependencies:** Windows (tested version 6.3.9600); launch method if automation is needed (*gpedit.msc -> User Configuration -> Administrative Templates -> System -> Logon -> Run these programs at user logon: C:\Windows\System32\GroupPolicy\User\Scripts\Logon\1cibases.cmd qn r)
|
||||||
> 1CEStart backup/restore settings
|
|
||||||
|
|
||||||
**Dependencies:**
|
|
||||||
>
|
|
||||||
> * Windows (tested version 6.3.9600)
|
|
||||||
> * privileged rights (only for backup)
|
|
||||||
|
|
||||||
| POSITION | PARAMETERS | DESCRIPTION | DEFAULT |
|
| POSITION | PARAMETERS | DESCRIPTION | DEFAULT |
|
||||||
|-----------|--------------|------------------------|---------------|
|
|-----------|--------------|------------------------|---------------|
|
||||||
| 1 | **[qn]** |execution without pauses| `None` |
|
| 1 | **[qn]** |execution without pauses| `None` |
|
||||||
| 2 | **[b]** |restore | `None` |
|
| 2 | **[b]** |restore| `None` |
|
||||||
| 2 | **[r]** |backup | `None` |
|
| 2 | **[r]** |backup| `None` |
|
||||||
|
|
||||||
### `1cibases`.cmd setup
|
|
||||||
|
|
||||||
1\. Create and edit `%SYSTEMDRIVE%\Users\Default\AppData\Roaming\1C\1CEStart\ibases.v8i` manually or by backup your settings running ```.\1cibases.cmd qn b``` as Administrator. New user profiles will have this `ibases.v8i`.
|
Example usage in terminal:
|
||||||
|
```cmd
|
||||||
2\. Only if you need to rewrite user changes at their logon:
|
.\1cibases.cmd qn r
|
||||||
>
|
|
||||||
> * Create `%SYSTEMDRIVE%\Windows\System32\GroupPolicy\User\Scripts\Logon\1cibases.cmd`
|
|
||||||
> * gpedit.msc -> User Configuration -> Administrative Templates -> System -> Logon -> Run these programs at user logon: `%SYSTEMDRIVE%\Windows\System32\GroupPolicy\User\Scripts\Logon\1cibases.cmd qn r`.
|
|
||||||
|
|
||||||
____
|
|
||||||
|
|
||||||
## `dfs-set-active`.ps1
|
|
||||||
|
|
||||||
**Description:**
|
|
||||||
> Set active server for used DFS namespaces.
|
|
||||||
|
|
||||||
**Dependencies:**
|
|
||||||
>
|
|
||||||
> * Windows (tested versions 6.1.7601, 10.0.19045, 10.0.22621)
|
|
||||||
> * privileged rights
|
|
||||||
|
|
||||||
| POSITION | PARAMETERS | DESCRIPTION | DEFAULT |
|
|
||||||
|-----------|--------------|------------------------|---------------|
|
|
||||||
| 1 | **-child** |internal execute switch | `false` |
|
|
||||||
|
|
||||||
### `dfs-set-active`.ps1 setup
|
|
||||||
|
|
||||||
1\. Create config file.
|
|
||||||
|
|
||||||
```powershell
|
|
||||||
@"
|
|
||||||
\\domain.local\dfs_namespace_1\share_dir_1:\\server_1.domain.local\share_dir_1
|
|
||||||
\\domain.local\dfs_namespace_2\share_dir_2:\\server_2.domain.local\share_dir_2
|
|
||||||
"@ | Out-File $env:\Windows\System32\GroupPolicy\Machine\Scripts\Startup\dfs-set-active.cfg -Encoding "UTF8"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
2\. Create startup script.
|
|
||||||
|
|
||||||
gpedit.msc -> Computer Settings -> Policies -> Windows Settings -> Scripts (Startup/Shutdown) -> Startup -> PowerShell Scripts: `%SYSTEMDRIVE%\Windows\System32\GroupPolicy\Machine\Scripts\Startup\dfs-set-active.ps1`.
|
|
||||||
|
|
|
@ -1,100 +0,0 @@
|
||||||
param(
|
|
||||||
[Parameter(Mandatory=$false,Position=0)][switch]$child
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
function Get-PSVersion {
|
|
||||||
if (Test-Path Variable:PSVersionTable) {
|
|
||||||
return $PSVersionTable.PSVersion.ToString()
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return "1.0.0.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function Test-AdminRights {
|
|
||||||
$currentUser = New-Object Security.Principal.WindowsPrincipal $([Security.Principal.WindowsIdentity]::GetCurrent())
|
|
||||||
return $currentUser.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
|
|
||||||
}
|
|
||||||
|
|
||||||
function Set-DFSActive {
|
|
||||||
foreach ($line in $(Get-Content -Path $Global:cfg)) {
|
|
||||||
$dfsLink = $line.Split(':')[0]
|
|
||||||
$smbPath = $line.Split(':')[1]
|
|
||||||
Set-Location "Microsoft.PowerShell.Core\FileSystem::$dfsLink"
|
|
||||||
Start-Process dfsutil.exe -ArgumentList "client","property","state","active","$dfsLink","$smbPath"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$Global:cfg = $MyInvocation.MyCommand.Path.Replace('.ps1', '.cfg')
|
|
||||||
|
|
||||||
|
|
||||||
if (!(Test-AdminRights)) {
|
|
||||||
if (!($child)) {
|
|
||||||
$params = New-Object System.Collections.ArrayList
|
|
||||||
foreach ($key in $MyInvocation.BoundParameters.Keys) {
|
|
||||||
[void]$params.Add("-$key")
|
|
||||||
[void]$params.Add($PSBoundParameters.$key)
|
|
||||||
}
|
|
||||||
Start-Process powershell.exe -Verb RunAs -ArgumentList (
|
|
||||||
"-NoProfile -File ""{0}"" -child $($params -join " ")" -f $($MyInvocation.MyCommand.Definition)
|
|
||||||
)
|
|
||||||
exit
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (!(Test-Path -Path "$env:SystemRoot\System32\dfsutil.exe")) {
|
|
||||||
try {
|
|
||||||
$system = $(Get-WmiObject -Class "Win32_OperatingSystem")
|
|
||||||
# Windows 11, 10, 2022, 2019, 2016, 8.1, 2012R2
|
|
||||||
if (($system.Version -like '10.0.*') -or ($system.Version -like '6.3.*')) {
|
|
||||||
# Workstation
|
|
||||||
if ($system.ProductType -like '1') {
|
|
||||||
$capability = "Rsat.FileServices.Tools"
|
|
||||||
if (!(Get-WindowsCapability -Name "*$capability*" -Online | Where-Object State -eq 'Installed' -ErrorAction Stop)) {
|
|
||||||
Get-WindowsCapability -Name "*$capability*" -Online | Add-WindowsCapability -Online -ErrorAction Stop
|
|
||||||
}
|
|
||||||
}
|
|
||||||
# DomainController, Server
|
|
||||||
if (($system.ProductType -like '2') -or ($system.ProductType -like '3')) {
|
|
||||||
$capability = "RSAT-DFS-Mgmt-Con"
|
|
||||||
if(!(Get-WindowsFeature -Name "*$capability*" | Where-Object InstallState -eq 'Installed' -ErrorAction Stop)) {
|
|
||||||
Get-WindowsFeature -Name "*$capability*" | Install-WindowsFeature -IncludeAllSubFeature -ErrorAction Stop
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
# Windows 7, 2008R2
|
|
||||||
if ($system.Version -like '6.1.*') {
|
|
||||||
# Workstation
|
|
||||||
if ($system.ProductType -like '1') {
|
|
||||||
if (!(Get-WmiObject -Class "Win32_QuickFixEngineering" | Where-Object { $_.HotFixID -like '*958830' })) {
|
|
||||||
if ($system.OSArchitecture -like '32*') {
|
|
||||||
Start-Process wusa.exe -ArgumentList "\\capital.local\sys\repo\distrib\microsoft\rsat\win7\Windows6.1-KB958830-x86.msu","/quiet","/norestart" -ErrorAction Stop -Wait
|
|
||||||
}
|
|
||||||
if ($system.OSArchitecture -like '64*') {
|
|
||||||
Start-Process wusa.exe -ArgumentList "\\capital.local\sys\repo\distrib\microsoft\rsat\win7\Windows6.1-KB958830-x64.msu","/quiet","/norestart" -ErrorAction Stop -Wait
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Start-Process dism.exe -ArgumentList "/Online","/Enable-Feature:RemoteServerAdministrationTools" -ErrorAction Stop -Wait
|
|
||||||
Start-Process dism.exe -ArgumentList "/Online","/Enable-Feature:RemoteServerAdministrationTools-Roles" -ErrorAction Stop -Wait
|
|
||||||
Start-Process dism.exe -ArgumentList "/Online","/Enable-Feature:RemoteServerAdministrationTools-Roles-FileServices" -ErrorAction Stop -Wait
|
|
||||||
Start-Process dism.exe -ArgumentList "/Online","/Enable-Feature:RemoteServerAdministrationTools-Roles-FileServices-Dfs" -ErrorAction Stop -Wait
|
|
||||||
}
|
|
||||||
# DomainController, Server
|
|
||||||
if (($system.ProductType -like '2') -or ($system.ProductType -like '3')) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch [System.Management.Automation.CommandNotFoundException] {
|
|
||||||
Write-Host "Powershell $(Get-PSVersion) need to update"
|
|
||||||
Start-Sleep 10
|
|
||||||
Exit 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!(Test-Path -Path "$($Global:cfg)")) {
|
|
||||||
Exit 1
|
|
||||||
}
|
|
||||||
Set-DFSActive
|
|
||||||
Exit 0
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user