ആശയം : ഏറ്റവും Powershell ചോദ്യങ്ങൾ.
നിങ്ങൾ പല രീതിയിൽ ഈ പട്ടിക ഉപയോഗിക്കാം :
- ഒരു സ്ക്രിപ്റ്റ് കയറി / പേസ്റ്റ് കമാൻഡുകൾ പകർത്താനും
- പെട്ടെന്ന് ഒരു പ്രത്യേക കമാൻഡ് സിന്റാക്സ് കാണുന്നതിന്
- നിങ്ങളുടെ സാങ്കേതിക ജ്ഞാനം മെച്ചപ്പെടുത്തുന്നതിന്
- പുതിയ കമാൻഡുകൾ കണ്ടെത്തുന്നതിനും
- ഒരു ജോലി അഭിമുഖത്തിൽ തയ്യാറാക്കുന്നതിനായി
പരിഷ്കരിച്ച |
ജൂലൈ 02, 2015
|
രചയിതാവ് | powershell-guru.com |
ഉറവിടം | malayalam.powershell-guru.com |
വിഭാഗങ്ങൾ |
75
|
ചോദ്യങ്ങൾ |
610
|
System
PowerShell എന്റെ പതിപ്പ് നിർണ്ണയിക്കാൻ എങ്ങനെ?
1 2 3 4 5 6 7 8 9 |
# via Powershell $PSVersionTable.PSVersion.Major # via Registry (Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\PowerShell\1\PowerShellEngine').PowerShellVersion # Versions 1 and 2 (Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine').PowerShellVersion # Versions 3 and 4 # via Remote Invoke-Command -ComputerName $computer -ScriptBlock { $PSVersionTable.PSVersion.Major } |
പിന്നാക്ക അനുയോജ്യത മറ്റൊരു പതിപ്പിൽ PowerShell പ്രവർത്തിപ്പിക്കുന്നതിന് എങ്ങനെ?
powershell.exe -Version 2.0
PowerShell ഒരു സ്ക്രിപ്റ്റ് ഒരു ചുരുങ്ങിയ PowerShell പതിപ്പ് (3.0 ഉയർന്ന) ആവശ്യമായ എങ്ങനെ?
#Requires -Version 3.0
PowerShell ഒരു സ്ക്രിപ്റ്റ് വേണ്ടി അഡ്മിനിസ്ട്രേറ്റീവ് അധികാരങ്ങൾ ആവശ്യമായ എങ്ങനെ?
1 2 3 4 5 |
# Solution 1 #Requires -RunAsAdministrator # Solution 2 [bool]((whoami.exe /all) -match 'S-1-16-12288') |
PowerShell ഒരു സ്ക്രിപ്റ്റ് പരാമീറ്ററുകളെപ്പറ്റിയുള്ള പരിശോധിക്കാൻ എങ്ങനെ?
help -Name .\Get-ExchangeEnvironmentReport.ps1 -Full
PowerShell കൂടെ നിലവിലുള്ള ഉപയോക്താവിന്റെ വിവരം എങ്ങനെ ലഭിക്കും?
[Security.Principal.WindowsIdentity]::GetCurrent()
എങ്ങനെ സൃഷ്ടിക്കാനും എഡിറ്റുചെയ്യാനും PowerShell ഒരു പ്രൊഫൈൽ റീലോഡ്?
1 2 3 4 5 6 7 8 9 |
# Create New-Item -Type file -Force $profile # Edit notepad.exe $profile # Reload (without restarting Powershell) & $profile .$profile |
PowerShell ഒരു സ്ക്രിപ്റ്റ് 5 സെക്കൻഡ് / മിനിറ്റ് ഒരു ആത്മബന്ധത്തിന് ചെയ്യാൻ എങ്ങനെ?
Start-Sleep -Seconds 5
Start-Sleep -Seconds 300 # 5 minutes
PowerShell കഴിഞ്ഞ ബൂട്ട് എങ്ങനെ ലഭിക്കും?
(Get-CimInstance -ClassName win32_operatingsystem).LastBootUpTime
PowerShell ഉപയോഗിച്ച് ടൈപ്പ് ത്വരിത എങ്ങനെ ലഭിക്കും?
1 |
[PSObject].Assembly.GetType('System.Management.Automation.TypeAccelerators')::Get.GetEnumerator() | Select-Object -Property @{Name='Key'; Expression={$_.Key}},@{name='Value'; Expression={$_.Value}} | Sort-Object -Property Key | Format-Table -AutoSize |
PowerShell ആരംഭിക്കുന്ന പരിപാടികൾ ലിസ്റ്റുചെയ്യുന്നതിന് എങ്ങനെ?
1 |
Get-WmiObject -Class Win32_StartupCommand | Sort-Object -Property Caption | Format-Table -Property Caption, Command, User -AutoSize |
PowerShell ഒരു അപ്ലിക്കേഷൻ അൺഇൻസ്റ്റാൾ എങ്ങനെ?
1 2 |
$application = Get-WmiObject -Query "SELECT * FROM Win32_Product WHERE Name LIKE 'HP Recovery Manager'" $application.Uninstall() |
പണിയിടമൊത്തമായുംവലുതാക്കുന്നു അല്ലെങ്കിൽ PowerShell ഒരു സജീവ ജാലകം ഒരു സ്ക്രീൻഷോട്ട് എടുത്തു എങ്ങനെ?
Take-ScreenShot -Screen -File 'C:\scripts\screenshot.png' -Imagetype JPEG
Repository : Take-ScreenShot
PowerShell കൂടെ MSMQ ക്യൂകൾ സന്ദേശം എണ്ണം എങ്ങനെ ലഭിക്കും?
1 |
Get-WmiObject -Class Win32_PerfRawData_MSMQ_MSMQQueue -ComputerName $computer | Format-Table -Property Name, MessagesInQueue -AutoSize |
PowerShell ഉപയോഗിച്ച് വധശിക്ഷ നയം സജ്ജമാക്കാൻ എങ്ങനെ?
1 2 3 4 5 6 7 8 9 10 11 |
# Restricted - No scripts can be run. Windows PowerShell can be used only in interactive mode. Set-ExecutionPolicy -ExecutionPolicy Restricted # AllSigned - Only scripts signed by a trusted publisher can be run. Set-ExecutionPolicy -ExecutionPolicy AllSigned # RemoteSigned - Downloaded scripts must be signed by a trusted publisher before they can be run. Set-ExecutionPolicy -ExecutionPolicy RemoteSigned # Unrestricted - No restrictions - All Windows PowerShell scripts can be run. Set-ExecutionPolicy -ExecutionPolicy Unrestricted |
PowerShell ഒരു കുറുക്കുവഴി സൃഷ്ടിക്കാൻ എങ്ങനെ?
1 2 3 4 |
$shell = New-Object -ComObject WScript.Shell $shortcut = $shell.Createshortcut("$HOME\Desktop\Procexp.lnk") $shortcut.TargetPath = 'C:\SysinternalsSuite\procexp.exe' $shortcut.Save() |
PowerShell കൂടെ ടാസ്ക്ബാറിൽ ഒരു പ്രോഗ്രാം പിൻ അല്ലെങ്കിൽ അൺപിൻ എങ്ങനെ?
1 2 3 4 |
$shell = New-Object -ComObject shell.application $program = $shell.Namespace($env:windir).Parsename('notepad.exe') $program.Invokeverb('TaskbarPin') $program.Invokeverb('TaskbarUnpin') |
PowerShell ഒരു Windows എക്സ്പ്ലോറർ തുറക്കാൻ എങ്ങനെ?
[Diagnostics.Process]::Start('explorer.exe')
Invoke-Item -Path C:\Windows\explorer.exe
PowerShell ഡിവൈസ് ഡ്രൈവറുകൾ ലിസ്റ്റുചെയ്യുന്നതിന് എങ്ങനെ?
Get-WmiObject -Class Win32_PnPSignedDriver
Get-WindowsDriver -Online -All
driverquery.exe
PowerShell ഒരു ജിയുഐഡി സൃഷ്ടിക്കാൻ എങ്ങനെ?
1 2 3 4 5 6 7 8 9 10 11 |
# Empty GUID $guid = [GUID]::Empty # New GUID (lower case by default) $guid = [GUID]::NewGuid() # New GUID (upper case) $guid = ([GUID]::NewGuid()).ToString().ToUpper() # New GUID with a specific value $guid = [GUID]('bc4ad3d3-d704-4bd0-843f-d607fbbc4cd7') |
PowerShell കൂടെ നിലവിലുള്ള ഉപയോക്താവിന്റെ താൽക്കാലിക ഡയറക്ടറി സ്ഥാനം എങ്ങനെ ലഭിക്കും?
[System.IO.Path]::GetTempPath()
PowerShell കൂടെ ഒരൊറ്റ പാതയിലേക്ക് ഒരു പാത്ത് ഒരു കുട്ടിയുമാണ് പാത്ത് ചേരാൻ എങ്ങനെ?
Join-Path -Path C:\ -ChildPath \windows
എല്ലാ cmdlets PowerShell ഉപയോഗിച്ച് “Get- *” പട്ടിക എങ്ങനെ?
Get-Command -Verb Get
PowerShell പ്രത്യേക സിസ്റ്റം ഫോൾഡറുകൾ ലിസ്റ്റുചെയ്യുന്നതിന് എങ്ങനെ?
1 |
[System.Enum]::GetNames([System.Environment+SpecialFolder]) | ForEach-Object -Process { $_ + " [System.Environment]::GetFolderPath($_)" } |
PowerShell ഉപയോഗിച്ച് ഐഎസ്ഒ / VHD ഫയലുകൾ മൌണ്ട് എങ്ങനെ?
Mount-DiskImage 'D:\ISO\file.iso' # ISO
Mount-DiskImage 'D:\VHD\file.vhd' # VHD
PowerShell ഇൻസ്റ്റാൾ .ഡോട്ട് പതിപ്പുകൾ പരിശോധിക്കുന്നത് എങ്ങനെ?
1 |
Get-ChildItem -Path 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -Recurse | Get-ItemProperty -Name Version -EA 0 | Where-Object -FilterScript { $_.PSChildName -match '^(?!S)\p{L}' } | Select-Object -Property PSChildName, Version |
.ഡോട്ട് പതിപ്പ് 4.5 PowerShell കൂടെ ഇൻസ്റ്റോൾ പരിശോധിക്കാൻ എങ്ങനെ?
(Get-ItemProperty -Path 'HKLM:\Software\Microsoft\NET Framework Setup\NDP\v4\Full' -EA 0).Version -like '4.5*'
PowerShell കൊണ്ട് (വിൻഡോസ് PowerShell സെഷനിൽ റെക്കോർഡ് സൃഷ്ടിക്കുന്നതിനായി) ഒരു ട്രാൻസ്ക്രിപ്റ്റ് ആരംഭിക്കാൻ അവസാനിപ്പിക്കുകയും എങ്ങനെ?
Start-Transcript -Path 'C:\scripts\transcript.txt
Stop-Transcript
PowerShell ഒരു നിർദ്ദിഷ്ട സ്ഥാനം നിലവിലെ ഡയറക്ടറി മാറ്റം എങ്ങനെ?
Set-Location -Path 'C:\scripts'
PowerShell ഉപയോഗിച്ച് സ്ക്രീൻ ക്ലിയർ എങ്ങനെ?
Clear-Host
cls # Alias
PowerShell ഉപയോഗിച്ച് ഡിസ്പ്ലെ മാറ്റം എങ്ങനെ?
Set-DisplayResolution -Width 1280 -Height 1024 -Force # Windows 2012
PowerShell ഉപയോഗിച്ച് “പൂർണ്ണ സ്ക്രീനിൽ” വിൻഡോ സജ്ജമാക്കാൻ എങ്ങനെ?
mode.com 300
PowerShell ഒരു ചിത്രത്തിന്റെ തലങ്ങളും (വീതിയും ഉയരവും) എങ്ങനെ ലഭിക്കും?
1 2 3 4 5 6 7 |
$picture = New-Object -ComObject Wia.ImageFile $picture.LoadFile('C:\screenshot.jpg') [PSCustomObject] @{ Width = $picture.Width Height = $picture.Height } |
PowerShell വിൻഡോസ് കീ എങ്ങനെ ലഭിക്കും?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
function Get-WindowsKey { ## function to retrieve the Windows Product Key from any PC ## by Jakob Bindslet (jakob@bindslet.dk) param ($targets = '.') $hklm = 2147483650 $regPath = 'Software\Microsoft\Windows NT\CurrentVersion' $regValue = 'DigitalProductId' Foreach ($target in $targets) { $productKey = $null $win32os = $null $wmi = [WMIClass]"\\$target\root\default:stdRegProv" $data = $wmi.GetBinaryValue($hklm,$regPath,$regValue) $binArray = ($data.uValue)[52..66] $charsArray = 'B', 'C', 'D', 'F', 'G', 'H', 'J', 'K', 'M', 'P', 'Q', 'R', 'T', 'V', 'W', 'X', 'Y', '2', '3', '4', '6', '7', '8', '9' ## decrypt base24 encoded binary data For ($i = 24; $i -ge 0; $i--) { $k = 0 For ($j = 14; $j -ge 0; $j--) { $k = $k * 256 -bxor $binArray[$j] $binArray[$j] = [math]::truncate($k / 24) $k = $k % 24 } $productKey = $charsArray[$k] + $productKey If (($i % 5 -eq 0) -and ($i -ne 0)) { $productKey = '-' + $productKey } } $win32os = Get-WmiObject -Class Win32_OperatingSystem -ComputerName $target $obj = New-Object -TypeName Object $obj | Add-Member -MemberType Noteproperty -Name Computer -Value $target $obj | Add-Member -MemberType Noteproperty -Name Caption -Value $win32os.Caption $obj | Add-Member -MemberType Noteproperty -Name CSDVersion -Value $win32os.CSDVersion $obj | Add-Member -MemberType Noteproperty -Name OSArch -Value $win32os.OSArchitecture $obj | Add-Member -MemberType Noteproperty -Name BuildNumber -Value $win32os.BuildNumber $obj | Add-Member -MemberType Noteproperty -Name RegisteredTo -Value $win32os.RegisteredUser $obj | Add-Member -MemberType Noteproperty -Name ProductID -Value $win32os.SerialNumber $obj | Add-Member -MemberType Noteproperty -Name ProductKey -Value $productKey $obj } } |
Perfmon
PowerShell കഴിഞ്ഞ 5 സെക്കൻഡ് (10 തവണ) എന്ന (ശരാശരി) നിലവിലുള്ള “% പ്രൊസസർ സമയം” എങ്ങനെ ലഭിക്കും?
(Get-Counter '\Processor(_total)\% Processor Time' -SampleInterval 5 -MaxSamples 10).CounterSamples.CookedValue
Assemblies
PowerShell ഉപയോഗിച്ച് സഭകൾ ലോഡ് എങ്ങനെ?
1 2 3 4 5 6 |
Add-Type -AssemblyName 'System.Windows.Forms' Add-Type -Path 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll' # Deprecated [System.Reflection.Assembly]::LoadFrom('C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll') |
PowerShell കയറ്റി നിലവിലെ ഭാഷയായി സമ്മേളനങ്ങൾ പരിശോധിക്കുന്നത് എങ്ങനെ?
1 2 3 4 5 |
# Check All [System.AppDomain]::CurrentDomain.GetAssemblies() # Check specific one [System.AppDomain]::CurrentDomain.GetAssemblies() | Where-Object -FilterScript { $_.FullName -like '*forms*' } |
PowerShell കൂടെ Thahseen: (ഗ്ലോബൽ അസംബ്ലി കാഷെ) മാർഗത്തിൽ കണ്ടെത്തുന്നത് എങ്ങനെയാണ്?
1 |
(New-Object -TypeName Regex -ArgumentList '(?<=file:///)(.*)(?=\/GAC)', 'IgnoreCase').Match(([PSObject].Assembly.Evidence | Where-Object -FilterScript { $_.Value -ne $null }).Value).Value -replace '/', '\' |
Clipboard
PowerShell ഉപയോഗിച്ച് ക്ലിപ്പ്ബോർഡിലേക്ക് ഫലങ്ങൾ പകർത്താനും എങ്ങനെ?
1 |
Get-Process | clip.exe |
PowerShell ഉപയോഗിച്ച് ക്ലിപ്പ്ബോർഡിൽ ഉള്ളടക്കം എങ്ങനെ ലഭിക്കും?
Add-Type -AssemblyName PresentationCore
[Windows.Clipboard]::GetText()
Hotfixes
PowerShell ഇൻസ്റ്റാൾ hotfixes എങ്ങനെ ലഭിക്കും?
Get-HotFix -ComputerName $computer
Hotfixes PowerShell ഒരു പ്രത്യേക തീയതി കഴിഞ്ഞ് / മുമ്പ് ഇന്സ്റ്റാള് ചെയ്യുക എങ്ങനെ?
Get-HotFix | Where-Object -FilterScript { $_.InstalledOn -lt ([DateTime]'01/01/2015') } # Before 01/01/2015
Get-HotFix | Where-Object -FilterScript {$_.InstalledOn -gt ([DateTime]'01/01/2015')} # After 01/01/2015
ഒരു hotfix PowerShell കൂടെ ഇൻസ്റ്റോൾ പരിശോധിക്കാൻ എങ്ങനെ?
Get-HotFix -Id KB2965142
Hotfixes PowerShell ഒരു വിദൂര കമ്പ്യൂട്ടർ ഇന്സ്റ്റാള് ചെയ്യുക എങ്ങനെ?
Get-HotFix -ComputerName $computer
Pagefile
PowerShell ഉപയോഗിച്ച് ഫയൽ വിവരങ്ങൾ എങ്ങനെ ലഭിക്കും?
Get-WmiObject -Class Win32_PageFileusage | Select-Object -Property Name, CurrentUsage, AllocatedBaseSize, PeakUsage, InstallDate
PowerShell കൂടെ ഫയൽ ശുപാർശ വ്യാപ്തി (MB) എങ്ങനെ ലഭിക്കും?
[Math]::Truncate(((Get-WmiObject -Class Win32_ComputerSystem).TotalPhysicalMemory) / 1MB) * 1.5
PowerShell കൊണ്ട് (ഡി 🙂 ഡ്രൈവിലുള്ള ഫയൽ (4096 എം.ബി.) സൃഷ്ടിക്കാൻ എങ്ങനെ?
1 2 3 4 5 |
Set-WmiInstance -Class Win32_PageFileSetting -Arguments @{ Name = 'D:\pagefile.sys' InitialSize = 4096 MaximumSize = 4096 } |
PowerShell (സി 🙂 ഡ്രൈവിലുള്ള ഒരു ഫയൽ ഇല്ലാതാക്കാൻ എങ്ങനെ?
1 2 3 4 5 |
$privileges = Get-WmiObject -Class Win32_computersystem -EnableAllPrivileges $privileges.AutomaticManagedPagefile = $false $privileges.Put() $pagefile = Get-WmiObject -Query "select * from Win32_PageFileSetting where name='c:\\pagefile.sys'" $pagefile.Delete() # Reboot required |
Maintenance
PowerShell ഒരു ഡ്രൈവ് ഫ്രാഗ്മൻറേഷൻ പരിശോധിക്കാൻ എങ്ങനെ?
1 |
$drive = Get-WmiObject -Class Win32_Volume -Filter "DriveLetter = 'c:'" $defragReport = $drive.DefragAnalysis() $defragReport.DefragAnalysis |
PowerShell കൂടെ ഡ്രൈവുകൾ ഡിസ്ക് സ്ഥലം പരിശോധിക്കാൻ എങ്ങനെ?
1 2 3 4 5 6 7 8 9 10 11 12 13 |
Get-WmiObject -Class Win32_logicaldisk | Format-Table -Property @{ Name = 'Drive' Expression = {$_.DeviceID} }, @{ Name = 'Total size (GB)' Expression = {[decimal]('{0:N0}' -f($_.Size/1gb))} }, @{ Name = 'Free space(GB)' Expression = {[decimal]('{0:N0}'-f($_.Freespace/1gb))} }, @{ Name = 'Free (%)' Expression = {'{0,6:P0}' -f(($_.Freespace/1gb) / ($_.size/1gb))} } -AutoSize |
Files
PowerShell ഒരു ഫയൽ തുറക്കാൻ എങ്ങനെ?
Invoke-Item -Path 'C:\scripts\file.txt'
.'C:\scripts\file.txt'
PowerShell ഒരു ഫയൽ വായിക്കാൻ എങ്ങനെ?
Get-Content -Path 'C:\scripts\file.txt'
gc "C:\scripts\file.txt" # Alias
PowerShell ഒരു ഫയലിലേക്ക് എങ്ങനെ എഴുതാം?
'Line1', 'Line2', 'Line3' | Out-File -FilePath 'C:\scripts\file.txt'
'Line1', 'Line2', 'Line3' | Add-Content -Path file.txt
PowerShell ഇപ്പോഴത്തെ സ്ക്രിപ്റ്റ് ഫയലിന്റെ FULLNAME എങ്ങനെ ലഭിക്കും?
$MyInvocation.MyCommand.Path
PowerShell ഉപയോഗിച്ച് / സിപ്പ് ഫയലുകൾ കംപ്രസ്സുചെയ്യാൻ എങ്ങനെ?
Add-Type -AssemblyName 'System.IO.Compression.Filesystem'
[System.IO.Compression.ZipFile]::CreateFromDirectory($folder,$fileZIP)
അൺകംപ്രസ്സ് എങ്ങനെ / PowerShell ഫയലുകൾ അൺസിപ്പ്?
Add-Type -AssemblyName 'System.IO.Compression.Filesystem'
[System.IO.Compression.ZipFile]::ExtractToDirectory($fileZIP, $folder)
PowerShell കൂടെ ഒരു ZIP ആർക്കൈവിൽ ഫയലുകൾ കാണാൻ എങ്ങനെ?
Add-Type -AssemblyName 'System.IO.Compression.Filesystem'
[System.IO.Compression.ZipFile]::OpenRead($fileZIP)
PowerShell കൂടെ കെ.ബി. ഒരു ഫയലിന്റെ വലിപ്പം പ്രദർശിപ്പിക്കാൻ എങ്ങനെ?
(Get-ChildItem -Path .\winsrv.dll).Length /1KB
(Get-ChildItem -Path .\winsrv.dll).Length /1MB
(Get-ChildItem -Path .\winsrv.dll).Length /1GB
PowerShell 1 ജിബി വലുതാണ് കുറവോ ഫയലുകൾ കണ്ടെത്തുന്നത് എങ്ങനെയാണ്?
1 2 3 4 5 |
# Larger than 1 GB Get-ChildItem -Path C:\ -Recurse -ErrorVariable $errorsSearch | Where-Object -FilterScript {$_.Length -gt 1GB} # Less than 1 GB Get-ChildItem -Path C:\ -Recurse -ErrorVariable $errorsSearch | Where-Object -FilterScript {$_.Length -lt 1GB} |
PowerShell ഉപയോഗിച്ച് വിപുലീകരണം ഇല്ലാത്ത ഒരു ഫയലിന്റെ പേര് പ്രദർശിപ്പിക്കാൻ എങ്ങനെ?
[System.IO.Path]::GetFileNameWithoutExtension('C:\Windows\system32\calc.exe') # Return calc
PowerShell ഒരു ഫയലിന്റെ വിപുലീകരണം പ്രദർശിപ്പിക്കാൻ എങ്ങനെ?
[System.IO.Path]::GetExtension('C:\scripts\file.txt') # Return .txt
PowerShell ഒരു ഫയലിന്റെ പതിപ്പ് എങ്ങനെ ലഭിക്കും?
1 2 |
(Get-Item -Path C:\Windows\System32\calc.exe).VersionInfo.FileVersion [System.Diagnostics.FileVersionInfo]::GetVersionInfo('C:\Windows\system32\calc.exe').FileVersion |
PowerShell ഒരു ഫയലിന്റെ ഹാഷ് എങ്ങനെ ലഭിക്കും?
(Get-FileHash $file).Hash
PowerShell ഒരു ഫയലിന്റെ MD5 / SHA1 ചെക്ക്സം എങ്ങനെ ലഭിക്കും?
Get-FileHash $file -Algorithm MD5
Get-FileHash $file -Algorithm SHA1
PowerShell മറഞ്ഞിരിക്കുന്ന ഫയലുകൾ ലഭ്യമാക്കി എങ്ങനെ?
1 2 3 4 5 |
# Display only hidden files Get-ChildItem -Hidden -File # Display all files (including hidden files) Get-ChildItem -Force -File |
ഒരു ഫയൽ PowerShell ഒരു വിപുലീകരണം ഉണ്ട് പരിശോധിക്കാൻ എങ്ങനെ?
1 |
[System.IO.Path]::HasExtension('C:\hiberfil.sys') |
PowerShell കൂടെ “വായന മാത്രം” ആയി ഒരു ഫയൽ സജ്ജമാക്കാൻ എങ്ങനെ?
Set-ItemProperty -Path .\file.txt -Name IsReadOnly -Value $true
PowerShell കൂടെ ഒരു പ്രമാണത്തിന്റെ കഴിഞ്ഞ ആഴ്ച വരെ “LastWriteTime” ഗുണം മാറ്റാൻ എങ്ങനെ?
Set-ItemProperty -Path .\file.txt -Name LastWriteTime -Value ((Get-Date).AddDays(-7))
If not working, use Nirsoft tool: BulkFileChanger.
PowerShell ഒരു പുതിയ ഫയൽ സൃഷ്ടിക്കാൻ എങ്ങനെ?
New-Item -ItemType File -Path 'C:\scripts\file.txt' -Value 'FirstLine'
PowerShell ഒരു ഫയൽ പുനർനാമകരണം എങ്ങനെ?
Rename-Item -Path 'C:\scripts\file.txt' -NewName 'C:\scripts\powershellguru2.txt'
PowerShell ഉപയോഗിച്ച് ഒന്നിലധികം ഫയലുകൾ എങ്ങനെ ബൾക്ക് വരെ / ബാച്ച് പുനർനാമകരണം?
Get-ChildItem -Path C:\scripts\txt | Rename-Item -NewName { $_.Name -replace ' ', '_' }
PowerShell ഒരു ഫയൽ ഡിലീറ്റ് എങ്ങനെ?
Remove-Item -Path 'C:\scripts\file.txt'
PowerShell ഒരു ഫയലിന്റെ 10 പുതിയ ലൈനുകൾ പ്രദർശിപ്പിക്കാൻ എങ്ങനെ?
Get-Content -Path 'C:\scripts\log.txt' -Tail 10
PowerShell ഫോൾഡർ നിരവധി ഫയലുകൾ തടഞ്ഞത് എങ്ങനെ?
Get-ChildItem -Path 'C:\scripts\Modules' | Unblock-File
PowerShell ഒരു ഫയലിൽ നിന്നും ശൂന്യമായ വരികള് നീക്കം എങ്ങനെ?
(Get-Content -Path file.txt) | Where-Object -FilterScript {$_.Trim() -ne '' } | Set-Content -Path file.txt
ഒരു ഫയൽ PowerShell നിലവിലുള്ളതിനാൽ പരിശോധിക്കാൻ എങ്ങനെ?
1 |
Test-Path -Path 'C:\Windows\notepad.exe' # Return True |
PowerShell ഒരു ഫോൾഡറിൽ പുതിയ / ചെന്ന സൃഷ്ടിച്ച ഫയല് എങ്ങനെ ലഭിക്കും?
1 2 |
Get-ChildItem | Sort-Object -Property CreationTime | Select-Object -Last 1 # Newest Get-ChildItem | Sort-Object -Property CreationTime | Select-Object -First 1 # Oldest |
PowerShell ഒരു ഫയലിൽ നിന്നും ഡ്യൂപ്ലിക്കേറ്റ് ലൈനുകൾ നീക്കം എങ്ങനെ?
1 2 |
Get-Content -Path .\file.txt | Select-Object -Unique # Display Get-Content -Path .\file.txt | Select-Object -Unique | Set-Content -Path .\testing.txt # Save |
PowerShell ഫോൾഡർ കൂടുതൽ സൃഷ്ടിച്ച ഫയലുകൾ കുറവോ 1 മാസം എങ്ങനെ ലഭിക്കും?
1 2 3 |
$1MonthAgo = (Get-Date).AddMonths(-1) Get-ChildItem | ?{$_.LastWriteTime -lt $1MonthAgo} | Select-Object LastWriteTime,Name,DirectoryName # More Get-ChildItem | ?{$_.LastWriteTime -gt $1MonthAgo} | Select-Object LastWriteTime,Name,DirectoryName # Less |
PowerShell ഫോൾഡർ കൂടുതൽ സൃഷ്ടിച്ച ഫയലുകൾ താഴെവരെ 1 വർഷം എങ്ങനെ ലഭിക്കും?
1 2 3 |
$1YearAgo = (Get-Date).AddYears(-1) Get-ChildItem | ?{$_.LastWriteTime -lt $1YearAgo} | Select-Object LastWriteTime,Name,DirectoryName # More Get-ChildItem | ?{$_.LastWriteTime -gt $1YearAgo} | Select-Object LastWriteTime,Name,DirectoryName # Less |
PowerShell ഒരു ഫയൽ ഒരു വേരിയബിൾ മൂല്യം കയറ്റുമതി എങ്ങനെ?
Set-Content -Path file.txt -Value $variable
PowerShell ഫോൾഡർ ഫയലുകള് എണ്ണം (* .txt) എണ്ണാൻ എങ്ങനെ?
1 2 3 |
[System.IO.Directory]::GetFiles('C:\scripts', '*.txt').Count (Get-ChildItem -Path 'C:\scripts' -Filter *.txt).Count (Get-ChildItem -Path 'C:\scripts' -Filter *.txt -Recurse).Count # Recursive |
PowerShell ഉപയോഗിച്ച് ഒന്നിലധികം ഫയലുകൾ അതിനുള്ളിൽ ഒരു സ്ട്രിംഗ് തിരയാൻ എങ്ങനെ?
Select-String -Path 'C:\*.txt' -Pattern 'Test'
PowerShell ഒരു ഫയൽ അവസാന / ആദ്യ വരി പ്രദർശിപ്പിക്കാൻ എങ്ങനെ?
1 2 3 4 5 6 7 8 9 |
'Line1', 'Line2', 'Line3' | Out-File -FilePath file.txt # First Line Get-Content -Path .\file.txt | Select-Object -First 1 # Returns Line1 (Get-Content -Path .\file.txt)[0] # Returns Line1 # Last Line Get-Content -Path .\file.txt | Select-Object -Last 1 # Returns Line3 (Get-Content -Path .\file.txt)[-1] # Returns Line3 |
PowerShell ഒരു ഫയലിന്റെ ഒരു പ്രത്യേക വരി നമ്പർ കാണിക്കുന്നതിനായി എങ്ങനെ?
1 2 3 |
'Line1', 'Line2', 'Line3' | Out-File -FilePath file.txt Get-Content -Path .\file.txt | Select-Object -Index 0 # Returns Line1 Get-Content -Path .\file.txt | Select-Object -Index 2 # Returns Line3 |
PowerShell ഒരു ഫയലിന്റെ വരികളുടെ എണ്ണം കണക്കാക്കാനും എങ്ങനെ?
1 2 |
'Line1', 'Line2', 'Line3' | Out-File -FilePath file.txt (Get-Content -Path .\file.txt | Measure-Object -Line).Lines # Returns 3 |
PowerShell ഒരു ഫയലിന്റെ പ്രതീകങ്ങൾ വാക്കുകളുടെ എണ്ണം കണക്കാക്കാനും എങ്ങനെ?
1 2 3 4 5 6 7 8 9 10 |
'Test', 'Powershell', 'Test Powershell' | Out-File -FilePath file.txt # Words (Return 4) (Get-Content -Path .\file.txt | Measure-Object -Word).Words # Characters (Return 23) (Get-Content -Path .\file.txt | Measure-Object -Character).Characters # Characters and ignore whitespaces (Return 22) (Get-Content -Path .\file.txt | Measure-Object -Character -IgnoreWhiteSpace).Characters |
PowerShell ഒരു ഫയൽ ഡൌൺലോഡ് എങ്ങനെ?
Invoke-WebRequest -Uri 'http://www.nirsoft.net/utils/searchmyfiles.zip' -OutFile 'C:\tools\searchmyfiles.zip'
PowerShell ഒരു ഫയലിന്റെ നിറഞ്ഞ പാത പ്രദർശിപ്പിക്കുന്നതിന് എങ്ങനെ?
Resolve-Path -Path .\script.ps1 # Return C:\Scripts\script.ps1
Copy
PowerShell ഒരു ഫോൾഡറിൽ ഒരു ഫയൽ പകർത്താനും എങ്ങനെ?
Copy-Item -Path 'C:\source\file.txt' -Destination 'C:\destination'
PowerShell ഉപയോഗിച്ച് ഒന്നിലധികം ഫോൾഡറുകൾ ഒരു ഫയലില് പകർത്താനും എങ്ങനെ?
1 2 |
$destination = 'C:\destination\Folder1', 'C:\destination\Folder2' $destination | Copy-Item -Path 'C:\source\file.txt' -Recurse -Destination {$_} |
PowerShell കൂടെ ഒരു ഫോൾഡർ ഒന്നിലധികം ഫയലുകൾ പകർത്താനും എങ്ങനെ?
Get-ChildItem -Path 'C:\source' -Filter *.txt | Copy-Item -Destination 'C:\destination'
Active Directory
Domain & Forest
PowerShell ഉപയോഗിച്ച് സജീവ ഡയറക്ടറി ആഗോള കാറ്റലോഗിൽ സെർവറുകളിൽ കണ്ടെത്തുന്നത് എങ്ങനെയാണ്?
[System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest().GlobalCatalogs
PowerShell ഉപയോഗിച്ച് സജീവ ഡയറക്ടറി സൈറ്റുകളുടെ കണ്ടെത്തുന്നത് എങ്ങനെയാണ്?
[System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest().Sites
PowerShell ഇപ്പോഴത്തെ ഡൊമെയ്ൻ കണ്ട്രോളര് കണ്ടെത്തുന്നത് എങ്ങനെയാണ്?
(Get-ADDomainController).HostName
PowerShell ഉപയോഗിച്ച് ഒരു ഡൊമെയ്ൻ എല്ലാ ഡൊമെയിൻകണ്ട്രോളറുകളും കണ്ടെത്തുന്നത് എങ്ങനെയാണ്?
1 2 3 4 5 6 7 8 9 10 11 |
# Solution 1 Get-ADDomainController -Filter * | ForEach-Object -Process {$_.Name} # Solution 2 Get-ADGroupMember 'Domain Controllers' | ForEach-Object -Process {$_.Name} # Solution 3 Get-ADComputer -LDAPFilter '(&(objectCategory=computer)(userAccountControl:1.2.840.113556.1.4.803:=8192))' | ForEach-Object -Process {$_.Name} # Solution 4 [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain() | ForEach-Object -Process {$_.DomainControllers} | ForEach-Object -Process {$_.Name} |
PowerShell ഉപയോഗിച്ച് എഡി തനിപ്പകർപ്പെടുക്കൽ പരാജയങ്ങൾ കണ്ടെത്തുന്നത് എങ്ങനെയാണ്?
Get-ADReplicationFailure dc02.domain.com # Windows 8 and 2012
PowerShell ഉപയോഗിച്ച് സജീവ ഡയറക്ടറിയിൽ വനമായി സ്മാരകശില ആജീവനാന്ത കണ്ടെത്തുന്നത് എങ്ങനെയാണ്?
1 |
(Get-ADObject -Identity "cn=Directory Service,cn=Windows NT,cn=Services,$(([adsi]('LDAP://RootDSE')).configurationNamingContext)" -Properties tombstonelifetime).tombstonelifetime |
PowerShell ഉപയോഗിച്ച് സജീവ ഡയറക്ടറി വനം / ഡൊമെയ്ൻ വിശദാംശങ്ങൾ എങ്ങനെ ലഭിക്കും?
1 2 |
Get-ADDomain domain.com Get-ADForest domain.com |
PowerShell ഉപയോഗിച്ച് സജീവ ഡയറക്ടറി ൽ “ഇല്ലാതാക്കിയ വസ്തുക്കൾ” കണ്ടെയ്നർ പാതയെ എങ്ങനെ ലഭിക്കും?
(Get-ADDomain).DeletedObjectsContainer
PowerShell ഉപയോഗിച്ച് സജീവ ഡയറക്ടറിയിൽ എഡി മരണഠേമശയില് ബിൻ സവിശേഷത പ്രാപ്തമാക്കാൻ എങ്ങനെ?
1 |
Enable-ADOptionalFeature -Identity 'CN=Recycle Bin Feature,CN=Optional Features,CN=Directory Service,CN=Windows NT,CN=Services,CN=Configuration,DC=domain,DC=com' -Scope ForestOrConfigurationSet -Target 'domain.com' |
PowerShell ഉപയോഗിച്ച് സജീവ ഡയറക്ടറി ലെ മരണഠേമശയില് ബിൻ നിന്ന് ഒരു എഡി അക്കൗണ്ട് പുനഃസ്ഥാപിക്കാൻ എങ്ങനെ?
Get-ADObject -Filter 'samaccountname -eq "powershellguru"' -IncludeDeletedObjects | Restore-ADObject
PowerShell കൂടെ FSMO റോളുകൾ കണ്ടെത്തുന്നത് എങ്ങനെയാണ്?
1 2 3 4 5 6 7 8 9 10 11 12 13 |
# Solution 1 Get-ADForest | Format-List -Property SchemaMaster, DomainNamingMaster Get-ADDomain | Format-List -Property PDCEmulator, RIDMaster, InfrastructureMaster # Solution 2 netdom query fsmo # Solution 3 [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest().SchemaRoleOwner [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest().NamingRoleOwner [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain().InfrastructureRoleOwner [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain().PdcRoleOwner [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain().RidRoleOwner |
PowerShell ഒരു പ്രത്യേക ഡൊമൈന് കണ്ട്രോളര് കണക്ട് എങ്ങനെ?
Get-ADUser -Identity $user -Server 'serverDC01'
PowerShell ഇപ്പോഴത്തെ പ്രവേശന സെർവർ എങ്ങനെ ലഭിക്കും?
1 2 |
($env:LOGONSERVER).Substring(2) ([System.Environment]::GetEnvironmentVariable('logonserver')).Substring(2) |
PowerShell ഒരു കമ്പ്യൂട്ടറിൽ “gpupdate” നടപ്പിലാക്കുന്നതിനായി എങ്ങനെ?
Invoke-GPUpdate -Computer $computer -Force -RandomDelayInMinutes 0 # Windows 2012
Groups
PowerShell ഉപയോഗിച്ച് സജീവ ഡയറക്ടറി ഒരു പുതിയ ഗ്രൂപ്പ് സൃഷ്ടിക്കാൻ എങ്ങനെ?
1 |
New-ADGroup -Name 'Powershell Guru' -SamAccountName powershellguru -GroupCategory Security -GroupScope Global -DisplayName 'Powershell Guru' -Path 'OU=MyOU,DC=domain,DC=com' -Description 'My account' |
PowerShell ഉപയോഗിച്ച് സജീവ ഡയറക്ടറി ഒരു ഗ്രൂപ്പ് നീക്കം എങ്ങനെ?
Remove-ADGroup -Identity 'PowershellGuru'
PowerShell ഉപയോഗിച്ച് സജീവ ഡയറക്ടറി ഒരു ഗ്രൂപ്പിൽ ഒരു ഉപയോക്താവിനെ ചേർക്കുന്നതിനായി എങ്ങനെ?
Add-ADGroupMember "Powershell Guru" -Members powershellguru
PowerShell ഉപയോഗിച്ച് സജീവ ഡയറക്ടറി ഒരു ഗ്രൂപ്പിൽ നിന്നും ഒരു ഉപയോക്താവ് നീക്കം എങ്ങനെ?
Remove-ADGroupMember 'Powershell Guru' -Members powershellguru
PowerShell ഉപയോഗിച്ച് സജീവ ഡയറക്ടറിയിൽ (യാതൊരു അംഗങ്ങൾ) ശൂന്യമായ ഗ്രൂപ്പുകൾ കണ്ടെത്തുന്നത് എങ്ങനെയാണ്?
Get-ADGroup -Filter * -Properties Members | Where-Object -FilterScript {-not $_.Members}
PowerShell ഉപയോഗിച്ച് സജീവ ഡയറക്ടറിയിൽ (യാതൊരു അംഗങ്ങൾ) ശൂന്യമായ ഗ്രൂപ്പുകൾ എണ്ണാൻ എങ്ങനെ?
(Get-ADGroup -Filter * -Properties Members | Where-Object -FilterScript {-not $_.Members}).Count
PowerShell ഉപയോഗിച്ച് സജീവ ഡയറക്ടറി ഒരു ഗ്രൂപ്പ് അംഗങ്ങളെ എങ്ങനെ ലഭിക്കും?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# Solution 1 Get-ADGroupMember 'Powershell Guru' | ForEach-Object -Process {$_.DistinguishedName} Get-ADGroupMember 'Powershell Guru' | ForEach-Object -Process {$_.Samaccountname} # Solution 2 Get-ADGroup 'Powershell Guru' -Properties Members | Select-Object -Property Members -ExpandProperty Members | Sort-Object # Solution 3 function Get-ADGroupMemberFast { [CmdletBinding()] Param ( [Parameter(Mandatory = $true)] [string]$GroupName ) $de = New-Object -TypeName System.DirectoryServices.DirectoryEntry $ds = New-Object -TypeName System.DirectoryServices.DirectorySearcher $ds.SearchRoot = $de $ds.Filter = "(cn=$group)" $null = $ds.PropertiesToLoad.Add('member') $result = $ds.FindOne() if($result) { $account = $result.GetDirectoryEntry() $account.Properties['member'] | ForEach-Object -Process {$_} } } Get-ADGroupMemberFast -GroupName 'Powershell Guru' |
PowerShell ഉപയോഗിച്ച് സജീവ ഡയറക്ടറി ലെ കാഷ്ഡ് അംഗങ്ങളുമായി ഒരു ഗ്രൂപ്പ് അംഗങ്ങളെ എങ്ങനെ ലഭിക്കും?
1 2 |
Get-ADGroupMember 'Powershell Guru' -Recursive | ForEach-Object -Process {$_.DistinguishedName} Get-ADGroupMember 'Powershell Guru' -Recursive | ForEach-Object -Process {$_.SamAccountName} |
1 2 |
(Get-ADGroupMember 'Powershell Guru' | ForEach-Object -Process {$_.Samaccountname}).Count (Get-ADGroupMember 'Powershell Guru' -Recursive | ForEach-Object -Process {$_.Samaccountname}).Count |
Users
1 2 3 4 5 6 7 8 9 |
# Filter (Get-ADUser -SearchBase 'OU=myOU,DC=domain,DC=com' -Filter {name -like '*vip*'} -Properties Name).Name # LDAPFilter (Get-ADUser -SearchBase 'OU=myOU,DC=domain,DC=com' -LDAPFilter '(name=*vip*)' -Properties Name).Name # With a variable $user = '*vip*' (Get-ADUser -SearchBase 'OU=myOU,DC=domain,DC=com' -Filter {name -like $user} -Properties Name).Name |
PowerShell ഉപയോഗിച്ച് സജീവ ഡയറക്ടറി മറ്റൊരു OU ഒരു ഉപയോക്താവ് നീക്കാൻ എങ്ങനെ?
Move-ADObject -Identity $dn -TargetPath 'OU=myOU,DC=domain,DC=com'
PowerShell ഒരു ഉപയോക്താവിനായി (നെസ്റ്റ്) എല്ലാ അംഗങ്ങൾ കണ്ടെത്തുന്നത് എങ്ങനെയാണ്?
Get-ADGroup -LDAPFilter "(member:1.2.840.113556.1.4.1941:=$($dn))"
PowerShell ഒരു ഉപയോക്താവിനായി അംഗങ്ങൾ (ചെറിയ പേര് / ഫയലിന്) എങ്ങനെ ലഭിക്കും?
(Get-ADUser $user -Properties MemberOf).MemberOf | ForEach-Object -Process {($_ -split ',')[0].Substring(3)} | Sort-Object
1 2 |
Set-ADUser $samAccountName -DisplayName 'DisplayName' -GivenName 'Test' -Surname 'Powershell' -DisplayName 'Test Powershell' Rename-ADObject $dn -NewName 'Test Powershell' #FullName |
PowerShell ഉപയോഗിച്ച് സജീവ ഡയറക്ടറി ഒരു യൂസർ അക്കൌണ്ട് വേണ്ടി വിവരണം, ഓഫീസ്, ടെലഫോൺ നമ്പർ മാറ്റാൻ എങ്ങനെ?
Set-ADUser $samAccountName -Description 'IT Consultant' -Office 'Building B' -OfficePhone '12345'
1 2 3 4 5 |
# 31/12/2015 Set-ADAccountExpiration $samAccountName -DateTime '01/01/2016' # Never Clear-ADAccountExpiration $samAccountName |
PowerShell ഉപയോഗിച്ച് സജീവ ഡയറക്ടറി ഒരു യൂസർ അക്കൌണ്ട് അൺലോക്ക് എങ്ങനെ?
Unlock-ADAccount $samAccountName
1 2 |
Disable-ADAccount $samAccountName Enable-ADAccount $samAccountName |
PowerShell ഉപയോഗിച്ച് സജീവ ഡയറക്ടറി ഒരു യൂസർ അക്കൌണ്ട് നീക്കം എങ്ങനെ?
Remove-ADUser $samAccountName
1 2 3 4 5 6 7 |
# Solution 1 : ask password $password = Read-Host -Prompt 'New Password' -AsSecureString # Solution 2 : specify password $password = ConvertTo-SecureString -String 'Q>9xYMw<3?' -AsPlainText -Force Get-ADUser -Filter "samaccountname -like 'helpdeskagent*'" | Set-ADAccountPassword -NewPassword $newpwd -Reset -PassThru | Set-ADuser -ChangePasswordAtLogon $true |
1 2 3 4 5 6 7 |
# Solution 1 : ask password $password = Read-Host -Prompt 'New Password' -AsSecureString # Solution 2 : specify password $password = ConvertTo-SecureString -String 'Q>9xYMw<3?' -AsPlainText -Force Get-ADUser -Filter "samaccountname -like 'helpdeskagent*'" | Set-ADAccountPassword -NewPassword $newpwd -Reset -PassThru | Set-ADuser -ChangePasswordAtLogon $true |
PowerShell ഉപയോഗിച്ച് സജീവ ഡയറക്ടറി ഒരു ഫയലിന്റെ ഉടമയെ കണ്ടെത്താൻ എങ്ങനെ?
1 2 3 |
$user = New-Object -TypeName System.Security.Principal.NTAccount -ArgumentList (Get-Acl -Path 'userFile.txt').Owner $sid = $user.Translate([System.Security.Principal.SecurityIdentifier]).Value Get-ADUser $sid |
PowerShell ഉപയോഗിച്ച് സജീവ ഡയറക്ടറി ഒരു ഉപയോക്താവിനായി OU (ഓർഗനൈസേഷണൽ യൂണിറ്റ്) കണ്ടെത്തുന്നത് എങ്ങനെയാണ്?
[regex]::match("$((Get-ADUser $user -Properties DistinguishedName).DistinguishedName)",'(?=OU=)(.*\n?)').value
1 2 |
Search-ADAccount -AccountDisabled Get-ADUser -Filter {Enabled -ne $true} |
PowerShell ഉപയോഗിച്ച് സജീവ ഡയറക്ടറി ലെ കാലഹരണപ്പെട്ട ഉപയോക്തൃ അക്കൗണ്ടുകൾ കണ്ടെത്തുന്നത് എങ്ങനെയാണ്?
Search-ADAccount -AccountExpired
PowerShell ഉപയോഗിച്ച് സജീവ ഡയറക്ടറി ലോക്ക് ഉപയോക്തൃ അക്കൗണ്ടുകൾ കണ്ടെത്തുന്നത് എങ്ങനെയാണ്?
Search-ADAccount -LockedOut
PowerShell ഉപയോഗിച്ച് സജീവ ഡയറക്ടറി ഒരു അക്കൌണ്ടിന്റെ എസ്ഐഡി കണ്ടെത്തുന്നത് എങ്ങനെയാണ്?
(Get-ADUser $user -Properties SID).SID.Value
PowerShell ഉപയോഗിച്ച് സജീവ ഡയറക്ടറിയിൽ SID ൽ ഒരു ഉപയോക്തൃനാമം പരിവർത്തനം എങ്ങനെ?
1 2 |
$user = New-Object -TypeName System.Security.Principal.NTAccount -ArgumentList ('DOMAIN', 'user') $SID = ($user.Translate([System.Security.Principal.SecurityIdentifier])).Value |
PowerShell ഉപയോഗിച്ച് സജീവ ഡയറക്ടറിയിൽ ഉപയോക്തൃനാമം ഒരു SID ൽ പരിവർത്തനം എങ്ങനെ?
1 2 |
$SID = New-Object -TypeName System.Security.Principal.SecurityIdentifier -ArgumentList ('SID') $user = ($SID.Translate( [System.Security.Principal.NTAccount])).Value |
PowerShell ഉപയോഗിച്ച് സജീവ ഡയറക്ടറി ഒരു യൂസർ അക്കൌണ്ട് എന്ന വ്യതിരിക്ത പേര് പിളർന്നു എങ്ങനെ?
1 2 3 |
$dn = 'CN=Powershell Test,OU=TEST,DC=domain,DC=com' $dn.Split(',')[0] # Returns "CN=Powershell Test" $dn.Split(',')[0].Split('=')[1] # Returns "Powershell Test" |
PowerShell ഉപയോഗിച്ച് സജീവ ഡയറക്ടറി ഒരു യൂസർ അക്കൌണ്ട് സൃഷ്ടിയും / ഭേദഗതി തീയതി കണ്ടെത്തുന്നത് എങ്ങനെയാണ്?
Get-ADUser -Identity $user -Properties whenChanged, whenCreated | Format-List -Property whenChanged, whenCreated
1 2 3 |
$schema = [DirectoryServices.ActiveDirectory.ActiveDirectorySchema]::GetCurrentSchema() $schema.FindClass('user').mandatoryproperties | Format-Table $schema.FindClass('user').optionalproperties | Format-Table |
PowerShell ഉപയോഗിച്ച് സജീവ ഡയറക്ടറി ഒരു ഉപയോക്താവിനായി എൽഡാപ്പ് പാത്ത് എങ്ങനെ ലഭിക്കും?
1 2 3 4 |
$searcher = New-Object -TypeName DirectoryServices.DirectorySearcher -ArgumentList ([ADSI]'') $searcher.Filter = "(&(objectClass=user)(sAMAccountName= $user))" $searcher = $searcher.FindOne() $pathLDAP = $searcher.Path |
PowerShell ഉപയോഗിച്ച് സജീവ ഡയറക്ടറി ഒരു ഉപയോക്താവിനായി സി.എൻ. (കാനോനിക്കൽ പേര്) മാറ്റം എങ്ങനെ?
Rename-ADObject $((Get-ADUser $user -Properties DistinguishedName).DistinguishedName) -NewName 'Test Powershell'
1 2 |
$dn = (Get-ADUser $user -Properties DistinguishedName).DistinguishedName $parent = $dn.Split(',',2)[1] |
1 2 |
$dn = (Get-ADUser $user -Properties DistinguishedName).DistinguishedName $owner = (Get-Acl -Path "AD:$dn").Owner |
PowerShell ഉപയോഗിച്ച് സജീവ ഡയറക്ടറി ഒരു ഉപയോക്താവിനായി PwdLastSet ആട്രിബ്യൂട്ട് പരിവർത്തനം എങ്ങനെ?
1 2 3 4 5 |
# Solution 1 [DateTime]::FromFileTime((Get-ADUser $user -Properties pwdLastSet).pwdLastSet) # Solution 2 w32tm /ntte 130787549514737594 |
Computers
PowerShell ലോക്കൽ കമ്പ്യൂട്ടറും ഡൊമെയ്ൻ തമ്മിലുള്ള സുരക്ഷിത ചാനൽ പരീക്ഷിക്കാൻ എങ്ങനെ?
Test-ComputerSecureChannel
PowerShell ലോക്കൽ കമ്പ്യൂട്ടറും ഡൊമെയ്ൻ തമ്മിലുള്ള സുരക്ഷിത ചാനൽ തീർക്കാൻ എങ്ങനെ?
Test-ComputerSecureChannel -Repair
PowerShell ഉപയോഗിച്ച് സജീവ ഡയറക്ടറി ഒരു കമ്പ്യൂട്ടർ അക്കൗണ്ട് അപ്രാപ്തമാക്കാൻ എങ്ങനെ?
Disable-ADAccount $computer
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
Get-ADComputer -Filter 'OperatingSystem -eq "CentOS"' Get-ADComputer -Filter 'OperatingSystem -eq "GNU/Linux"' Get-ADComputer -Filter 'OperatingSystem -eq "Linux"' Get-ADComputer -Filter 'OperatingSystem -eq "Mac OS X"' Get-ADComputer -Filter 'OperatingSystem -eq "OnTap"' Get-ADComputer -Filter 'OperatingSystem -eq "Red Hat Enterprise Linux Server"' Get-ADComputer -Filter 'OperatingSystem -eq "redhat-linux-gnu"' Get-ADComputer -Filter 'OperatingSystem -eq "Samba"' Get-ADComputer -Filter 'OperatingSystem -eq "Ubuntu"' Get-ADComputer -Filter 'OperatingSystem -eq "Windows NT"' Get-ADComputer -Filter 'OperatingSystem -eq "Windows 2000 Professional"' Get-ADComputer -Filter 'OperatingSystem -eq "Windows 2000 Server"' Get-ADComputer -Filter 'OperatingSystem -eq "Windows XP Professional"' Get-ADComputer -Filter 'OperatingSystem -eq "Windows Server 2003"' Get-ADComputer -Filter 'OperatingSystem -eq "Windows Vista™ Business"' Get-ADComputer -Filter 'OperatingSystem -eq "Windows Vista™ Enterprise"' Get-ADComputer -Filter 'OperatingSystem -eq "Windows Vista™ Entreprise"' Get-ADComputer -Filter 'OperatingSystem -eq "Windows 7 Enterprise"' Get-ADComputer -Filter 'OperatingSystem -eq "Windows 7 Professional"' Get-ADComputer -Filter 'OperatingSystem -eq "Windows 7 Ultimate"' Get-ADComputer -Filter 'OperatingSystem -eq "Windows Server 2008 R2 Enterprise"' Get-ADComputer -Filter 'OperatingSystem -eq "Windows Server 2008 R2 Standard"' Get-ADComputer -Filter 'OperatingSystem -eq "Windows Server® 2008 Enterprise"' Get-ADComputer -Filter 'OperatingSystem -eq "Windows 8 Enterprise"' Get-ADComputer -Filter 'OperatingSystem -eq "Windows 8.1 Enterprise"' Get-ADComputer -Filter 'OperatingSystem -eq "Windows Server 2012 R2 Standard"' Get-ADComputer -Filter 'OperatingSystem -eq "Windows Server 2012 Standard"' |
Organizational Unit (OU)
PowerShell ഉപയോഗിച്ച് സജീവ ഡയറക്ടറിയിൽ ഒരു സംഘടനാ യൂണിറ്റ് (OU) സൃഷ്ടിക്കാൻ എങ്ങനെ?
New-ADOrganizationalUnit -Name 'TEST' -Path 'DC=domain,DC=com'
PowerShell ഉപയോഗിച്ച് സജീവ ഡയറക്ടറി സംഘടനാപരമായ യൂണിറ്റ് (OU) വിവരങ്ങൾ നേടാൻ എങ്ങനെ?
Get-ADOrganizationalUnit 'OU=TEST,DC=domain,DC=com' -Properties *
PowerShell ഉപയോഗിച്ച് സജീവ ഡയറക്ടറിയിൽ ഒരു സംഘടനാ യൂണിറ്റ് (OU) വിവരണം മാറ്റം എങ്ങനെ?
Set-ADOrganizationalUnit 'OU=TEST,DC=domain,DC=com' -Description 'My description'
1 2 3 4 5 |
# Protection ON Set-ADOrganizationalUnit 'OU=TEST,DC=domain,DC=com' -ProtectedFromAccidentalDeletion $true # Protection OFF Set-ADOrganizationalUnit 'OU=TEST,DC=domain,DC=com' -ProtectedFromAccidentalDeletion $false |
1 |
Get-ADOrganizationalUnit -Filter * -Property ProtectedFromAccidentalDeletion | Where-Object -FilterScript { $_.ProtectedFromAccidentalDeletion -eq $false } | Set-ADOrganizationalUnit -ProtectedFromAccidentalDeletion $true |
1 2 |
Set-ADOrganizationalUnit 'OU=TEST,DC=domain,DC=com' -ProtectedFromAccidentalDeletion $false Remove-ADOrganizationalUnit 'OU=TEST,DC=domain,DC=com' |
1 2 |
$parent = $dn.Split(',',2)[1] $parent = (Get-ADOrganizationalUnit $parent -Properties CanonicalName).CanonicalName |
PowerShell ശൂന്യമായ ഓർഗനൈസേഷണൽ യൂണിറ്റുകൾ (OUs) പട്ടിക എങ്ങനെ?
1 2 3 4 5 |
# Solution 1 Get-ADOrganizationalUnit -Filter * -Property 'msDS-Approx-Immed-Subordinates' | Where-Object -FilterScript {$_.'msDS-Approx-Immed-Subordinates' -eq 0} # Solution 2 ([adsisearcher]'(objectclass=organizationalunit)').FindAll() | Where-Object -FilterScript { (([adsi]$_.Path).PSbase.Children | Measure-Object).Count -eq 0 } |
PowerShell ഒരു ഗ്രൂപ്പ് മാനേജർ എങ്ങനെ ലഭിക്കും?
(Get-ADGroup $dn -Properties Managedby).Managedby
Regex (Regular Expression)
PowerShell കൂടെ റിജക്സിനെ ഒരു ഐപി വിലാസം v4 (80.80.228.8) പാകത്തിൽ എങ്ങനെ?
$example = 'The IP address is 80.80.228.8'
$ip = [regex]::match($example,'\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b').value
സെപ്പറേറ്റർ ഒരു മാക് വിലാസം (C0-D9-62-39-61-2D) പാകത്തിൽ എങ്ങനെ “-” റിജക്സിനെ കൂടെ PowerShell കൂടെ?
$example = 'The MAC address is C0-D9-62-39-61-2D'
$mac = [regex]::match($example,'([0-9A-F]{2}[-]){5}([0-9A-F]{2})').value
“:” റിജക്സിനെ കൂടെ PowerShell കൂടെ സെപ്പറേറ്റർ കൂടെ? (2D: D9: 39:: 61 62 C0) അഭിസംബോധന ഒരു മാക് പാകത്തിൽ എങ്ങനെ
$example = 'The MAC address is C0:D9:62:39:61:2D'
$mac = [regex]::match($example,'((\d|([a-f]|[A-F])){2}:){5}(\d|([a-f]|[A-F])){2}').value
PowerShell കൂടെ റിജക്സിനെ ഒരു തീയതി (10/02/2015) പാകത്തിൽ എങ്ങനെ?
$example = 'The date is 10/02/2015'
$date = [regex]::match($example,'(\d{2}\/\d{2}\/\d{4})').value
PowerShell കൂടെ റിജക്സിനെ ഒരു URL- (www.powershell-guru.com) പാകത്തിൽ എങ്ങനെ?
$example = 'The URL is www.powershell-guru.com'
$url = [regex]::match($example,'[a-z]+[:.].*?(?=\s)').value
PowerShell കൂടെ റിജക്സിനെ ഒരു ഇമെയിൽ (user@domain.com) പാകത്തിൽ എങ്ങനെ?
$example = 'The email is user@domain.com'
$email = [regex]::match($example,'(?i)\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b').value
PowerShell കൂടെ റിജക്സിനെ കൂടെ സ്ട്രിംഗ് ഉദാഹരണം നിന്ന് “ഗുരു” പാകത്തിൽ എങ്ങനെ?
$example = 'www.powershell-guru.com'
[regex]::match($example,'(?<=-)(.*\n?)(?=.com)').value
PowerShell കൂടെ റിജക്സിനെ കൂടെ സ്ട്രിംഗ് ഉദാഹരണം നിന്ന് “guru.com” പാകത്തിൽ എങ്ങനെ?
$example = 'www.powershell-guru.com'
[regex]::match($example,'(?<=-)(.*\n?)(?<=.)').value
PowerShell കൂടെ റിജക്സിനെ കൂടെ സ്ട്രിംഗ് ഉദാഹരണം നിന്ന് “powershell-guru.com” പാകത്തിൽ എങ്ങനെ?
$example = 'www.powershell-guru.com'
[regex]::match($example,'(?<=www.)(.*\n?)').value
PowerShell കൂടെ റിജക്സിനെ കൂടെ സ്ട്രിംഗ് ഉദാഹരണം നിന്ന് “123” പാകത്തിൽ എങ്ങനെ?
$example = 'Powershell123'
[regex]::match($example,'(\d+)').value
PowerShell കൂടെ റിജക്സിനെ കൂടെ സ്ട്രിംഗ് മാതൃകയിൽനിന്ന് “$” (ഡോളർ അടയാളം) പാകത്തിൽ എങ്ങനെ?
$example = 'Powershell`$123'
[regex]::match($example,'(\$)').value
PowerShell കൂടെ റിജക്സിനെ ഒരു സ്ട്രിംഗ് മറ്റൊരു (* .fr) ഒരു ചിഹ്നം (* .com) പകരം എങ്ങനെ?
$example = 'www.powershell-guru.com'
[regex]::Replace($example, '.com','.fr')
PowerShell കൂടെ റിജക്സിനെ ഒരു സ്ട്രിംഗ് രക്ഷപ്പെടാൻ എങ്ങനെ?
[regex]::Escape('\\server\share')
Memory
PowerShell കൂടെ ഗാർബേജ് കളക്ടറുടെ പ്രകാരം മെമ്മറി ഒരു ശേഖരം നിർബന്ധിക്കാൻ എങ്ങനെ?
[System.GC]::Collect()
[System.GC]::WaitForPendingFinalizers()
PowerShell കമ്പ്യൂട്ടർ റാം വലിപ്പം എങ്ങനെ ലഭിക്കും?
1 2 3 4 5 6 7 8 |
# Solution 1 Get-CimInstance -ClassName 'cim_physicalmemory' | ForEach-Object -Process {$_.Capacity /1GB} # Solution 2 (Get-WmiObject -Class Win32_ComputerSystem).TotalPhysicalMemory /1GB # Solution 3 (systeminfo.exe | Select-String -Pattern 'Total Physical Memory:').ToString().Split(':')[1].Trim() |
Date
PowerShell ഇപ്പോഴത്തെ തീയതി എങ്ങനെ ലഭിക്കും?
Get-Date
[Datetime]::Now
PowerShell വ്യത്യസ്ത ഫോർമാറ്റുകളിൽ തീയതി പ്രദർശിപ്പിക്കുന്നതിന് എങ്ങനെ?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
### DATETIME ### Get-Date -Format D : Tuesday, June 30, 2015 Get-Date -Format f : Tuesday, June 30, 2015 3:22 PM Get-Date -Format F : Tuesday, June 30, 2015 3:22:58 PM Get-Date -Format g : 6/30/2015 3:23 PM Get-Date -Format G : 6/30/2015 3:23:30 PM Get-Date -DisplayHint Date : Tuesday, June 30, 2015 Get-Date -DisplayHint DateTime : Tuesday, June 30, 2015 3:31:21 PM ### DATE ### Get-Date -Format d : 6/30/2015 Get-Date -Format yyyyMMdd : 20150630 Get-Date -UFormat '%d%m%Y' : 30062015 Get-Date -UFormat '%m%d%Y' : 06302015 Get-Date -UFormat '%Y%m%d' : 20150630 Get-Date -UFormat '%d.%m.%Y' : 30.06.2015 Get-Date -UFormat '%m.%d.%Y' : 06.30.2015 Get-Date -UFormat '%Y.%m.%d' : 2015.06.30 Get-Date -UFormat '%d-%m-%Y' : 30-06-2015 Get-Date -UFormat '%m-%d-%Y' : 06-30-2015 Get-Date -UFormat '%Y-%m-%d' : 2015-06-30 Get-Date -UFormat '%d/%m/%Y' : 30/06/2015 Get-Date -UFormat '%m/%d/%Y' : 06/30/2015 Get-Date -UFormat '%Y/%m/%d' : 2015/06/30 ### HOUR ### Get-Date -Format t : 3:23 PM Get-Date -Format T : 3:23:30 PM Get-Date -Format HH : 15 (Hour) Get-Date -Format mm : 28 (Minute) Get-Date -Format ss : 30 (Seconds) Get-Date -DisplayHint Time : 3:23:30 PM ### DAY ### Get-Date -Format dddd : Tuesday Get-Date -Format ddd : Tue Get-Date -Format dd : 30 ### MONTH ### Get-Date -Format MMMM : June Get-Date -Format MMM : Jun Get-Date -Format MM : 06 ### YEAR ### Get-Date -Format yyyy : 2015 |
PowerShell ഒരു തീയതി (സ്ട്രിംഗ്) ലേക്ക് തീയതി (തീയതി) പരിവർത്തനം എങ്ങനെ?
$datetimeToString = '{0:dd/MM/yy}' -f (Get-Date 30/01/2015)
$datetimeToString = (Get-Date 31/01/2015).ToShortDateString()
PowerShell ഒരു തീയതി (തീയതി) ലേക്ക് തീയതി (സ്ട്രിങ്) പരിവർത്തനം എങ്ങനെ?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# Solution 1 $stringToDatetime = '07/15/2015' | Get-Date $stringToDatetime = '07-15-2015' | Get-Date # Solution 2 $stringToDatetime = [Datetime]::ParseExact('07/15/2015', 'MM/dd/yyyy', $null) # Solution 3 $stringToDatetime = [Datetime]"7/15/2015" # Check $stringToDatetime Wednesday, July 15, 2015 12:00:00 AM $stringToDatetime.GetType().Name Datetime |
PowerShell രണ്ട് തീയതികൾ തമ്മിലുള്ള വ്യത്യാസം (ഡെയ്സ് എണ്ണം, മണിക്കൂറുകൾ, മിനിറ്റ്, അല്ലെങ്കിൽ സെക്കണ്ടുകൾ) കണക്കുകൂട്ടാൻ എങ്ങനെ?
(New-TimeSpan -Start $dateStart -End $dateEnd).Days
(New-TimeSpan -Start $dateStart -End $dateEnd).Hours
(New-TimeSpan -Start $dateStart -End $dateEnd).Minutes
(New-TimeSpan -Start $dateStart -End $dateEnd).Seconds
PowerShell രണ്ട് തീയതികൾ താരതമ്യം എങ്ങനെ?
(Get-Date 2015-01-01) -lt (Get-Date 2015-01-30) # True
(Get-Date 2015-01-01) -gt (Get-Date 2015-01-30) # False
PowerShell ഉപയോഗിച്ച് “തീയതി” എന്ന് തീയതികൾ ഒരു അറേ അടുക്കുന്നതിന് എങ്ങനെ?
$arrayDate | Sort-Object -Property {$_ -as [Datetime]}
PowerShell ഒരു സ്റ്റോപ്പ്വാച്ച് ആരംഭിക്കാൻ അവസാനിപ്പിക്കുകയും എങ്ങനെ?
$chrono = [Diagnostics.Stopwatch]::StartNew()
$chrono.Stop()
$chrono
PowerShell കൂടെ ആഴ്ചയിലെ നിലവിലെ ദിവസം എങ്ങനെ ലഭിക്കും?
(Get-Date).DayOfWeek #Sunday
PowerShell ഉപയോഗിച്ച് ഇന്നലെ തീയതി എങ്ങനെ ലഭിക്കും?
(Get-Date).AddDays(-1)
PowerShell കൊണ്ട് (ഫെബ്രുവരി 2015) ഒരു മാസത്തിൽ ദിവസം എണ്ണം എങ്ങനെ ലഭിക്കും?
[DateTime]::DaysInMonth(2015, 2)
PowerShell ഒരു അധിവർഷം അറിയാൻ എങ്ങനെ?
[DateTime]::IsLeapYear(2015)
PowerShell കൂടെ സമയ മേഖലകളും ലിസ്റ്റുചെയ്യുന്നതിന് എങ്ങനെ?
[System.TimeZoneInfo]::GetSystemTimeZones()
Networking
(ആസ്കി ഫോർമാറ്റ് വരെ) എന്കോഡു ചെയ്ത് PowerShell ഒരു URL- ഡീകോഡ് എങ്ങനെ?
1 2 3 4 5 6 7 8 9 |
# Encode $url = 'http://www.powershell-guru.com' $encoded = [System.Web.HttpUtility]::UrlEncode($url) # Decode $decoded = [System.Web.HttpUtility]::UrlDecode($encoded) # Encoded : http%3a%2f%2fwww.powershell-guru.com # Decoded : http://www.powershell-guru.com |
PowerShell കൂടെ നേറ്റീവ് നെറ്റ്വർക്ക് കമാൻഡുകൾ തുല്യമായവയിൽ എന്തൊക്കെയാണ്?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# ipconfig Get-NetIPConfiguration Get-NetIPAddress # ping Test-NetConnection # tracert Test-NetConnection -TraceRoute # route Get-NetRoute # nslookup Resolve-DnsName # Windows 8.1 & Windows 2012 ([System.Net.Dns]::GetHostEntry($IP)).Hostname # IP > PC ([System.Net.Dns]::GetHostAddresses($computer)).IPAddressToString # PC > IP |
PowerShell ഉപയോഗിച്ച് ഐപി വിലാസങ്ങൾ എങ്ങനെ ലഭിക്കും?
Get-NetIPAddress # Windows 8.1 & Windows 2012
Get-NetIPConfiguration # Windows 8.1 & Windows 2012
PowerShell ഉപയോഗിച്ച് ഐപി വിലാസം v6 (IPv6) അപ്രാപ്തമാക്കാൻ എങ്ങനെ?
1 |
New-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters' -Name 'DisabledComponents' -Value '0xFFFFFFFF' -PropertyType"DWORD" # Reboot required |
PowerShell ഒരു ഐപി വിലാസം v4 (IPv4-) മൂല്യനിർണ്ണയം എങ്ങനെ?
if([ipaddress]'10.0.0.1'){'validated'}
PowerShell കൂടെ ബാഹ്യ ഐ.പി. വിലാസം കണ്ടെത്തുന്നത് എങ്ങനെയാണ്?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
# Solution 1 (Invoke-WebRequest -Uri 'myexternalip.com/raw').Content (iwr -Uri 'myexternalip.com/raw').Content # Alias # Solution 2 $webClient = New-Object -TypeName System.Net.WebClient $webClient.DownloadString('http://myexternalip.com/raw') # Solution 3 while ($true) { Write-Output -InputObject "$(Get-Date) - $((Invoke-WebRequest -Uri 'http://myexternalip.com/raw' -Method Get).Content)" Start-Sleep -Seconds 300 } |
PowerShell ഒരു ഐപി വിലാസം നിന്ന് നെയിം കണ്ടെത്തുന്നത് എങ്ങനെയാണ്?
([System.Net.Dns]::GetHostEntry($IP)).Hostname
PowerShell ഒരു ഹോസ്റ്റ് നിന്നും ഐപി വിലാസം കണ്ടെത്തുന്നത് എങ്ങനെയാണ്?
([System.Net.Dns]::GetHostAddresses($computer)).IPAddressToString
PowerShell ഒരു ഹോസ്റ്റ് നിന്നും എഫ്ക്യൂഡിഎൻ കണ്ടെത്തുന്നത് എങ്ങനെയാണ്?
[System.Net.Dns]::GetHostByName($computer).HostName
1 |
Get-WmiObject -Class Win32_NetworkAdapterConfiguration | Format-Table -Property Description, IpAddress, IPSubnet, DefaultIPGateway, DNSServerSearchOrder |
PowerShell കൂടെ മാക് വിലാസം കണ്ടെത്തുന്നത് എങ്ങനെയാണ്?
Get-CimInstance win32_networkadapterconfiguration | Select-Object -Property Description, Macaddress
Get-WmiObject -Class win32_networkadapterconfiguration | Select-Object -Property Description, Macaddress
PowerShell കമ്പ്യൂട്ടർ പിംഗ് എങ്ങനെ?
1 2 3 4 5 6 |
# Solution 1 Test-Connection -ComputerName $computer -Quiet # Returns True / False # Solution 2 $ping = New-Object -TypeName System.Net.Networkinformation.Ping $ping.Send($computer) |
ഒരു കമ്പ്യൂട്ടർ PowerShell ഉപയോഗിച്ച് ഇന്റർനെറ്റ് കണക്ട് പരിശോധിക്കാൻ എങ്ങനെ?
1 |
[Activator]::CreateInstance([Type]::GetTypeFromCLSID([Guid]'{DCB00C01-570F-4A9B-8D69-199FDBA5723B}')).IsConnectedToInternet |
PowerShell ഒരു വെബ്സൈറ്റ് വേണ്ടി ഒരു “whois” സെർവർപോലെയുള്ള നടപ്പിലാക്കുന്നതിനുള്ള എങ്ങനെ?
$whois = New-WebServiceProxy 'http://www.webservicex.net/whois.asmx?WSDL'
$whois.GetWhoIs('powershell-guru.com')
PowerShell ഒരു പൊതു ഐപി (ജിയോലൊക്കേഷൻ) വിശദാംശങ്ങൾ എങ്ങനെ ലഭിക്കും?
1 2 |
$externalIP = (Invoke-WebRequest -Uri 'myexternalip.com/raw').Content $detailsIP = ([xml](Invoke-WebRequest -Uri "http://freegeoip.net/xml/$externalIP" -UseBasicParsing).Content).Response |
ഒരു പോർട്ട് PowerShell അടച്ചു / തുറന്ന എന്നത് പരിശോധിക്കാൻ എങ്ങനെ?
New-Object -TypeName Net.Sockets.TcpClient -ArgumentList $computer, 135
PowerShell കൂടെ “tracert” നടപ്പിലാക്കുന്നതിനായി എങ്ങനെ?
Test-NetConnection www.google.com -TraceRoute
PowerShell ഒരു ഹോം നെറ്റ്വർക്ക് കണക്ഷൻ പ്രൊഫൈൽ പരിഹരിക്കാൻ എങ്ങനെ?
Get-NetAdapter | Format-Table -Property Name, InterfaceDescription, ifIndex -AutoSize # Windows 8.1
Set-NetConnectionProfile -InterfaceIndex 6 -NetworkCategory Private
PowerShell ഉപയോഗിച്ച് TCP പോർട്ട് കണക്ഷനുകൾ കാണിക്കാൻ എങ്ങനെ?
netstat.exe -ano
Get-NetTCPConnection #Windows 8 and 2012
PowerShell ഒരു ചെറിയ യുആർഎൽ ഒരു നീണ്ട യുആർഎൽ ചുരുക്കി എങ്ങനെ?
$url = 'www.powershell-guru.com'
$tiny = Invoke-RestMethod -Uri "http://tinyurl.com/api-create.php?url=$url"
PowerShell ഉപയോഗിച്ച് പ്രോക്സി ക്രമീകരണം എങ്ങനെ ലഭിക്കും?
Get-ItemProperty -Path HKCU:"Software\Microsoft\Windows\CurrentVersion\Internet Settings"
DNS
PowerShell ഒരു പ്രാദേശിക കമ്പ്യൂട്ടറിൽ ഡിഎൻഎസ് കാഷെ പരിശോധിക്കാൻ എങ്ങനെ?
ipconfig.exe /displaydns
Get-DnsClientCache #Windows 8 and 2012
PowerShell ഒരു ലോക്കൽ കമ്പ്യൂട്ടറിൽ ഒരു ഡിഎൻഎസ് ക്യാഷെ എങ്ങനെ?
ipconfig.exe /flushdns
Start-Process -FilePath ipconfig -ArgumentList /flushdns -WindowStyle Hidden
Clear-DnsClientCache #Windows 8 and 2012
PowerShell കൂടെ റിമോട്ട് കമ്പ്യൂട്ടറുകളിൽ ഒരു ഡിഎൻഎസ് ക്യാഷെ എങ്ങനെ?
Invoke-Command -ScriptBlock {Clear-DnsClientCache} -ComputerName computer01, computer02
PowerShell സൈന്യങ്ങളുടെ ഫയൽ വായിക്കാൻ എങ്ങനെ?
Get-Content -Path 'C:\Windows\system32\drivers\etc\hosts'
Password
PowerShell ഒരു റാൻഡം പാസ്വേഡ് ഉൽപാദിപ്പിക്കുന്നതിൽ എങ്ങനെ?
[Reflection.Assembly]::LoadWithPartialName('System.Web')
[System.Web.Security.Membership]::GeneratePassword(30,2)
PowerShell ഒരു റിമോട്ട് സർവറിലുള്ള അഡ്മിനിസ്ട്രേറ്റർ പ്രാദേശിക പാസ്വേഡ് മാറ്റാൻ എങ്ങനെ?
$admin = [ADSI]('WinNT://server01/administrator,user')
$admin.SetPassword($password)
$admin.SetInfo()
1 2 3 4 5 6 7 8 |
# Solution 1 [DateTime]::FromFileTime((Get-ADUser -Identity $user -Properties 'msDS-UserPasswordExpiryTimeComputed').'msDS-UserPasswordExpiryTimeComputed') # Solution 2 Get-Date -Date ((Get-ADUser $user -Properties 'msDS-UserPasswordExpiryTimeComputed' | Select-Object -Property @{ Name = 'ExpiryDate' Expression = {[DateTime]::FromFileTime($_.'msDS-UserPasswordExpiryTimeComputed')} }).ExpiryDate)-Format 'F' |
Printers
PowerShell ഒരു പ്രത്യേക സെർവർ എല്ലാ പ്രിന്ററുകൾ ലിസ്റ്റുചെയ്യുന്നതിന് എങ്ങനെ?
Get-WmiObject -Query 'Select * From Win32_Printer' -ComputerName $computer
PowerShell ഒരു പ്രത്യേക സെർവർ എല്ലാ പോർട്ടുകളും ലിസ്റ്റുചെയ്യുന്നതിന് എങ്ങനെ?
Get-WmiObject -Class Win32_TCPIPPrinterPort -Namespace 'root\CIMV2' -ComputerName $computer
PowerShell ഒരു പ്രിന്ററിന്റെ അഭിപ്രായം / സ്ഥലം മാറ്റാൻ എങ്ങനെ?
1 2 3 4 |
$printer = Get-WmiObject -Class win32_printer -Filter "Name='HP Deskjet 2540 series'" $printer.Location = 'Germany' $printer.Comment = 'Printer - Test' $printer.Put() |
PowerShell ഒരു പ്രിന്ററിൽ (എല്ലാ ജോലികളും റദ്ദാക്കുക) വെടിപ്പാക്കുവാൻ എങ്ങനെ?
$printer = Get-WmiObject -Class win32_printer -Filter "Name='HP Deskjet 2540 series'"
$printer.CancelAllJobs()
PowerShell ഒരു പ്രിന്റർ ഒരു പരിശോധന പേജ് അച്ചടിക്കുക എങ്ങനെ?
$printer = Get-WmiObject -Class win32_printer -Filter "Name='HP Deskjet 2540 series'"
$printer.PrintTestPage()
PowerShell പ്രിന്റേഴ്സിലെ വേണ്ടി അച്ചടി ക്യൂകൾ എങ്ങനെ ലഭിക്കും?
1 2 3 4 |
Get-WmiObject -Class Win32_PerfFormattedData_Spooler_PrintQueue | Select-Object -Property Name, @{ Expression = {$_.jobs} Label = 'Current Jobs' } | Format-Table -AutoSize |
Regedit
Read
PowerShell ഉപയോഗിച്ച് രജിസ്ട്രി തേനീച്ചക്കൂടുകൾ ലിസ്റ്റുചെയ്യുന്നതിന് എങ്ങനെ?
Get-ChildItem -Path Registry::
രജിസ്ട്രി മൂല്യങ്ങളും PowerShell കൂടെ മൂല്യം തരം എങ്ങനെ ലഭിക്കും?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
function Get-RegistryValue { Param ( [Parameter(Mandatory = $true)] [string]$RegistryKey ) $key = Get-Item -Path "Registry::$RegistryKey" $key.GetValueNames() | Sort-Object | ForEach-Object -Process { $name = $_ $type = $key.GetValueKind($name) switch ($type) { 'String' {'REG_SZ'} 'Binary' {'REG_BINARY'} 'Dword' {'REG_DWORD'} 'Qword' {'REG_QWORD'} 'MultiString' {'REG_MULTI_SZ'} 'ExpandString'{'REG_EXPAND_SZ'} Default {$null} } [PSCustomObject]@{ Name = $name Type = $type Data = $key.GetValue($name) } } } |
PowerShell കൂടെ രജിസ്ട്രി കീ subkeys ലിസ്റ്റുചെയ്യുന്നതിന് എങ്ങനെ?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
#HKEY_CLASSES_ROOT New-PSDrive -PSProvider Registry -Root HKEY_CLASSES_ROOT -Name HKCR Get-ChildItem -Path 'HKCR:\' #HKEY_CURRENT_USER Get-ChildItem -Path 'HKCU:\Software' Get-ChildItem -Path Registry::HKEY_CURRENT_USER #HKEY_LOCAL_MACHINE Get-ChildItem -Path 'HKLM:\SYSTEM' Get-ChildItem -Path Registry::HKEY_LOCAL_MACHINE #HKEY_USERS New-PSDrive -PSProvider Registry -Root HKEY_USERS -Name HKU Get-ChildItem -Path 'HKU:\' #HKEY_CURRENT_CONFIG New-PSDrive -PSProvider Registry -Root HKEY_CURRENT_CONFIG -Name HKCC Get-ChildItem -Path 'HKCC:\' |
PowerShell ഒരു കാഷ്ഡ് വിധത്തിൽ രജിസ്ട്രി കീ subkeys ലിസ്റ്റുചെയ്യുന്നതിന് എങ്ങനെ?
Get-ChildItem -Path 'HKLM:\SYSTEM' -Recurse -ErrorAction SilentlyContinue
PowerShell ഒരു പ്രത്യേക നാമമുള്ള subkeys കണ്ടെത്തുന്നത് എങ്ങനെയാണ്?
Get-ChildItem -Path 'HKLM:\SOFTWARE' -Include *Plugin* -Recurse -ErrorAction SilentlyContinue
PowerShell കൂടെ രജിസ്ട്രി subkeys പേര് മാത്രമാണ് മടക്കി എങ്ങനെ?
(Get-ChildItem -Path 'HKLM:\SYSTEM').Name # Return HKEY_LOCAL_MACHINE\SYSTEM\ControlSet
Get-ChildItem -Path 'HKLM:\SYSTEM' -Name # Return ControlSet
PowerShell ഉപയോഗിച്ച് രജിസ്ട്രി മൂല്യങ്ങൾ ലിസ്റ്റുചെയ്യുന്നതിന് എങ്ങനെ?
Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion'
PowerShell ഒരു പ്രത്യേക രജിസ്ട്രി മൂല്യം എങ്ങിനെ വായിക്കാം?
(Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion').ProductName
PowerShell ഒരു റിമോട്ട് കമ്പ്യൂട്ടറിൽ ഒരു പ്രത്യേക രജിസ്ട്രി മൂല്യം എങ്ങിനെ വായിക്കാം?
1 2 3 4 5 |
$hostname = $computer $openRegedit = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $hostname) $openKey = $openRegedit.OpenSubKey('SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion') $keyValue = $openKey.GetValue('ProductName') $keyValue |
Write
PowerShell ഒരു പുതിയ രജിസ്ട്രി കീ സൃഷ്ടിക്കുന്നതിന് എങ്ങനെ?
New-Item -Path 'HKCU:\Software\MyApplication'
PowerShell ഒരു രജിസ്ട്രി മൂല്യം സൃഷ്ടിക്കാൻ എങ്ങനെ?
New-ItemProperty -Path 'HKCU:\Software\MyApplication' -Name 'Version' -Value '1.0'
PowerShell ഒരു നിലവിലുള്ള രജിസ്ട്രി മൂല്യം മാറ്റം എങ്ങനെ?
Set-ItemProperty -Path 'HKCU:\Software\MyApplication' -Name 'Version' -Value '2.0'
Delete
PowerShell ഒരു രജിസ്ട്രി മൂല്യം ഇല്ലാതാക്കാൻ എങ്ങനെ?
Remove-ItemProperty -Path 'HKCU:\Software\MyApplication' -Name 'Version'
PowerShell ഒരു രജിസ്ട്രി കീ ഇല്ലാതാക്കാൻ എങ്ങനെ?
Remove-Item -Path 'HKCU:\Software\MyApplication' -Force
Test
ഒരു രജിസ്ട്രി കീ PowerShell നിലവിലുള്ളതിനാൽ പരിശോധിക്കുവാന് എങ്ങനെ?
Test-Path -Path 'HKCU:\Software\MyApplication'
ഒരു രജിസ്ട്രി മൂല്യം PowerShell നിലവിലുള്ളതിനാൽ പരിശോധിക്കുവാന് എങ്ങനെ?
(Get-Item -Path 'HKCU:\Software\MyApplication').GetValueNames() -contains 'Version'
Strings
PowerShell ഒരു സ്ട്രിംഗ് തുടക്കം വൈറ്റ്-സ്പെയ്സ് പ്രതീകങ്ങൾ നീക്കം എങ്ങനെ?
$string = ' PowershellGuru'
$string = $string.TrimStart()
PowerShell ഒരു സ്ട്രിംഗ് അറ്റം വൈറ്റ്-സ്പെയ്സ് പ്രതീകങ്ങൾ നീക്കം എങ്ങനെ?
$string = 'PowershellGuru '
$string = $string.TrimEnd()
PowerShell ഒരു സ്ട്രിംഗ് വെളുത്ത-സ്പെയ്സ് പ്രതീകങ്ങൾ (തുടങ്ങി അവസാനമുള്ള) നീക്കം എങ്ങനെ?
$string = ' PowershellGuru '
$string = $string.Trim()
PowerShell മുകളിലും കേസിൽ ഒരു സ്ട്രിംഗ് പരിവർത്തനം എങ്ങനെ?
$string = 'powershellguru'
$string = $string.ToUpper()
PowerShell കൊണ്ട് കേസിൽ ഒരു സ്ട്രിംഗ് പരിവർത്തനം എങ്ങനെ?
$string = 'POWERSHELLGURU'
$string = $string.ToLower()
സ്ട്രിംഗ് സംജഞകള് “PowerShell” തിരഞ്ഞെടുക്കുക എങ്ങനെ PowerShell ഉപയോഗിച്ച് “PowerShellGuru”?
$string.Substring(0,10)
PowerShell ഉപയോഗിച്ച് സ്ട്രിംഗ് ‘PowerShellGuru “എന്ന” ഗുരു “സംജഞകള് തിരഞ്ഞെടുക്കുക എങ്ങനെ?
$string.Substring(10)
PowerShell ഉപയോഗിച്ച് “PowerShell123Guru” എണ്ണത്തിൽ “123” തിരഞ്ഞെടുക്കുക എങ്ങനെ?
$string = 'Powershell123Guru'
[regex]::match($string,'(\d+)').value
PowerShell കൂടെ സ്ട്രിംഗ് “ഗുരു” “PowerShellGuru” എന്ന പൂജ്യം അധിഷ്ഠിത സൂചിക എങ്ങനെ ലഭിക്കും?
$string.IndexOf('Guru') # 10
ഒരു സ്ട്രിംഗ് PowerShell ഉപയോഗിച്ച് അസാധുവോ ശൂന്യമാണ് പരിശോധിക്കാൻ എങ്ങനെ?
$string = $null
$string = ''
[string]::IsNullOrEmpty($string)
ഒരു സ്ട്രിംഗ് ശൂന്യമായ, നൾ അല്ലെങ്കിൽ PowerShell വെളുത്ത-സ്പെയ്സ് കഥാപാത്രങ്ങളുടെ മാത്രമേ അടങ്ങുന്നതാണ് പരിശോധിക്കാൻ എങ്ങനെ?
$string = $null
$string = ''
$string = ' '
[string]::IsNullOrWhiteSpace($string)
ഒരു സ്ട്രിംഗ് PowerShell ഒരു പ്രത്യേക കത്ത് അടങ്ങിയിരിക്കുന്നു പരിശോധിക്കാൻ എങ്ങനെ?
$string = 'PowershellGuru'
$string.Contains('s')
[regex]::match($string,'s').Success
PowerShell ഒരു സ്ട്രിംഗ് നീളം മടക്കി എങ്ങനെ?
$string.Length
PowerShell രണ്ട് സ്ട്രിങ്ങുകൾ concatenate എങ്ങനെ?
1 2 3 4 5 6 7 |
# Solution 1 $string1 + $string2 # Solution 2 $string1 = 'Powershell' $string2 = 'Guru' [string]::Concat($string1,$string2) |
PowerShell ഒരു സ്ട്രിംഗ് ലെ “[]” ഒന്നോ അതിലധികമോ ബ്രാക്കറ്റിലുള്ളത് വേണ്ടി പൊരുത്തപ്പെടുന്ന എങ്ങനെ?
$string = '[PowershellGuru]'
$string -match '\[' # Only 1
$string -match '\[(.*)\]' # Several
PowerShell ഒരു സ്ട്രിംഗ് ഒന്നോ പല ബ്രാക്കറ്റിൽ “()” എന്ന പൊരുത്തപ്പെടുന്ന എങ്ങനെ?
$string = '(PowershellGuru)'
$string -match '\(' # Only 1
$string -match '\((.*)\)' # Several
PowerShell ഒരു സ്ട്രിംഗ് ഒന്നോ നിരവധി ചുരുണ്ട ബ്രാക്കറ്റുകൾ “{}” എന്ന പൊരുത്തപ്പെടുന്ന എങ്ങനെ?
$string = '{PowershellGuru}'
$string -match '\{' # Only 1
$string -match '\{(.*)\}' # Several
ഒന്നോ PowerShell ഒരു സ്ട്രിംഗ് നിരവധി ആങ്കിൾ ബ്റാക്കറ്റുകളിൽ “<>” വേണ്ടി പൊരുത്തപ്പെടുന്ന എങ്ങനെ?
$string = ''
$string -match '\<' # Only 1
$string -match "\<(.*)\>" # Several
PowerShell ഒരു സ്ട്രിംഗ് ഏതെങ്കിലും ചെറിയ അക്ഷരങ്ങൾ (ABC) പൊരുത്തപ്പെടുന്ന എങ്ങനെ?
$string = 'POWERSHELLGURU'
$string -cmatch "^[a-z]*$" #False
PowerShell ഒരു സ്ട്രിംഗ് ഏതെങ്കിലും upperletters (എബിസി) പൊരുത്തപ്പെടുന്ന എങ്ങനെ?
$string = 'powershellguru'
$string -cmatch "^[A-Z]*$" #False
PowerShell ഒരു സ്ട്രിംഗ് ലെ “[പേ” (പേ ലോവർ കേസ്) പൊരുത്തപ്പെടുന്ന എങ്ങനെ?
$string = '[powershellGuru]'
$string -cmatch '\[[a-z]\w+' #True
PowerShell ഒരു സ്ട്രിംഗ് ലെ “[പി” (പി അപ്പർ കേസ്) പൊരുത്തപ്പെടുന്ന എങ്ങനെ?
$string = '[PowershellGuru]'
$string -cmatch '\[[A-Z]\w+' #True
PowerShell മറ്റൊരു വരി ഒരു ലൈൻ പകരം എങ്ങനെ?
$a = 'Line A'
$b = 'Line B'
$a = $a -replace $a, $b
PowerShell ഒരു സ്ട്രിംഗ് (ശതമാനം) ഒരു ഡിവിഷൻ പ്രവർത്തനം പരിവർത്തനം എങ്ങനെ?
(1/2).ToString('P')
PowerShell കൂടെ നമ്പറുകൾ അടങ്ങിയ സ്ട്രിങ്ങുകൾ അടുക്കുന്നതിന് എങ്ങനെ?
1 |
'string-10', 'string-2', 'string-23', 'string-30' | Sort-Object -Property {$_ -replace '[\d]'}, {$_ -replace '[a-zA-Z\p{P}]'-as [int]} |
PowerShell ഒരു വാക്യത്തിന്റെ അവസാന പദം തിരഞ്ഞെടുക്കാൻ എങ്ങനെ?
$sentence = 'My name is Test Powershell'
$sentence.Split(' ')[-1] # Returns Powershell
PowerShell കൂടെ ഒരു വാക്യത്തിന്റെ വലിയ വചനം എങ്ങനെ ലഭിക്കും?
$sentence = 'My name is Test Powershell'
$sentence.Split(' ') | Sort-Object -Property Length | Select-Object -Last 1 # Returns Powershell
എത്ര തവണ ഒരു സ്ട്രിംഗ് count എങ്ങനെ PowerShell ഒരു വിധി യാഥാര്ഥ്യമാകുകയും?
$sentence = 'test test test Powershell'
[regex]::Matches($sentence, 'test').Count # Returns 3
PowerShell ഒരു കഥാപാത്രം അറേ ഒരു സ്ട്രിംഗ് ഓരോ അക്ഷരം പകർത്താനും എങ്ങനെ?
1 2 3 4 5 6 7 |
$name = 'test' $name.ToCharArray() s t e v e |
PowerShell ഒരു സ്ട്രിംഗ് അപ്പർകേസ് ആദ്യ കത്ത് പരിവർത്തനം എങ്ങനെ?
1 2 |
$name = 'test' $name.Substring(0,1).ToUpper() + $name.Substring(1) |
എങ്ങനെ PowerShell ഉപയോഗിച്ച് പാഡ് (ഇടത് അല്ലെങ്കിൽ വലത്) ഒരു സ്ട്രിംഗ് വരെ?
1 2 3 4 5 6 7 |
# With whitespaces $padRight = 'test'.PadRight(25) $padLeft = 'test'.PadLeft(25) # With characters $padRight = 'test'.PadRight(25,'.') # Return test.................... $padLeft = 'test'.PadLeft(25,'.') # Return ....................test |
PowerShell കൂടെ റിപ്പോർട്ടുചെയ്യുക Base64- ഒരു സ്ട്രിംഗ് എന്കോഡു ചെയ്ത് ഡീകോഡ് എങ്ങനെ?
1 2 3 4 5 6 7 8 9 10 |
# Encode $string = [System.Text.Encoding]::UTF8.GetBytes('test') $encoded = [System.Convert]::ToBase64String($string) # Decode $string = [System.Convert]::FromBase64String($encoded) $decoded = [System.Text.Encoding]::UTF8.GetString($string) # Encoded : c3RldmU= # Decoded : test |
PowerShell ഒരു എണ്ണം (നിന്നും) ബൈനറി പരിവർത്തനം എങ്ങനെ?
1 2 3 4 5 |
# Base 10 to Base 2 [System.Convert]::ToString(255,2) # Base 2 to Base 10 [System.Convert]::ToInt32('11111111',2) |
PowerShell ഒരു പാതയിൽ മാത്രം അവസാന പാരന്റ് ഫോൾഡർ മടക്കി എങ്ങനെ?
1 2 |
$path = 'C:\Folder1\Folder2\Folder3\file.txt' Split-Path -Path (Split-Path -Path $path -Parent) -Leaf # Return Folder3 |
PowerShell ഒരു പാതയിൽ മാത്രം അവസാന ഇനം മടക്കി എങ്ങനെ?
1 2 |
$path = 'C:\Folder1\Folder2\Folder3\file.txt' Split-Path -Path $path -Leaf # Return file.txt |
Math
PowerShell കൂടെ System.Math വർഗത്തിന്റെ രീതികൾ ലിസ്റ്റുചെയ്യുന്നതിന് എങ്ങനെ?
[System.Math] | Get-Member -Static -MemberType Method
PowerShell കൂടെ പരമമായ മൂല്യം മടക്കി എങ്ങനെ?
[Math]::Abs(-12) #Returns 12
[Math]::Abs(-12.5) # Returns 12.5
ആരുടെ Sine PowerShell വ്യക്തമാക്കിയിട്ടുള്ള എണ്ണം ആംഗിൾ മടക്കി എങ്ങനെ?
[Math]::ASin(1) #Returns 1,5707963267949
PowerShell ഉപയോഗിച്ച് സീലിങ് മൂല്യം മടക്കി എങ്ങനെ?
[Math]::Ceiling(1.4) #Returns 2
[Math]::Ceiling(1.9) #Returns 2
PowerShell കൂടെ മൂന്ന് മൂല്യം മടക്കി എങ്ങനെ?
[Math]::Floor(1.4) #Returns 1
[Math]::Floor(1.9) #Returns 1
PowerShell ഒരു വ്യക്തമാക്കിയ എണ്ണം സ്വാഭാവിക (ബേസ് ഇ) ലോഗരിതം മടക്കി എങ്ങനെ?
[Math]::Log(4) #Returns 1,38629436111989
PowerShell ഒരു വ്യക്തമാക്കിയ എണ്ണം അടിത്തറ 10 ലോഗരിതം മടക്കി എങ്ങനെ?
[Math]::Log10(4) #Returns 0,602059991327962
PowerShell രണ്ട് മൂല്യങ്ങളുടെ പരമാവധി മടക്കി എങ്ങനെ?
[Math]::Max(2,4) #Returns 4
[Math]::Max(-2,-4) #Returns -2
PowerShell രണ്ട് മൂല്യങ്ങളുടെ കുറഞ്ഞത് മടക്കി എങ്ങനെ?
[Math]::Min(2,4) #Returns 2
[Math]::Max(-2,-4) #Returns -4
PowerShell ഒരു വ്യക്തമാക്കിയ അധികാരത്തിൽ ഉയർത്തുകയും ഒരു നമ്പർ മടക്കി എങ്ങനെ?
[Math]::Pow(2,4) #Returns 16
PowerShell അടുത്തുള്ള സമഗ്രവുമായ മൂല്യം ഒരു ഡെസിമൽ മൂല്യം മടക്കി എങ്ങനെ?
[Math]::Round(3.111,2) #Returns 3,11
[Math]::Round(3.999,2) #Returns 4
PowerShell ഒരു വ്യക്തമാക്കിയ ദശാംശ നമ്പറിന്റെ അവിഭാജ്യ മടക്കി എങ്ങനെ?
[Math]::Truncate(3.111) #Returns 3
[Math]::Truncate(3.999) #Returns 3
PowerShell ഒരു വ്യക്തമാക്കിയ എണ്ണം സ്ക്വയർ റൂട്ട് മടക്കി എങ്ങനെ?
[Math]::Sqrt(16) #Returns 4
PowerShell ഉപയോഗിച്ച് പി.ഐ. നിരന്തരമായ മടക്കി എങ്ങനെ?
[Math]::Pi #Returns 3,14159265358979
PowerShell ഉപയോഗിച്ച് പ്രകൃതിദത്തമായ ലോഗരിതമിക് അടിത്തറ (നിരന്തരമായ ഇ) മടക്കി എങ്ങനെ?
[Math]::E #Returns 2,71828182845905
ഒരു നമ്പർ PowerShell പോലും അല്ലെങ്കിൽ ഒറ്റയായി എന്നത് പരിശോധിക്കാൻ എങ്ങനെ?
[bool]($number%2)
Hashtables
PowerShell ഒരു ശൂന്യമായ hashtable സൃഷ്ടിക്കാൻ എങ്ങനെ?
$hashtable = @{}
$hashtable = New-Object -TypeName System.Collections.Hashtable
PowerShell ഇനങ്ങൾ ഒരു hashtable സൃഷ്ടിക്കാൻ എങ്ങനെ?
1 2 3 4 5 |
$hashtable = @{ 'Key1' = 'Value1' 'Key2' = 'Value2' 'Key3' = 'Value3' } |
PowerShell ഇനങ്ങൾ കൂടി കീ / പേര് (ഉത്തരവിട്ടു നിഘണ്ടു) തരംതിരിച്ച ഒരു hashtable സൃഷ്ടിക്കാൻ എങ്ങനെ?
1 2 3 4 5 6 7 |
$hashtable = [ordered]@{ 'Key1' = 'Value1' 'Key2' = 'Value2' 'Key3' = 'Value3' } $hashtable | Get-Member # System.Collections.Specialized.OrderedDictionary |
PowerShell ഒരു hashtable ഇനങ്ങൾ (കീ-മൂല്ല്യം ജോഡി) ചേർക്കാൻ എങ്ങനെ?
$hashtable.Add('Key3', 'Value3')
PowerShell ഒരു hashtable ഒരു പ്രത്യേക മൂല്യം എങ്ങനെ ലഭിക്കും?
$hashtable.Key1
$hashtable.Get_Item('Key1')
PowerShell ഒരു hashtable മിനിമം മൂല്യം എങ്ങനെ ലഭിക്കും?
1 2 3 4 5 6 7 8 |
$hashtable = @{ 'Key1' = '1' 'Key2' = '2' 'Key3' = '3' } $hashtable.GetEnumerator() | Sort-Object -Property Value | Select-Object -First 1 $hashtable.GetEnumerator() | Sort-Object -Property Value -Descending | Select-Object -Last 1 |
PowerShell ഒരു hashtable പരമാവധി മൂല്യം എങ്ങനെ ലഭിക്കും?
1 2 3 4 5 6 7 8 |
$hashtable = @{ 'Key1' = '1' 'Key2' = '2' 'Key3' = '3' } $hashtable.GetEnumerator() | Sort-Object -Property Value -Descending | Select-Object -First 1 $hashtable.GetEnumerator() | Sort-Object -Property Value | Select-Object -Last 1 |
PowerShell ഒരു hashtable ഇനങ്ങൾ മാറ്റം എങ്ങനെ?
$hashtable.Set_Item('Key1', 'Value1Updated')
PowerShell ഒരു hashtable ഇനങ്ങൾ നീക്കം എങ്ങനെ?
$hashtable.Remove('Key1')
PowerShell ഒരു hashtable ക്ലിയർ എങ്ങനെ?
$hashtable.Clear()
PowerShell ഒരു hashtable ഒരു പ്രത്യേക കീ / മൂല്യം സാന്നിദ്ധ്യം പരിശോധിക്കാൻ എങ്ങനെ?
$hashtable.ContainsKey('Key3')
$hashtable.ContainsValue('Value3')
PowerShell ഒരു hashtable കീ / മൂല്യം അടുക്കുന്നതിന് എങ്ങനെ?
$hashtable.GetEnumerator() | Sort-Object -Property Name
$hashtable.GetEnumerator() | Sort-Object -Property Value -Descending
Arrays
PowerShell ഒരു ശൂന്യമായ അറേ സൃഷ്ടിക്കാൻ എങ്ങനെ?
$array = @()
$array = [System.Collections.ArrayList]@()
PowerShell ഇനങ്ങൾ ഒരു അറേ സൃഷ്ടിക്കാൻ എങ്ങനെ?
$array = @('A', 'B', 'C')
$array = 'A', 'B', 'C'
$array = 'a,b,c'.Split(',')
$array = .{$args} a b c
$array = echo a b c
PowerShell ഒരു അറേ ഇനങ്ങൾ ചേർക്കാൻ എങ്ങനെ?
$array += 'D'
[void]$array.Add('D')
PowerShell ഒരു അണിനിരന്നു ഒരു ഇനം മാറ്റം എങ്ങനെ?
$array[0] = 'Z' # 1st item[0]
PowerShell ഒരു അറേ വലിപ്പം പരിശോധിക്കാൻ എങ്ങനെ?
$array = 'A', 'B', 'C'
$array.Length # Returns 3
PowerShell ഒരു അണിനിരന്നു ഒരിനം / നിരവധി / എല്ലാ ഇനങ്ങളും വീണ്ടെടുക്കാൻ എങ്ങനെ?
$array = @('A', 'B', 'C')
$array[0] # One item (A)
$array[0] + $array[2] # Several items (A,C)
$array # All items (A,B,C)
PowerShell ഒരു അണിനിരന്നു ശൂന്യമായ ഇനങ്ങൾ നീക്കം എങ്ങനെ?
$array = @('A', 'B', 'C', '')
$array = $array.Split('',[System.StringSplitOptions]::RemoveEmptyEntries) | Sort-Object # A,B,C
ഒരു ഇനം PowerShell ഒരു അണിനിരന്നു നിലവിലുണ്ട് പരിശോധിക്കാൻ എങ്ങനെ?
$array = @('A', 'B', 'C')
'A' | ForEach-Object -Process {$array.Contains($_)} # Returns True
'D' | ForEach-Object -Process {$array.Contains($_)} # Returns False
PowerShell ഒരു അണിനിരന്നു ഒരു ഇനത്തിന്റെ സൂചിക എണ്ണം കണ്ടെത്തുക എങ്ങനെ?
$array = @('A', 'B', 'C')
[array]::IndexOf($array,'A') # Returns 0
PowerShell ഒരു അണിനിരന്നു ഇനങ്ങൾ ക്രമം റിവേഴ്സ് എങ്ങനെ?
$array = @('A', 'B', 'C')
[array]::Reverse($array) # C,B,A
PowerShell ഒരു അറേ നിന്നും ഒരു റാൻഡം ഇനം ഉൽപാദിപ്പിക്കുന്നതിൽ എങ്ങനെ?
$array | Get-Random
PowerShell ഒരു ആരോഹണ / ഇറങ്ങുന്നതും വഴിയിൽ ഒരു അറേ അടുക്കുന്നതിന് എങ്ങനെ?
$array = @('A', 'B', 'C')
$array | Sort-Object # A,B,C
$array | Sort-Object -Descending # C,B,A
PowerShell ഒരു അണിനിരന്നു ഇനങ്ങൾ എണ്ണം കണക്കാക്കാനും എങ്ങനെ?
$array.Count
PowerShell വേറെ ഒരു അറേ ചേർക്കാൻ എങ്ങനെ?
$array1 = 'A', 'B', 'C'
$array2 = 'D', 'E', 'F'
$array3 = $array1 + $array2 # A,B,C,D,E,F
PowerShell ഒരു അറേ നിന്ന് തനിപ്പകർപ്പുകൾ കണ്ടെത്തുന്നത് എങ്ങനെയാണ്?
$array = 'A', 'B', 'C', 'C'
($array