Open Perrypackettracer opened 7 months ago
Certainly! Here are the PowerShell scripts for tasks 26 to 30:
# PowerShell script for DHCP lease cleanup
# Set DHCP server IP address
$DHCPServer = "YourDHCPServer"
# Get and remove expired DHCP leases
Get-DhcpServerv4Lease -ComputerName $DHCPServer | Where-Object { $_.LeaseExpiry -lt (Get-Date) } | Remove-DhcpServerv4Lease
# PowerShell script for SSL certificate installation
# Set certificate details
$CertPath = "C:\Path\To\Certificate.pfx"
$CertPassword = "YourCertPassword"
# Install SSL certificate
Import-PfxCertificate -FilePath $CertPath -CertStoreLocation Cert:\LocalMachine\My -Password (ConvertTo-SecureString $CertPassword -AsPlainText -Force)
# PowerShell script for Windows Update management
# Check for and install available updates
Install-Module PSWindowsUpdate -Force -Confirm:$false
Get-WindowsUpdate -Install -AcceptAll -Force
# PowerShell script for Task Scheduler configuration
# Set task details
$TaskName = "YourTaskName"
$ScriptPath = "C:\Path\To\YourScript.ps1"
$TriggerTime = (Get-Date).AddHours(1)
# Create a new scheduled task
$action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-File $ScriptPath"
$trigger = New-ScheduledTaskTrigger -At $TriggerTime -Once
Register-ScheduledTask -Action $action -Trigger $trigger -TaskName $TaskName
# PowerShell script for logon script configuration
# Set logon script details
$ScriptPath = "\\FileServer\Scripts\LogonScript.ps1"
# Configure logon script for all users
Set-GPRegistryValue -Name "LogonScriptGPO" -Key "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run" -ValueName "LogonScript" -Type String -Value $ScriptPath
Certainly! Here are the PowerShell scripts for tasks 31 to 40:
# PowerShell script for DHCP lease cleanup
# Set DHCP server IP address
$DHCPServer = "YourDHCPServer"
# Get and remove expired DHCP leases
Get-DhcpServerv4Lease -ComputerName $DHCPServer | Where-Object { $_.LeaseExpiry -lt (Get-Date) } | Remove-DhcpServerv4Lease
# PowerShell script for SSL certificate installation
# Set certificate details
$CertPath = "C:\Path\To\Certificate.pfx"
$CertPassword = "YourCertPassword"
# Install SSL certificate
Import-PfxCertificate -FilePath $CertPath -CertStoreLocation Cert:\LocalMachine\My -Password (ConvertTo-SecureString $CertPassword -AsPlainText -Force)
# PowerShell script for Windows Update management
# Check for and install available updates
Install-Module PSWindowsUpdate -Force -Confirm:$false
Get-WindowsUpdate -Install -AcceptAll -Force
# PowerShell script for Task Scheduler configuration
# Set task details
$TaskName = "YourTaskName"
$ScriptPath = "C:\Path\To\YourScript.ps1"
$TriggerTime = (Get-Date).AddHours(1)
# Create a new scheduled task
$action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-File $ScriptPath"
$trigger = New-ScheduledTaskTrigger -At $TriggerTime -Once
Register-ScheduledTask -Action $action -Trigger $trigger -TaskName $TaskName
# PowerShell script for logon script configuration
# Set logon script details
$ScriptPath = "\\FileServer\Scripts\LogonScript.ps1"
# Configure logon script for all users
Set-GPRegistryValue -Name "LogonScriptGPO" -Key "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run" -ValueName "LogonScript" -Type String -Value $ScriptPath
# PowerShell script for local user account management
# Set user details
$Username = "LocalUser"
$Password = "LocalPassword"
# Create a new local user
New-LocalUser -Name $Username -Password (ConvertTo-SecureString -AsPlainText $Password -Force) -PasswordNeverExpires $true
# PowerShell script for file integrity monitoring
# Set file and hash details
$FilePath = "C:\Path\To\File.txt"
$ExpectedHash = "YourExpectedHash"
# Calculate the hash of the file
$ActualHash = Get-FileHash -Path $FilePath -Algorithm SHA256
# Compare hashes
if ($ActualHash.Hash -eq $ExpectedHash) {
Write-Host "File integrity is intact."
} else {
Write-Host "File integrity is compromised!"
}
# PowerShell script for Group Policy updates
# Force Group Policy update
gpupdate /force
# PowerShell script for Remote Desktop Gateway configuration
# Set RD Gateway server details
$RDGatewayServer = "YourRDGatewayServer"
# Configure RD Gateway settings
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Terminal Server Gateway" -Name "RdGateway" -Value $RDGatewayServer
# PowerShell script for IIS website deployment
# Set website details
$WebsiteName = "YourWebsite"
$PhysicalPath = "C:\Path\To\Website"
# Create a new IIS website
New-WebSite -Name $WebsiteName -PhysicalPath $PhysicalPath -Port 80
Certainly! Here are the PowerShell scripts for tasks 41 to 50:
# PowerShell script for Active Directory group membership management
# Set group and user details
$GroupName = "YourGroup"
$Username = "YourUser"
# Add user to group
Add-ADGroupMember -Identity $GroupName -Members $Username
# PowerShell script for Azure resource management
# Set Azure resource details
$ResourceGroupName = "YourResourceGroup"
$ResourceName = "YourResourceName"
# Start an Azure resource
Start-AzResource -ResourceGroupName $ResourceGroupName -Name $ResourceName
# PowerShell script for PowerShell script execution policies
# Set execution policy
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine
# PowerShell script for Remote Desktop Gateway configuration
# Set RD Gateway server details
$RDGatewayServer = "YourRDGatewayServer"
# Configure RD Gateway settings
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Terminal Server Gateway" -Name "RdGateway" -Value $RDGatewayServer
# PowerShell script for IIS website deployment
# Set website details
$WebsiteName = "YourWebsite"
$PhysicalPath = "C:\Path\To\Website"
# Create a new IIS website
New-WebSite -Name $WebsiteName -PhysicalPath $PhysicalPath -Port 80
# PowerShell script for disk cleanup
# Run built-in Disk Cleanup utility
Start-Process -FilePath "cleanmgr.exe" -ArgumentList "/sagerun:1" -Wait
# PowerShell script for remote desktop session management
# Set user and session details
$Username = "YourUsername"
$SessionID = 1
# Disconnect or log off a specific remote desktop session
# Disconnect: Stop-RemoteDesktopSession -SessionId $SessionID
# Log Off: Stop-RemoteDesktopSession -SessionId $SessionID -LogOff
# PowerShell script for Azure AD synchronization
# Trigger Azure AD synchronization
Start-ADSyncSyncCycle -PolicyType Delta
# PowerShell script for DNS record updates
# Set DNS record details
$RecordName = "YourRecordName"
$RecordType = "A"
$IPAddress = "192.168.1.3"
# Update DNS record
Set-DnsServerResourceRecord -ZoneName "yourdomain.com" -Name $RecordName -Type $RecordType -A -IPv4Address $IPAddress
# PowerShell script for security group management
# Set security group and user details
$GroupName = "YourSecurityGroup"
$Username = "YourUsername"
# Add user to security group
Add-ADGroupMember -Identity $GroupName -Members $Username
Adapt these scripts according to your specific environment and requirements. Always test thoroughly in a safe environment before deploying in production.
Here are the first 5 PowerShell scripts for the mentioned tasks:
1. User Account Creation:
2. Folder/File Backups:
3. Windows Update Status Reporting:
4. Print Server Configuration:
5. Event Log Archiving:
Certainly! Here are the scripts for tasks 6 to 10:
6. Service Restart:
7. Certificate Renewals:
8. File System Permissions:
9. Registry Modifications:
10. Network Configuration Changes:
Certainly! Here are the PowerShell scripts for tasks 11 to 15:
11. Active Directory Cleanup:
12. Print Queue Management:
13. Database Maintenance:
14. Email Notification:
15. Folder Redirection:
Certainly! Here are the PowerShell scripts for tasks 16 to 20:
16. Windows Firewall Rules:
17. Task Scheduler Cleanup:
18. Scheduled Reboots:
19. Disk Cleanup:
20. Remote Desktop Session Management:
Certainly! Here are the PowerShell scripts for tasks 21 to 25:
21. Azure AD Sync:
22. DNS Record Updates:
23. Backup Verification:
24. Azure VM Scaling:
25. Security Group Management: