mirror of
https://git.ecdf.ed.ac.uk/win_automation/windows-ansible.git
synced 2026-10-29 20:26:51 +00:00
simplifing process
This commit is contained in:
1 parent
e14096aac4
commit
8f2a04e82e
4 files changed
+6
-73
No files matched your search
@@ -1,28 +0,0 @@
|
|||||||
$bashProfilePath = Join-Path $HOME ".bash_profile"
|
|
||||||
|
|
||||||
$condaPath = "C:\tools\miniforge3\Scripts\conda.exe"
|
|
||||||
|
|
||||||
$requiredLine = 'eval "$(''/C/tools/miniforge3/Scripts/conda.exe'' ''shell.bash'' ''hook'')"'
|
|
||||||
|
|
||||||
if (Test-Path $condaPath) {
|
|
||||||
Write-Host "Miniforge3 is installed at $condaPath"
|
|
||||||
|
|
||||||
if (Test-Path $bashProfilePath) {
|
|
||||||
$currentContent = Get-Content -Path $bashProfilePath -ErrorAction SilentlyContinue
|
|
||||||
|
|
||||||
if ($currentContent -contains $requiredLine) {
|
|
||||||
Write-Host "The required line is already present in .bash_profile"
|
|
||||||
} else {
|
|
||||||
Add-Content -Path $bashProfilePath -Value $requiredLine
|
|
||||||
Write-Host "The required line has been added to .bash_profile"
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Set-Content -Path $bashProfilePath -Value $requiredLine -Force
|
|
||||||
Write-Host ".bash_profile created with the required line"
|
|
||||||
}
|
|
||||||
|
|
||||||
Set-ItemProperty -Path $bashProfilePath -Name Attributes -Value ([System.IO.FileAttributes]::Hidden)
|
|
||||||
Write-Host ".bash_profile is set to hidden"
|
|
||||||
} else {
|
|
||||||
Write-Host "Miniforge3 is not installed. Exiting."
|
|
||||||
}
|
|
||||||
@@ -412,12 +412,7 @@ New-GPLink -Name "Chrome" -Target $workbenchou
|
|||||||
#New-GPLink -Name "firewall" -Target $workbenchou
|
#New-GPLink -Name "firewall" -Target $workbenchou
|
||||||
|
|
||||||
#Logon Script Reg Keys
|
#Logon Script Reg Keys
|
||||||
Import-Module GroupPolicy
|
New-ItemProperty -Path "Registry::HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce" -Name "CreateBashProfile" -Value "powershell.exe -ExecutionPolicy Bypass -File C:\eidf\logon.ps1" -PropertyType String
|
||||||
if (!(Get-GPLink -Name "User Logon Script" -Target "OU=YourOU,DC=yourdomain,DC=local" -ErrorAction SilentlyContinue)) {
|
|
||||||
New-GPLink -Name "User Logon Script" -Target "OU=YourOU,DC=yourdomain,DC=local"
|
|
||||||
}
|
|
||||||
Set-GPRegistryValue -Name "User Logon Script" -Key "HKCU\Environment" -ValueName "LogonScript" -Type String -Value "C:\\eidf\\logon.ps1"
|
|
||||||
Set-GPRegistryValue -Name "User Logon Script" -Key "HKLM\Software\Policies\Microsoft\Windows\PowerShell" -ValueName "ExecutionPolicy" -Type String -Value "Unrestricted"
|
|
||||||
|
|
||||||
#add entry for WSUS
|
#add entry for WSUS
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
$bashProfilePath = Join-Path $HOME ".bash_profile"
|
||||||
|
$requiredLine = 'eval "$(''/C/tools/miniforge3/Scripts/conda.exe'' ''shell.bash'' ''hook'')"'
|
||||||
|
|
||||||
|
Add-Content -Path $bashProfilePath -Value $requiredLine
|
||||||
|
Set-ItemProperty -Path $bashProfilePath -Name Attributes -Value ([System.IO.FileAttributes]::Hidden)
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
---
|
|
||||||
- name: Set Reg Keys
|
|
||||||
tags:
|
|
||||||
- logon
|
|
||||||
block:
|
|
||||||
- name: Configure Windows Logon Script via GPO
|
|
||||||
tasks:
|
|
||||||
- name: Create a new Group Policy Object (GPO)
|
|
||||||
ansible.windows.win_shell:
|
|
||||||
command: |
|
|
||||||
Import-Module GroupPolicy
|
|
||||||
if (!(Get-GPO -Name "User Logon Script" -ErrorAction SilentlyContinue)) {
|
|
||||||
New-GPO -Name "User Logon Script" -Domain "yourdomain.local"
|
|
||||||
}
|
|
||||||
ignore_errors: true
|
|
||||||
|
|
||||||
- name: Link GPO to Organizational Unit (OU)
|
|
||||||
ansible.windows.win_shell:
|
|
||||||
command: |
|
|
||||||
Import-Module GroupPolicy
|
|
||||||
if (!(Get-GPLink -Name "User Logon Script" -Target "OU=YourOU,DC=yourdomain,DC=local" -ErrorAction SilentlyContinue)) {
|
|
||||||
New-GPLink -Name "User Logon Script" -Target "OU=YourOU,DC=yourdomain,DC=local"
|
|
||||||
}
|
|
||||||
|
|
||||||
- name: Configure the logon script in GPO
|
|
||||||
ansible.windows.win_shell:
|
|
||||||
command: |
|
|
||||||
Import-Module GroupPolicy
|
|
||||||
Set-GPRegistryValue -Name "User Logon Script" -Key "HKCU\Environment" -ValueName "LogonScript" -Type String -Value "C:\\eidf\\logon.ps1"
|
|
||||||
|
|
||||||
- name: Allow PowerShell scripts to execute
|
|
||||||
ansible.windows.win_shell:
|
|
||||||
command: |
|
|
||||||
Import-Module GroupPolicy
|
|
||||||
Set-GPRegistryValue -Name "User Logon Script" -Key "HKLM\Software\Policies\Microsoft\Windows\PowerShell" -ValueName "ExecutionPolicy" -Type String -Value "Unrestricted"
|
|
||||||
|
|
||||||
- name: Force Group Policy update on clients
|
|
||||||
ansible.windows.win_command:
|
|
||||||
command: gpupdate /Force
|
|
||||||
Reference in new issue
Block a user