: Function WP_Styles::add was called incorrectly. The style with the handle "hello-elementor-child-style" was enqueued with dependencies that are not registered: hello-elementor-theme-style. Please see Debugging in WordPress for more information. (This message was added in version 6.9.1.) in /home/csrkub/domains/cube-vps.com/public_html/wp-includes/functions.php on line 6131
Notice: Function WP_Scripts::add was called incorrectly. The script with the handle "gpress-custom-js" was enqueued with dependencies that are not registered: gpress-siema. Please see Debugging in WordPress for more information. (This message was added in version 6.9.1.) in /home/csrkub/domains/cube-vps.com/public_html/wp-includes/functions.php on line 6131
*Cube-Host– full cloud services!!
PowerShell is a powerful automation and management tool for system administrators. It allows you to run scripts, control services, users, events, and interact with external systems and APIs. This guide will show you how to use PowerShell for real-world tasks, step by step.
Allow scripts to run by executing:
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
Create a file named Hello.ps1 and paste the following:
Write-Host "Hello, PowerShell automation!"
Get-Date
$env:USERNAME
Run the script with the command:
.Hello.ps1
PowerShell is based on a clear and concise structure:
Use the PowerShell ISE editor or Visual Studio Code with the PowerShell extension for highlighting and autocompletion.
We recommend following these principles:
param([int]$Threshold = 80)
$mem = Get-CimInstance Win32_OperatingSystem |
Select @{Name='FreeGB'; Expression={[math]::Round($_.FreePhysicalMemory/1MB,2)}}
if ($mem.FreeGB -lt $Threshold) {
Write-Warning "Memory low: $($mem.FreeGB) GB"
} else {
Write-Host "Memory OK: $($mem.FreeGB) GB"
}
The script checks whether there is enough free memory and displays a warning if there is not enough.
You can run PowerShell scripts on a schedule:
Specify:
powershell.exe -ExecutionPolicy Bypass -File "C:ScriptsHello.ps1"
Local users:
$pass = Read-Host -AsSecureString "Введите пароль"
New-LocalUser -Name "TestUser" -Password $pass -FullName "Тестовый пользователь"
Disable-LocalUser -Name "TestUser"
Remove-LocalUser -Name "TestUser"
Active Directory (with CSV file):
Import-Csv users.csv | ForEach-Object {
New-ADUser -Name $_.Name -SamAccountName $_.Login `
-AccountPassword (ConvertTo-SecureString $_.Password -AsPlainText -Force) -Enabled $true
}
Get-WinEvent -LogName System -MaxEvents 10 |
Format-Table TimeCreated, Id, Message
Filtering:
Get-WinEvent -FilterHashtable @{LogName='Application'; Id=1000; StartTime=(Get-Date).AddDays(-1)}
Export to CSV:
... | Export-Csv "C:Logsapp.csv" -NoTypeInformation
$src = "C:Important"
$dst = "D:BackupBackup_$(Get-Date -Format 'yyyyMMdd').zip"
Compress-Archive -Path "$src*" -DestinationPath $dst
Add-Content "D:Backupbackup_log.txt" "Backup: $(Get-Date) → $dst"
This script creates an archive from a folder and logs the backup.
Send-MailMessage -From "admin@domain.com" -To "team@company.com" `
-Subject "Backup report" -Body "Backup completed successfully." `
-SmtpServer "smtp.domain.com" -Attachments "D:Backup*.zip"
Example for GitHub Actions:
- name: Run PowerShell script
run: pwsh ./monitor.ps1
PowerShell is not just a shell, but a universal automation tool. Real-world examples of backing up, deleting old files, and running programs help you quickly grasp the basics. Important: Always test scripts with the -WhatIf parameter or in a test environment to avoid unwanted changes.