MINISTRY OF DIGITAL TECHNOLOGIES OF THE
REPUBLIC OF UZBEKISTAN
TASHKENT UNIVERSITY OF INFORMATION TECHNOLOGIES
NAMED AFTER MUHAMMAD AL-KHWARIZMI
Practical task #2
By subject
“OPERATING SYSTEMS”
Completed by : Ruziboyev Diyorbek
Group : OPS401-2
Received by : Tahir Rabia
Tashkent – 2025
Task 1 & 2
Task 3
Script code #1
$folderPath = "C:\MyFolder"
$filePath = "$folderPath\MyFile.txt"
if (!(Test-Path -Path $folderPath)) {
New-Item -ItemType Directory -Path $folderPath
}
"PowerShell script created this file by Diyorbek." | Out-File -FilePath $filePath
Write-Output "Folder and file created successfully."
Task 4
Script code #2
} $folderPath = "C:\MyFolder"
$filePath = "$folderPath\MyFile.txt"
try {
# Papka mavjudligini tekshirish, yo‘q bo‘lsa yaratish
if (!(Test-Path -Path $folderPath)) {
New-Item -ItemType Directory -Path $folderPath -ErrorAction Stop
}
# Fayl yaratish va unga yozish
"PowerShell script created this file with error handling." | Out-File -FilePath
$filePath -ErrorAction Stop
Write-Output "Folder and file created successfully with error handling."
} catch {
Write-Output "An error occurred: $_"
}