FAQ POWERSHELL CHIKIN HAUSA

By | May 15, 2015

translated-nigeria


beta-v2-0


Ra’ayi : Mafi akai-akai tambaye tambayoyi game da PowerShell.

Za ka iya amfani da wannan tsarin sunaye a hanyoyi daban-daban :

  • Don kwafe / manna dokokin cikin wani rubutun
  • Ganin sauri da ginin kalma da wani umurnin
  • Wajen inganta fasaha da ilmi
  • Don gano sababbin dokokin
  • Don shirya wani aiki hira

Har kwanan wata
Yuli 02, 2015
Marubucin Steve Renard
Mafari hausa-language.powershell-guru.com
Rukuni
75
Tambayoyi
610


ACL
Active Directory
Alias
Arrays
Browsers
Certificates
Characters
CIM
Comments
COM Objects
Compare
Computer
Credentials
CSV
Culture
Date
Drives
Environment
Errors
Event Viewer
Files
Folders
Format Operator (-f)
Functions
GPO
GUI
Hardware
Hashtables
Help
History
Jobs
Keyboard
Loops
Math
Memory
Messages
Modules
Microsoft Excel
Microsoft Exchange
Microsoft Outlook
Microsoft SharePoint
Networking
Openfiles
Operators
Parameters
Password
Powershell ISE
Printers
Processes
PSObject
Quest
Random
RDP
Regedit
Regex
Remote
Restore
Scheduled Tasks
Search
SCCM
Services
SMTP
Snapins
Sounds
Static .NET Methods
Strings
System
Try/Catch
Variables
Symantec Vault
Windows10
Windows 2012
Windows Azure
Windows Forms
WMI
XML

System

Yadda za a tantance ta irin ra’ayi na PowerShell?

Yadda za a gudanar da PowerShell a wani irin ra’ayi domin baya karfinsu?
powershell.exe -Version 2.0

Yadda za a buƙaci kadan PowerShell irin ra’ayi (3.0 kuma mafi girma) a cikin wani rubutun hannu da PowerShell?
#Requires -Version 3.0

Yadda za a buƙaci Gudanarwa gata ga wani rubutun hannu da PowerShell?

Yadda za a duba sigogi da wani rubutun hannu da PowerShell?
help -Name .\Get-ExchangeEnvironmentReport.ps1 -Full

Yadda za a samu bayanai ga na yanzu mai amfani da PowerShell?
[Security.Principal.WindowsIdentity]::GetCurrent()

Yadda za ka ƙirƙiri, shirya, da kuma ƙari bayanin martaba da PowerShell?

Yadda za a yi a ɗan hutu of seconds / minti biyar cikin wani rubutun hannu da PowerShell?
Start-Sleep -Seconds 5
Start-Sleep -Seconds 300 # 5 minutes

Yadda za a samu ta ƙarshe taya lokaci da PowerShell?
(Get-CimInstance -ClassName win32_operatingsystem).LastBootUpTime

Yadda za a samu irin totur da PowerShell?

Yadda za a jerin shirye-shirye da farawa da PowerShell?

Yadda za a kawar aikace-aikace tare da PowerShell?

Yadda za a yi a allon harbi na dukan tebur ko na wani aiki taga da PowerShell?
Take-ScreenShot -Screen -File 'C:\scripts\screenshot.png' -Imagetype JPEG
Repository : Take-ScreenShot

Yadda za a samu da sakon ƙidaya ga MSMQ queues da PowerShell?

Yadda za a saita kisa da manufofin da PowerShell?

Yadda za ka ƙirƙiri wani gajerar hanya tare da PowerShell?

Yadda za a fil ko kawar a shirin da taskbar da PowerShell?

Yadda za a bude wani Windows Explorer da PowerShell?
[Diagnostics.Process]::Start('explorer.exe')
Invoke-Item -Path C:\Windows\explorer.exe

Yadda za a jerin na’urar direbobi da PowerShell?
Get-WmiObject -Class Win32_PnPSignedDriver
Get-WindowsDriver -Online -All
driverquery.exe

Yadda za ka ƙirƙiri wani GUID da PowerShell?

Yadda za a samu wurin da wucin gadi littafin adireshi domin na yanzu mai amfani da PowerShell?
[System.IO.Path]::GetTempPath()

Yadda za a shiga a hanyar da yaro hanya zuwa cikin daya guda hanyar da PowerShell?
Join-Path -Path C:\ -ChildPath \windows

Yadda za a jerin duk cmdlets “Samu- *” da PowerShell?
Get-Command -Verb Get

Yadda za a jerin musamman tsarin manyan fayiloli tare da PowerShell?

Yadda za a Dutsen ISO / VHD fayiloli tare da PowerShell?
Mount-DiskImage 'D:\ISO\file.iso' # ISO
Mount-DiskImage 'D:\VHD\file.vhd' # VHD

Yadda za a duba .NET Tsarin iri shigar da PowerShell?

Yadda za a duba idan .NET Tsarin irin ra’ayi 4.5 aka shigar da PowerShell?
(Get-ItemProperty -Path 'HKLM:\Software\Microsoft\NET Framework Setup\NDP\v4\Full' -EA 0).Version -like '4.5*'

Yadda za a fara da kuma dakatar da wani kwafi (ya halicci rikodin na Windows PowerShell zaman) da PowerShell?
Start-Transcript -Path 'C:\scripts\transcript.txt
Stop-Transcript

Yadda za a canja halin yanzu directory zuwa wani wuri da PowerShell?
Set-Location -Path 'C:\scripts'

Yadda za a share allon tare da PowerShell?
Clear-Host
cls # Alias

Yadda za a canja nuni ƙuduri da PowerShell?
Set-DisplayResolution -Width 1280 -Height 1024 -Force # Windows 2012

Yadda za a saita “cikakke allon” taga da PowerShell?
mode.com 300

Yadda za a samu girma (nisa da tsawo) na hoto tare da PowerShell?

Yadda za a samu da Windows samfurin mabudi da PowerShell?

Perfmon

Yadda za a samu na yanzu “% cin gaba Lokaci” (talakawan), a cikin shekaru 5 seconds (10 sau) da PowerShell?
(Get-Counter '\Processor(_total)\% Processor Time' -SampleInterval 5 -MaxSamples 10).CounterSamples.CookedValue

Assemblies

Yadda za a labta majalisai da PowerShell?

Yadda za a duba halin yanzu .NET majalisai ɗora Kwatancen da PowerShell?

Yadda za a sami GAC (Duniya Majalisar Kache) hanyar da PowerShell?

Clipboard

Yadda za a kwafa da sakamakon da allo mai rike takarda tare da PowerShell?

Yadda za a samu da abun ciki na allo mai rike takarda tare da PowerShell?
Add-Type -AssemblyName PresentationCore
[Windows.Clipboard]::GetText()

Hotfixes

Yadda za a samu da zafi gyaran gaba daya shigar da PowerShell?
Get-HotFix -ComputerName $computer

Yadda za a samu da zafi gyaran gaba daya shigar a gaban / bayan wani kwanan wata da 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

Yadda za a duba ne idan wata zafi gyaran gaba daya aka shigar da PowerShell?
Get-HotFix -Id KB2965142

Yadda za a samu da zafi gyaran gaba daya shigar a kan wani m kwamfuta da PowerShell?
Get-HotFix -ComputerName $computer

Pagefile

Yadda za a samu na boye bayanai da PowerShell?
Get-WmiObject -Class Win32_PageFileusage | Select-Object -Property Name, CurrentUsage, AllocatedBaseSize, PeakUsage, InstallDate

Yadda za a samu da shawarar gimra (MB) ga na boye da PowerShell?
[Math]::Truncate(((Get-WmiObject -Class Win32_ComputerSystem).TotalPhysicalMemory) / 1MB) * 1.5

Yadda za ka ƙirƙiri wani na boye (4096 MB) a kan (D 🙂 fitar da PowerShell?

Yadda za a share na boye a kan (C 🙂 fitar da PowerShell?

Maintenance

Yadda za a duba guntu wani tuƙa da PowerShell?

Yadda za a duba faifai sarari na tafiyarwa da PowerShell?

Up


Files

Yadda za a bude wani fayil da PowerShell?
Invoke-Item -Path 'C:\scripts\file.txt'
.'C:\scripts\file.txt'

Yadda za a karanta fayil da PowerShell?
Get-Content -Path 'C:\scripts\file.txt'
gc "C:\scripts\file.txt" # Alias

Yadda za a rubuta fitarwa zuwa fayil da PowerShell?
'Line1', 'Line2', 'Line3' | Out-File -FilePath 'C:\scripts\file.txt'
'Line1', 'Line2', 'Line3' | Add-Content -Path file.txt

Yadda za a samu da cikakken suna na yanzu rubutun fayil da PowerShell?
$MyInvocation.MyCommand.Path

Yadda za a damfara / zip fayil tare da PowerShell?
Add-Type -AssemblyName 'System.IO.Compression.Filesystem'
[System.IO.Compression.ZipFile]::CreateFromDirectory($folder,$fileZIP)

Yadda za a ba damfara / kasa kwancewa fayiloli tare da PowerShell?
Add-Type -AssemblyName 'System.IO.Compression.Filesystem'
[System.IO.Compression.ZipFile]::ExtractToDirectory($fileZIP, $folder)

Yadda za a ga fayil a cikin wani ZIP Rumbun da PowerShell?
Add-Type -AssemblyName 'System.IO.Compression.Filesystem'
[System.IO.Compression.ZipFile]::OpenRead($fileZIP)

Yadda za a nuna girman fayil a KB da PowerShell?
(Get-ChildItem -Path .\winsrv.dll).Length /1KB
(Get-ChildItem -Path .\winsrv.dll).Length /1MB
(Get-ChildItem -Path .\winsrv.dll).Length /1GB

Yadda za a sami fayiloli ya fi girma ko kasa da 1 GB da PowerShell?

Yadda za a nuna da sunan fayil ba tare da tsawo tare da PowerShell?
[System.IO.Path]::GetFileNameWithoutExtension('C:\Windows\system32\calc.exe') # Return calc

Yadda za a nuna tsawo na fayil da PowerShell?
[System.IO.Path]::GetExtension('C:\scripts\file.txt') # Return .txt

Yadda za a samu fayil irin ra’ayi of fayil da PowerShell?

Yadda za a samu da zanta da wani fayil da PowerShell?
(Get-FileHash $file).Hash

Yadda za a samu da MD5 / SHA1 duba Miliyan Xari wani fayil da PowerShell?
Get-FileHash $file -Algorithm MD5
Get-FileHash $file -Algorithm SHA1

Yadda za a nuna boye fayil tare da PowerShell?

Yadda za a duba idan fayil yana da wani tsawo tare da PowerShell?

Yadda za a kafa wani fayil a matsayin “Karanta Kawai” da PowerShell?
Set-ItemProperty -Path .\file.txt -Name IsReadOnly -Value $true

Yadda za a canja “Karshe Rubuta Lokaci” sifa to makon da ya gabata, ga fayil da PowerShell?
Set-ItemProperty -Path .\file.txt -Name LastWriteTime -Value ((Get-Date).AddDays(-7))
If not working, use Nirsoft tool: BulkFileChanger.

Yadda za ka ƙirƙiri wani sabon fayil da PowerShell?
New-Item -ItemType File -Path 'C:\scripts\file.txt' -Value 'FirstLine'

Yadda za a sake sunan fayil tare da PowerShell?
Rename-Item -Path 'C:\scripts\file.txt' -NewName 'C:\scripts\powershellguru2.txt'

Yadda za a girma / tsari sake sunan mahara fayil tare da PowerShell?
Get-ChildItem -Path C:\scripts\txt | Rename-Item -NewName { $_.Name -replace ' ', '_' }

Yadda za a share fayil da PowerShell?
Remove-Item -Path 'C:\scripts\file.txt'

Yadda za a nuna 10 sabon layi wani fayil da PowerShell?
Get-Content -Path 'C:\scripts\log.txt' -Tail 10

Yadda za a cire katanga dama da fayil na babban da PowerShell?
Get-ChildItem -Path 'C:\scripts\Modules' | Unblock-File

Yadda za a cire komai daga layi fayil da PowerShell?
(Get-Content -Path file.txt) | Where-Object -FilterScript {$_.Trim() -ne '' } | Set-Content -Path file.txt

Yadda za a duba idan fayil wanzu tare da PowerShell?

Yadda za a samu sabuwar / mafi tsufa halitta fayil a cikin wani babban fayil da PowerShell?

Yadda za a cire Kwafin layi daga fayil da PowerShell?

Yadda za a samu fayil halitta fiye ko kasa da 1 ga watan a cikin wani babban fayil da PowerShell?

Yadda za a samu fayil halitta fiye ko kasa da 1 shekara a babban fayil da PowerShell?

Yadda za a fitarwa da darajar da wani m zuwa fayil da PowerShell?
Set-Content -Path file.txt -Value $variable

Yadda za a ƙidaya yawan fayil (* .txt) a cikin wani babban fayil da PowerShell?

Yadda za a bincika a cikin kirtani mahara fayil tare da PowerShell?
Select-String -Path 'C:\*.txt' -Pattern 'Steve'

Yadda za a nuna na farko / ƙarshe line wani fayil da PowerShell?

Yadda za a nuna wani layi yawan fayil da PowerShell?

Yadda za a ƙidaya yawan layi wani fayil da PowerShell?

Yadda za a ƙidaya yawan haruffa da kalmomin fayil da PowerShell?

Yadda za a sauke fayil da PowerShell?
Invoke-WebRequest -Uri 'http://www.nirsoft.net/utils/searchmyfiles.zip' -OutFile 'C:\tools\searchmyfiles.zip'

Yadda za a nuna cikakken hanyar fayil da PowerShell?
Resolve-Path -Path .\script.ps1 # Return C:\Scripts\script.ps1

Copy

Yadda za a kwafa daya fayil zuwa babban fayil da PowerShell?
Copy-Item -Path 'C:\source\file.txt' -Destination 'C:\destination'

Yadda za a kwafa daya fayil zuwa mahara manyan fayil tare da PowerShell?

Yadda za a kwafa mahara fayil zuwa babban fayil daya da PowerShell?
Get-ChildItem -Path 'C:\source' -Filter *.txt | Copy-Item -Destination 'C:\destination'

Up


Active Directory

Domain & Forest

Computers

Groups

Organizational Unit (OU)

Users

Domain & Forest

Yadda za a sami Duniya Tsarin litattafai sabobin a Aiki Littafin Adireshi da PowerShell?
[System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest().GlobalCatalogs

Yadda za a sami sites a Aiki Littafin Adireshi da PowerShell?
[System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest().Sites

Yadda za a sami halin yanzu yanki mai kula da PowerShell?
(Get-ADDomainController).HostName

Yadda za a sami duk kan yankin da masu kula a cikin wani yanki da PowerShell?

Yadda za a sami AD kwafi kasawa da PowerShell?
Get-ADReplicationFailure dc02.domain.com # Windows 8 and 2012

Yadda za a sami dutsen kabari rayuwa ga gandun daji a Aiki Littafin Adireshi da PowerShell?

Yadda za a samu cikakken bayani game da gandun daji / yanki a Aiki Littafin Adireshi da PowerShell?

Yadda za a samu hanyar da “Share Abubuwan” ganga a Aiki Littafin Adireshi da PowerShell?
(Get-ADDomain).DeletedObjectsContainer

Yadda za a taimaka wa AD maimaita Bin alama a Aiki Littafin Adireshi da PowerShell?

Yadda za a mayar da wani AD Asusun daga maimaita Bin in Aiki Littafin Adireshi da PowerShell?
Get-ADObject -Filter 'samaccountname -eq "powershellguru"' -IncludeDeletedObjects | Restore-ADObject

Yadda za a sami FSMO matsayin da PowerShell?

Yadda za a haɗa zuwa wani yanki mai kula da PowerShell?
Get-ADUser -Identity $user -Server 'serverDC01'

Yadda za a samu na yanzu logon uwar garken da PowerShell?

Yadda za a yi “gpupdate” a kan kwamfuta da PowerShell?
Invoke-GPUpdate -Computer $computer -Force -RandomDelayInMinutes 0 # Windows 2012

Groups

Yadda za ka ƙirƙiri wani sabon kungiyar a Aiki Littafin Adireshi da PowerShell?

Yadda za a cire kungiyar a Aiki Littafin Adireshi da PowerShell?
Remove-ADGroup -Identity 'PowershellGuru'

Yadda za a ƙara mai amfani ga kungiyar a Aiki Littafin Adireshi da PowerShell?
Add-ADGroupMember "Powershell Guru" -Members powershellguru

Yadda za a cire daga wani rukuni mai amfani a Aiki Littafin Adireshi da PowerShell?
Remove-ADGroupMember 'Powershell Guru' -Members powershellguru

Yadda za a sami komai a kungiyoyin (ba tare da wani ‘yan) a Aiki Littafin Adireshi da PowerShell?
Get-ADGroup -Filter * -Properties Members | Where-Object -FilterScript {-not $_.Members}

Yadda za a ƙidaya komai kungiyoyin (ba tare da wani ‘yan) a Aiki Littafin Adireshi da PowerShell?
(Get-ADGroup -Filter * -Properties Members | Where-Object -FilterScript {-not $_.Members}).Count

Yadda za a samu da ‘yan ƙungiyar a Aiki Littafin Adireshi da PowerShell?

Yadda za a samu da ‘yan ƙungiyar da maimaita yan a Aiki Littafin Adireshi da PowerShell?

Yadda za a ƙidaya yawan ‘yan ƙungiyar da / ba tare da maimaita yan a Aiki Littafin Adireshi da PowerShell?

Users

Yadda za a yi amfani da wildcard a tace na “Ka-ADMai amfani” a Aiki Littafin Adireshi da PowerShell?

Yadda za a motsa mai amfani zuwa wani OU a Aiki Littafin Adireshi da PowerShell?
Move-ADObject -Identity $dn -TargetPath 'OU=myOU,DC=domain,DC=com'

Yadda za a sami dukan duk ‘yan da suke (Sheƙa) ga wani mai amfani da PowerShell?
Get-ADGroup -LDAPFilter "(member:1.2.840.113556.1.4.1941:=$($dn))"

Yadda za a samu da duk ‘yan (gajere sunan / kakkãtse) ga wani mai amfani da PowerShell?
(Get-ADUser $user -Properties MemberOf).MemberOf | ForEach-Object -Process {($_ -split ',')[0].Substring(3)} | Sort-Object

Yadda za a sake sunan da Sunan (CikakkeSunan), (NuniSunan), BaSunan (Na farkoSunan), da sunan uba (KarsheSunan) ga wani mai amfani da asusun a Aiki Littafin Adireshi da PowerShell?

Yadda za a canja Siffantarwa, ofishin, da kuma Telefon mai lamba ga wani mai amfani da asusun a Aiki Littafin Adireshi da PowerShell?
Set-ADUser $samAccountName -Description 'IT Consultant' -Office 'Building B' -OfficePhone '12345'

Yadda za a saita kwanan watan ƙarewa to “31/12/2015” ko “Bã” ga wani mai amfani da asusun a Aiki Littafin Adireshi da PowerShell?

Yadda za a buše mai amfani da asusun a Aiki Littafin Adireshi da PowerShell?
Unlock-ADAccount $samAccountName

Yadda za a taimaka / musaki mai amfani da asusun a Aiki Littafin Adireshi da PowerShell?

Yadda za a cire mai amfani da asusun a Aiki Littafin Adireshi da PowerShell?
Remove-ADUser $samAccountName

Yadda za a sake saita kalmarka ta sirri a daya mai amfani da asusun a Aiki Littafin Adireshi da PowerShell?

Yadda za a sake saita kalmarka ta sirri a domin da yawa mai amfani da asusun (girma) a Aiki Littafin Adireshi da PowerShell?

Yadda za a sami mai shi wani fayil a Aiki Littafin Adireshi da PowerShell?

Yadda za a sami Ou (kungiya Naúrar) ga wani mai amfani a Aiki Littafin Adireshi da PowerShell?
[regex]::match("$((Get-ADUser $user -Properties DistinguishedName).DistinguishedName)",'(?=OU=)(.*\n?)').value

Yadda za a sami nakasa mai amfani da asusun a Aiki Littafin Adireshi da PowerShell?

Yadda za a sami kare mai amfani da asusun a Aiki Littafin Adireshi da PowerShell?
Search-ADAccount -AccountExpired

Yadda za a sami kulle mai amfani da asusun a Aiki Littafin Adireshi da PowerShell?
Search-ADAccount -LockedOut

Yadda za a sami Sid na mai amfani da asusun a Aiki Littafin Adireshi da PowerShell?
(Get-ADUser $user -Properties SID).SID.Value

Yadda za a maida wani sunan mai amfani ga Sid a Aiki Littafin Adireshi da PowerShell?

Yadda za a maida wani Sid to sunan mai amfani a Aiki Littafin Adireshi da PowerShell?

Yadda za a raba bambanta sunan mai amfani da asusun a Aiki Littafin Adireshi da PowerShell?

Yadda za a sami kwanan wata halitta / gyara na mai amfani da asusun a Aiki Littafin Adireshi da PowerShell?
Get-ADUser -Identity $user -Properties whenChanged, whenCreated | Format-List -Property whenChanged, whenCreated

Yadda za a nuna na tilas da tilas dukiya domin ajin “Mai amfani” a Aiki Littafin Adireshi da PowerShell?

Yadda za a samu da LDAP hanya ga wani mai amfani a Aiki Littafin Adireshi da PowerShell?

Yadda za a canja CN (canonical Sunan) ga wani mai amfani a Aiki Littafin Adireshi da PowerShell?
Rename-ADObject $((Get-ADUser $user -Properties DistinguishedName).DistinguishedName) -NewName 'Steve Renard'

Yadda za a samu da Kungiya Naúrar (OU) iyaye na mai amfani a Aiki Littafin Adireshi da PowerShell?

Yadda za a samu mai shi da wani mai amfani (wanda Ya halitta lissafi) a Aiki Littafin Adireshi da PowerShell?

Yadda za a maida da PwdKarsheSeti sifa ga wani mai amfani a Aiki Littafin Adireshi da PowerShell?

Computers

Yadda za a gwada amintacce tashar tsakanin gida kwamfuta da kan yankin da PowerShell?
Test-ComputerSecureChannel

Yadda za a gyara amintacce tashar tsakanin gida kwamfuta da kan yankin da PowerShell?
Test-ComputerSecureChannel -Repair

Yadda za a musaki kwamfuta lissafi a Aiki Littafin Adireshi da PowerShell?
Disable-ADAccount $computer

Yadda za a sami kwakwalwa tare da takamaiman Operating Systems a Aiki Littafin Adireshi da PowerShell?

Organizational Unit (OU)

Yadda za ka ƙirƙiri wani Kungiya Naúrar (OU) a Aiki Littafin Adireshi da PowerShell?
New-ADOrganizationalUnit -Name 'STEVE' -Path 'DC=domain,DC=com'

Yadda za a samu Kungiya Naúrar (OU) cikakkun bayanai a Active Directory da PowerShell?
Get-ADOrganizationalUnit 'OU=STEVE,DC=domain,DC=com' -Properties *

Yadda za a canja bayanin wani Kungiya Naúrar (OU) a Aiki Littafin Adireshi da PowerShell?
Set-ADOrganizationalUnit 'OU=STEVE,DC=domain,DC=com' -Description 'My description'

Yadda za a taimaka / musaki wani Kungiya Naúrar (OU) daga mai haɗari shafewa a Aiki Littafin Adireshi da PowerShell?

Yadda za a taimaka wa mai haɗari shafewa ga dukan Kungiya Naúrar (OU) a Aiki Littafin Adireshi da PowerShell?

Yadda za a share Kungiya Naúrar (OU) kariya daga mai haɗari shafewa a Aiki Littafin Adireshi da PowerShell?

Yadda za a maida wani bambanta sunan wani Kungiya Naúrar (OU) zyuwa ga canonical Sunan a Aiki Littafin Adireshi da PowerShell?

Yadda za a jerin komai a Kungiya Naúrar (OUs) da PowerShell?

Yadda za a samu da manajan wani rukuni da PowerShell?
(Get-ADGroup $dn -Properties Managedby).Managedby

Up


Regex (Regular Expression)

Yadda za a fitar da wani IP Adireshi V4 (80.80.228.8) da Regex da PowerShell?
$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

Yadda za a fitar da wata MAC Adireshi (C0-D9-62-39-61-2D) da raba “-” da Regex da 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

Yadda za a fitar da wata MAC Adireshi (C0: D9: 62: 39: 61: 2D) da raba “:” tare da Regex da PowerShell?
$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

Yadda za a fitar da wata rana (10/02/2015) da Regex da PowerShell?
$example = 'The date is 10/02/2015'
$date = [regex]::match($example,'(\d{2}\/\d{2}\/\d{4})').value

Yadda za a fitar da wata URL (www.powershell-guru.com) da Regex da PowerShell?
$example = 'The URL is www.powershell-guru.com'
$url = [regex]::match($example,'[a-z]+[:.].*?(?=\s)').value

Yadda za a cire wani imel (user@domain.com) da Regex da PowerShell?
$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

Yadda za a cire “guru” daga kirtani misali da Regex da PowerShell?
$example = 'www.powershell-guru.com'
[regex]::match($example,'(?<=-)(.*\n?)(?=.com)').value

Yadda za a cire “guru.com” daga kirtani misali da Regex da PowerShell?
$example = 'www.powershell-guru.com'
[regex]::match($example,'(?<=-)(.*\n?)(?<=.)').value

Yadda za a cire “powershell-guru.com” daga kirtani misali da Regex da PowerShell?
$example = 'www.powershell-guru.com'
[regex]::match($example,'(?<=www.)(.*\n?)').value

Yadda za a cire “123” daga kirtani misali da Regex da PowerShell?
$example = 'Powershell123'
[regex]::match($example,'(\d+)').value

Yadda za a cire “$” (dollar ãyã) daga kirtani misali da Regex da PowerShell?
$example = 'Powershell`$123'
[regex]::match($example,'(\$)').value

Yadda za a maye gurbin wani hali (* .com) tare da wani (* .fr) a cikin wani kirtani da Regex da PowerShell?
$example = 'www.powershell-guru.com'
[regex]::Replace($example, '.com','.fr')

Yadda za a kubuta a kirtani da Regex da PowerShell?
[regex]::Escape('\\server\share')

Up


Memory

Yadda za a tilasta tarin tunani da datti tara da PowerShell?
[System.GC]::Collect()
[System.GC]::WaitForPendingFinalizers()

Yadda za a samu da RAM girman kwamfuta da PowerShell?

Up


Date

Yadda za a samu na yanzu kwanan wata da PowerShell?
Get-Date
[Datetime]::Now

Yadda za a nuna kwanan wata cikin daban-daban musamman da PowerShell?

Yadda za a maida wani kwanan wata (Kwanan watalokaci) zuwa kwanan wata (Kirtani) da PowerShell?
$datetimeToString = '{0:dd/MM/yy}' -f (Get-Date 30/01/2015)
$datetimeToString = (Get-Date 31/01/2015).ToShortDateString()

Yadda za a maida wani kwanan wata (Kirtani) zuwa kwanan wata (Kwanan watalokaci) da PowerShell?
$stringToDatetime = [Datetime]::ParseExact('30/01/2015', 'dd/MM/yyyy', $null)

Yadda za a lissafta bambanci (Yawan kwanaki, Awa, Minti, ko Second) a tsakanin biyu kwanakin da 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

Yadda za a kwatanta biyu kwanakin da 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

Yadda za a warware wani tsararru na kwanakin a matsayin “Kwanan watalokaci” da PowerShell?
$arrayDate | Sort-Object -Property {$_ -as [Datetime]}

Yadda za a fara da kuma dakatar da agogon awon gudu da PowerShell?
$chrono = [Diagnostics.Stopwatch]::StartNew()
$chrono.Stop()
$chrono

Yadda za a samu na yanzu rana ta mako tare da PowerShell?
(Get-Date).DayOfWeek #Sunday

Yadda za a samu jiya ta kwanan da PowerShell?
(Get-Date).AddDays(-1)

Yadda za a samu yawan kwanaki a cikin wani watan (a watan Fabrairu 2015) da PowerShell?
[DateTime]::DaysInMonth(2015, 2)

Yadda za a san da tsalle shekara da PowerShell?
[DateTime]::IsLeapYear(2015)

Yadda za a jerin lokaci bangarori da PowerShell?
[System.TimeZoneInfo]::GetSystemTimeZones()

Up


Networking

Yadda za a encode (ga ASCII musamman) da kuma karanta URL da PowerShell?

Mene ne equivalents na ‘yan qasar na cibiyar sadarwa dokokin da PowerShelll?

Yadda za a samu IP adireshin da PowerShell?
Get-NetIPAddress # Windows 8.1 & Windows 2012
Get-NetIPConfiguration # Windows 8.1 & Windows 2012

Yadda za a musaki IP address V6 (IPv6) da PowerShell?

Yadda za a inganta da wani IP adireshin V4 (IPv4) da PowerShell?
if([ipaddress]'10.0.0.1'){'validated'}

Yadda za a sami external IP adireshin da PowerShell?

Yadda za a sami Sunan mai masauki daga wani IP adireshin da PowerShell?
([System.Net.Dns]::GetHostEntry($IP)).Hostname

Yadda za a sami IP adireshin daga wani Sunan mai masauki tare da PowerShell?
([System.Net.Dns]::GetHostAddresses($computer)).IPAddressToString

Yadda za a sami FQDN daga wani Sunan mai masauki tare da PowerShell?
[System.Net.Dns]::GetHostByName($computer).HostName

Yadda za a sami hanyar sadarwa sanyi (Ip, Subnet, ƙofarhanya, da kuma DNS) da PowerShell?

Yadda za a sami MAC adireshin da PowerShell?
Get-CimInstance win32_networkadapterconfiguration | Select-Object -Property Description, Macaddress
Get-WmiObject -Class win32_networkadapterconfiguration | Select-Object -Property Description, Macaddress

Yadda za a kadawa sauti kwamfuta da PowerShell?

Yadda za a duba idan kwamfuta da aka haɗa ta internet da PowerShell?

Yadda za a yi a “whois” nemo ga wani website tare da PowerShell?
$whois = New-WebServiceProxy 'http://www.webservicex.net/whois.asmx?WSDL'
$whois.GetWhoIs('powershell-guru.com')

Yadda za a samu cikakken bayani game da wata jama’a IP (Gano wuri) da PowerShell?

Yadda za a duba ne idan wata tashar jiragen ruwa bayyane / rufe da kon Harsashi?
New-Object -TypeName Net.Sockets.TcpClient -ArgumentList $computer, 135

Yadda za a yi “tracert” da PowerShell?
Test-NetConnection www.google.com -TraceRoute

Yadda za a gyara a gida na cibiyar sadarwa dangane profile da PowerShell?
Get-NetAdapter | Format-Table -Property Name, InterfaceDescription, ifIndex -AutoSize # Windows 8.1
Set-NetConnectionProfile -InterfaceIndex 6 -NetworkCategory Private

Yadda za a nuna TCP tashar jiragen ruwa sadarwa tare da PowerShell?
netstat.exe -ano
Get-NetTCPConnection #Windows 8 and 2012

Yadda za a rage tsawon URL cikin wani kankanin URL da PowerShell?
$url = 'www.powershell-guru.com'
$tiny = Invoke-RestMethod -Uri "http://tinyurl.com/api-create.php?url=$url"

Yadda za a samu wakili saituna da PowerShell?
Get-ItemProperty -Path HKCU:"Software\Microsoft\Windows\CurrentVersion\Internet Settings"

DNS

Yadda za a duba DNS cache a kan wani gida kwamfuta da PowerShell?
ipconfig.exe /displaydns
Get-DnsClientCache #Windows 8 and 2012

Yadda za a share wata DNS cache a kan wani gida kwamfuta da PowerShell?
ipconfig.exe /flushdns
Start-Process -FilePath ipconfig -ArgumentList /flushdns -WindowStyle Hidden
Clear-DnsClientCache #Windows 8 and 2012

Yadda za a share wata DNS cache a kan m kwakwalwa da PowerShell?
Invoke-Command -ScriptBlock {Clear-DnsClientCache} -ComputerName computer01, computer02

Yadda za a karanta Runduna fayil din da PowerShell?
Get-Content -Path 'C:\Windows\system32\drivers\etc\hosts'

Up


Password

Yadda za a samar da wata kalmar sirri da bazuwar PowerShell?
[Reflection.Assembly]::LoadWithPartialName('System.Web')
[System.Web.Security.Membership]::GeneratePassword(30,2)

Yadda za a canja gida kalmar sirri ga wani shugaba a kan wani m uwar garken da PowerShell?
$admin = [ADSI]('WinNT://server01/administrator,user')
$admin.SetPassword($password)
$admin.SetInfo()

Yadda za a sami kalmar sirri karewa ranar wani asusun a Aiki Littafin Adireshi da PowerShell?

Up


Printers

Yadda za a jerin dukan firintocinku ga wani takamaiman uwar garken da PowerShell?
Get-WmiObject -Query 'Select * From Win32_Printer' -ComputerName $computer

Yadda za a jerin dukan mashigai na musamman uwar garken da PowerShell?
Get-WmiObject -Class Win32_TCPIPPrinterPort -Namespace 'root\CIMV2' -ComputerName $computer

Yadda za a canja nuna ra’ayi / wurin da a firinta da PowerShell?

Yadda za a kawar (soke duk jobs) zuwa firinta da PowerShell?
$printer = Get-WmiObject -Class win32_printer -Filter "Name='HP Deskjet 2540 series'"
$printer.CancelAllJobs()

Yadda za a buga a shafi na gwajin ga wani firinta da PowerShell?
$printer = Get-WmiObject -Class win32_printer -Filter "Name='HP Deskjet 2540 series'"
$printer.PrintTestPage()

Yadda za a samu buga queues ga firinta da PowerShell?

Up


Regedit

Read

Yadda za a jerin rajista amya da PowerShell?
Get-ChildItem -Path Registry::

Yadda za a samu yin rajista dabi’u da kuma darajar iri da PowerShell?

Yadda za a jerin rajista mabuɗi ƙaramimabuɗi da PowerShell?

Yadda za a jerin rajista mabuɗi ƙaramimabuɗi a cikin wani maimaita hanyar da PowerShell?
Get-ChildItem -Path 'HKLM:\SYSTEM' -Recurse -ErrorAction SilentlyContinue

Yadda za a sami ƙaramimabuɗi tare da wani sunan da PowerShell?
Get-ChildItem -Path 'HKLM:\SOFTWARE' -Include *Plugin* -Recurse -ErrorAction SilentlyContinue

Yadda za a mayar da kawai da sunan rajista ƙaramimabuɗi da PowerShell?
(Get-ChildItem -Path 'HKLM:\SYSTEM').Name # Return HKEY_LOCAL_MACHINE\SYSTEM\ControlSet
Get-ChildItem -Path 'HKLM:\SYSTEM' -Name # Return ControlSet

Yadda za a jerin rajista dabi’u da PowerShell?
Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion'

Yadda za a karanta wani rajista darajar da PowerShell?
(Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion').ProductName

Yadda za a karanta wani rajista darajar a kan wani m kwamfuta da PowerShell?

Write

Yadda za ka ƙirƙiri wani sabon rajista key da PowerShell?
New-Item -Path 'HKCU:\Software\MyApplication'

Yadda za ka ƙirƙiri wani rajista darajar da PowerShell?
New-ItemProperty -Path 'HKCU:\Software\MyApplication' -Name 'Version' -Value '1.0'

Yadda za a gyara data kasance rajista darajar da PowerShell?
Set-ItemProperty -Path 'HKCU:\Software\MyApplication' -Name 'Version' -Value '2.0'

Delete

Yadda za a share rajista darajar da PowerShell?
Remove-ItemProperty -Path 'HKCU:\Software\MyApplication' -Name 'Version'

Yadda za a share rajista key da PowerShell?
Remove-Item -Path 'HKCU:\Software\MyApplication' -Force

Test

Yadda za a jarraba idan wata rajista key wanzu tare da PowerShell?
Test-Path -Path 'HKCU:\Software\MyApplication'

Yadda za a jarraba idan wata rajista darajar wanzu tare da PowerShell?
(Get-Item -Path 'HKCU:\Software\MyApplication').GetValueNames() -contains 'Version'

Up


Strings

Yadda za a cire fari-sarari characters daga farkon wata kirtani da PowerShell?
$string = ' PowershellGuru'
$string = $string.TrimStart()

Yadda za a cire fari-sarari hali daga karshen wata kirtani da PowerShell?
$string = 'PowershellGuru '
$string = $string.TrimEnd()

Yadda za a cire fari-sarari hali (farko da kawo karshen) wani layi tare da PowerShell?
$string = ' PowershellGuru '
$string = $string.Trim()

Yadda za a maida wani kirtani zuwa sama harka da PowerShell?
$string = 'powershellguru'
$string = $string.ToUpper()

Yadda za a maida wani kirtani ya runtse yanayin da PowerShell?
$string = 'POWERSHELLGURU'
$string = $string.ToLower()

Yadda za a zaba da ƙaramikirtani “PowerShell” na kirtani “PowerShellGwani” da PowerShell?
$string.Substring(0,10)

Yadda za a zaba da ƙaramikirtani “Gwani” na kirtani “Ikon HrsashiGwani” da PowerShell?
$string.Substring(10)

Yadda za a zaba yawan “123” da “PowerShell123Gwani” da PowerShell?
$string = 'Powershell123Guru'
[regex]::match($string,'(\d+)').value

Yadda za a samu da sifilin na tushen fihirisa na “Gwani” na kirtani “PowerShellGwani” da PowerShell?
$string.IndexOf('Guru') # 10

Yadda za a duba ne idan wata kirtani ne kõme ba ko komai a tare da PowerShell?
$string = $null
$string = ''
[string]::IsNullOrEmpty($string)

Yadda za a duba ne idan wata kirtani ne kõme ba, komai, ko kunshi kawai na fari-sarari hali da PowerShell?
$string = $null
$string = ''
$string = ' '
[string]::IsNullOrWhiteSpace($string)

Yadda za a duba ne idan wata kirtani ya ƙunshi wani wasika da PowerShell?
$string = 'PowershellGuru'
$string.Contains('s')
[regex]::match($string,'s').Success

Yadda za a mayar da da tsawon wani kirtani da PowerShell?
$string.Length

Yadda za a concatenate biyu kirtani da PowerShell?

Yadda za a daidaita ga daya ko dama brackets “[]” a cikin wani kirtani da PowerShell?
$string = '[PowershellGuru]'
$string -match '\[' # Only 1
$string -match '\[(.*)\]' # Several

Yadda za a daidaita ga daya ko dama sashi “()” a cikin wani kirtani da PowerShell?
$string = '(PowershellGuru)'
$string -match '\(' # Only 1
$string -match '\((.*)\)' # Several

Yadda za a daidaita ga daya ko dama nada braketi “{}” a cikin wani kirtani da PowerShell?
$string = '{PowershellGuru}'
$string -match '\{' # Only 1
$string -match '\{(.*)\}' # Several

Yadda za a daidaita ga daya ko dama kwana braketi “<>” a cikin wani kirtani da PowerShell?
$string = ''
$string -match '\<' # Only 1
$string -match "\<(.*)\>" # Several

Yadda za a daidaita wani Ƙaramin baki haruffa (ABC) a cikin wani kirtani da PowerShell?
$string = 'POWERSHELLGURU'
$string -cmatch "^[a-z]*$" #False

Yadda za a daidaita wani na samawasika (ABC) a cikin wani kirtani da PowerShell?
$string = 'powershellguru'
$string -cmatch "^[A-Z]*$" #False

Yadda za a daidaita “[p” (p ƙananan idan akwai) a cikin wani kirtani da PowerShell?
$string = '[powershellGuru]'
$string -cmatch '\[[a-z]\w+' #True

Yadda za a daidaita “[P” (P babba idan akwai) a cikin wani kirtani da PowerShell?
$string = '[PowershellGuru]'
$string -cmatch '\[[A-Z]\w+' #True

Yadda za a maye gurbin wani layi tare da wani line tare da PowerShell?
$a = 'Line A'
$b = 'Line B'
$a = $a -replace $a, $b

Yadda za a maida wani rabo aiki zuwa kirtani (kashi) da PowerShell?
(1/2).ToString('P')

Yadda za a warware kirtani dauke da lambobi tare da PowerShell?

Yadda za a zaba na karshe maganar wani hukunci da PowerShell?
$sentence = 'My name is Steve Renard'
$sentence.Split(' ')[-1] # Returns Renard

Yadda za a samu mafi girma maganar wani hukunci da PowerShell?
$sentence = 'My name is Steve Renard'
$sentence.Split(' ') | Sort-Object -Property Length | Select-Object -Last 1 # Returns Renard

Yadda za a ƙidaya yawan sau a kirtani ne ba a cikin jumla da PowerShell?
$sentence = 'steve steve steve renard'
[regex]::Matches($sentence, 'steve').Count # Returns 3

Yadda za a kwafa kowane hali a cikin wani kirtani zuwa hali tsararru da PowerShell?

Yadda za a maida ta farko da wasika zuwa babban mai kirtani da PowerShell?

Yadda za a kushin (hagu ko dama) a kirtani da PowerShell?

Yadda za a tsari da karanta wani kirtani ya Tushe64 da PowerShell?

Yadda za a maida dama (zuwa kuma daga) binary da Ikon Harsa?

Yadda za a mayar da kawai na karshe iyaye babban fayil a cikin wani hanya tare da PowerShell?

Yadda za a mayar da kawai na karshe abu a hanyar da PowerShell?

Up


Math

Yadda za a jerin hanyoyin na Tsarin.Ilimin lissafi aji da PowerShell?
[System.Math] | Get-Member -Static -MemberType Method

Yadda za a mayar da cikakken darajar da Ikon Harsash?
[Math]::Abs(-12) #Returns 12
[Math]::Abs(-12.5) # Returns 12.5

Yadda za a mayar da kwana wanda sine ne a kayyade adadin da Ikon Harsash?
[Math]::ASin(1) #Returns 1,5707963267949

Yadda za a mayar da sama, sa’an darajar da Ikon Harsash?
[Math]::Ceiling(1.4) #Returns 2
[Math]::Ceiling(1.9) #Returns 2

Yadda za a mayar da kasa darajar da Ikon Harsash?
[Math]::Floor(1.4) #Returns 1
[Math]::Floor(1.9) #Returns 1

Yadda za a mayar da na halitta (tushe e) lambar tushe na wani ajali number da Ikon Harsash?
[Math]::Log(4) #Returns 1,38629436111989

Yadda za a mayar da tushe 10 lambar tushe na wani ajali number da Ikon Harsash?
[Math]::Log10(4) #Returns 0,602059991327962

Yadda za a mayar da kalla biyu dabi’u da Ikon Harsash?
[Math]::Max(2,4) #Returns 4
[Math]::Max(-2,-4) #Returns -2

Yadda za a mayar da m na biyu dabi’u da Ikon Harsash?
[Math]::Min(2,4) #Returns 2
[Math]::Max(-2,-4) #Returns -4

Yadda za a mayar da dama tãyar da su wani ajali ikon da Ikon Harsash?
[Math]::Pow(2,4) #Returns 16

Yadda za a mayar da wani gidan goma darajar zuwa mafi kusa na game darajar da Ikon Harsash?
[Math]::Round(3.111,2) #Returns 3,11
[Math]::Round(3.999,2) #Returns 4

Yadda za a mayar da ɓangare na wani ajali gidan goma lambar da Ikon Harsash?
[Math]::Truncate(3.111) #Returns 3
[Math]::Truncate(3.999) #Returns 3

Yadda za a mayar da square tushen ajali lambar da Ikon Harsash?
[Math]::Sqrt(16) #Returns 4

Yadda za a mayar da PI m tare da Ikon Harsash?
[Math]::Pi #Returns 3,14159265358979

Yadda za a mayar da na halitta lambar tushe (kulluyaumin e) da Ikon Harsash?
[Math]::E #Returns 2,71828182845905

Yadda za a duba idan da dama ne ma ko m tare da Ikon Harsash?
[bool]($number%2)

Up


Hashtables

Yadda za ka ƙirƙiri wani komai a zantatebur da Ikon Harsash?
$hashtable = @{}
$hashtable = New-Object -TypeName System.Collections.Hashtable

Yadda za ka ƙirƙiri wani zantatebur da abubuwa da PowerShell?

Yadda za ka ƙirƙiri wani zantatebur ana jerawa da mabuɗi / sunan (umurni da kamus) da abubuwa da PowerShell?

Yadda za a ƙara abubuwa (mabuɗi-darajar biyu) zuwa zantatebur da PowerShell?
$hashtable.Add('Key3', 'Value3')

Yadda za a samu wani darajar wani zantatebur da IkonHarsashi?
$hashtable.Key1
$hashtable.Get_Item('Key1')

Yadda za a samu da ƙaramar darajar wani zantatebur da PowerShell?

Yadda za a samu matsakaicin darajar wani zantatebur da PowerShell?

Yadda za a gyara abubuwa a cikin wani zantatebur da PowerShell?
$hashtable.Set_Item('Key1', 'Value1Updated')

Yadda za a cire abubuwa a cikin wani zantatebur da PowerShell?
$hashtable.Remove('Key1')

Yadda za a share wata zantatebur da PowerShell?
$hashtable.Clear()

Yadda za a duba gaban wani key / darajar a cikin wani zantatebur da PowerShell?
$hashtable.ContainsKey('Key3')
$hashtable.ContainsValue('Value3')

Yadda za a warware ta key / darajar a cikin wani zantatebur da PowerShell?
$hashtable.GetEnumerator() | Sort-Object -Property Name
$hashtable.GetEnumerator() | Sort-Object -Property Value -Descending

Up


Arrays

Yadda za ka ƙirƙiri wani komai a tsararru da PowerShell?
$array = @()
$array = [System.Collections.ArrayList]@()

Yadda za ka ƙirƙiri wani tsararru da abubuwa da PowerShell?
$array = @('A', 'B', 'C')
$array = 'A', 'B', 'C'
$array = 'a,b,c'.Split(',')
$array = .{$args} a b c
$array = echo a b c

Yadda za a ƙara abubuwa zuwa wani tsararru da PowerShell?
$array += 'D'
[void]$array.Add('D')

Yadda za a gyara wani abu a wani tsararru da PowerShell?
$array[0] = 'Z' # 1st item[0]

Yadda za a duba girman wani tsararru da PowerShell?
$array = 'A', 'B', 'C'
$array.Length # Returns 3

Yadda za a mai da daya abu / dama / dukan abubuwa a cikin wani tsararru da PowerShell?
$array = @('A', 'B', 'C')
$array[0] # One item (A)
$array[0] + $array[2] # Several items (A,C)
$array # All items (A,B,C)

Yadda za a cire komai abubuwa a cikin wani tsararru da PowerShell?
$array = @('A', 'B', 'C', '')
$array = $array.Split('',[System.StringSplitOptions]::RemoveEmptyEntries) | Sort-Object # A,B,C

Yadda za a duba idan wani abu wanzu a cikin wani tsararru da PowerShell?
$array = @('A', 'B', 'C')
'A' | ForEach-Object -Process {$array.Contains($_)} # Returns True
'D' | ForEach-Object -Process {$array.Contains($_)} # Returns False

Yadda za a sami index yawan abu a cikin wani tsararru da PowerShell?
$array = @('A', 'B', 'C')
[array]::IndexOf($array,'A') # Returns 0

Yadda za a baya umurnin abubuwa a cikin wani tsararru da PowerShell?
$array = @('A', 'B', 'C')
[array]::Reverse($array) # C,B,A

Yadda za a samar da wani bazuwar abu daga wani tsararru da PowerShell?
$array | Get-Random

Yadda za a warware wani tsararru a cikin wani suna hawa / saukowa hanyar da PowerShell?
$array = @('A', 'B', 'C')
$array | Sort-Object # A,B,C
$array | Sort-Object -Descending # C,B,A

Yadda za a ƙidaya yawan abubuwa a cikin wani tsararru da PowerShell?
$array.Count

Yadda za a ƙara wani tsararru zuwa wani da PowerShell?
$array1 = 'A', 'B', 'C'
$array2 = 'D', 'E', 'F'
$array3 = $array1 + $array2 # A,B,C,D,E,F

Yadda za a sami kwafi daga wani tsararru da PowerShell?
$array = 'A', 'B', 'C', 'C'
($array | Group-Object | Where-Object -FilterScript {$_.Count -gt 1}).Values # Returns C

Yadda za a cire kwafi daga wani tsararru da PowerShell?
$array = 'A', 'B', 'C', 'C'
$array = $array | Select-Object -Unique
$array # Returns A,B,C

Yadda za ka ƙirƙiri wani tsararru da abubuwa suka fara da wani kari (“mai amfani01”, “mai amfani02”, … “mai amfani10”) da PowerShell?
$array = 1..10 | ForEach-Object -Process { "user$_" }

Up


ACL

Yadda za a jerin ACL wani AD mai amfani da PowerShell?
(Get-Acl -Path "AD:\$dn").Access

Yadda za a jerin ACL na babban fayil da PowerShell?
(Get-Acl -Path C:\scripts).Access

Yadda za a jerin musamman ACL izni shigarwar (masu amfani ko kungiyoyi) wani AD mai amfani da PowerShell?

Up


Variables

Abin da sun fi na kowa data iri da PowerShell?

Yadda za a sami m da kuma iyakar dabi’u ga wasu irin canji da PowerShell?

Yadda za a gwada datairi da PowerShell?

Yadda za ka ƙirƙiri wani Ga-Kirtani m tare da PowerShell?

Yadda za ka ƙirƙiri wani m tare da PowerShelll?
$powershellGuru = 'Hello'

Yadda za ka ƙirƙiri akai m tare da PowerShell?
Set-Variable -Name powershellGuru -Value 2015 -Option Constant

Yadda za ka ƙirƙiri wani duniya maras tabbas tare da PowerShell?
$Global:powershellGuru = 'Hello'

Yadda za a karanta a m tare da PowerShell?
$powershellGuru = 'Hello' # Create
$powershellGuru # Read
Get-Variable -Name powershellGuru -ValueOnly # Read

Yadda za a duba irin wani maras tabbas tare da PowerShell?
$powershellGuru.GetType()

Yadda za a sami canji a cikin duniya ikon yinsa, tare da PowerShell?
Get-Variable -Scope Global

Yadda za a samu canji musamman da sunan da PowerShell?
Get-Variable -Include *Preference -Exclude W*

Yadda za a sanya wani data irin zuwa m da PowerShell?
[int64]$variable = 100
[string]$variable = 'PowershellGuru'

Yadda za a sa hannu mahara canji ga wannan darajar da PowerShell?
$a = $b = $c = $d = $e = 0

Mene ne wanda aka ce masa ga m “$ _” da PowerShell?
Get-Process | Where-Object -FilterScript {$_.Handles -gt 1000} # Using $_
Get-Process | Where-Object -FilterScript {$PSItem.Handles -gt 1000} # Using $PSItem (since version 3)

Yadda za a cire canji da sunan suka fara da “ƙidaya” da PowerShell?
Remove-Variable -Name count*

Yadda za a samu na gida yanayi canji da PowerShell?
Get-ChildItem -Path Env:

Yadda za a samu hanyar muhalli m line by line tare da PowerShell?
($env:Path) -replace(';', "`n")
[Environment]::GetEnvironmentVariable('Path') -replace(';', "`n")

Yadda za a ƙara sabon hanyar (tsohon. C: \ SysinternalsSuite) zuwa ga hanyar muhalli m tare da PowerShell?
$env:Path += ';C:\SysinternalsSuite'
$env:Path = $env:Path + ';C:\SysinternalsSuite'

Yadda za a concatenate canji da PowerShell?
$a = 'Powershell'
$b = '- Guru'
$c = $a + $b

Yadda za a yi amfani da KuskurenCanji da PowerShell?
Get-ChildItem -Path 'C:\PerfLogs' -ErrorAction SilentlyContinue -ErrorVariable AccessDenied
$AccessDenied | ForEach-Object -Process {$_.Exception}
$AccessDenied | ForEach-Object -Process {$_.TargetObject}

Yadda za a taimaka / musaki kwatankwacin “Zaži bayyane” (VBrubutun hannu: na bukatar cewa a m da za a ayyana) da PowerShell?

Up


Static .NET Methods

Yadda za a samu a tsaye ‘yan tare da PowerShell?
[DateTime] | Get-Member -Static

Up


Sounds

Yadda za a yi wasa da “sauti” sauti da PowerShell?
[System.Console]::Beep()

Yadda za a yi wasa da “alama” tare da sauti PowerShell?
[System.Media.SystemSounds]::Asterisk.Play()

Yadda za a yi wasa da “motsin rai” sauti da PowerShell?
[System.Media.SystemSounds]::Exclamation.Play()

Yadda za a samu samuwa sauti da PowerShell?
[System.Media.SystemSounds] | Get-Member -Static

Yadda za a yi wasa “WAV” sautina da PowerShell?
$soundPlayer = New-Object -TypeName System.Media.SoundPlayer -ArgumentList "$env:windir\Media\Ringout.wav"
$soundPlayer.Play()
ko
$soundPlayer.PlayLooping()
$soundPlayer.Stop()

Yadda za a kunna magana rubuta rubutu da PowerShell?
Add-Type -AssemblyName System.Speech
$speech = New-Object -TypeName System.Speech.Synthesis.SpeechSynthesizer
$speech.Speak('Hello PowershellGuru')

Up


XML

Yadda za a karanta wani XML fayil da PowerShell?
[xml]$sitemap = Get-Content -Path .\sitemap.xml
$sitemap.urlset.url

Yadda za a fitarwa data matsayin XML fayil da PowerShell?
Get-Process | Export-Clixml -Path C:\scripts\processes.xml

Yadda za a shigo bayanai daga wata CLIXML fayil da PowerShell?
$importProcesses = Import-Clixml -Path C:\scripts\processes.xml

Up


GUI

Yadda za ka ƙirƙiri wani asali Gui (Windows Form) da PowerShell?

Up


Characters

Yadda za a maida da ascii darajar zuwa hali da PowerShell?
[char]64

Yadda za a maida wani hali ga ascii darajar da PowerShell?
[int][char]'@'

Yadda za a samar da cikin Turanci haruffa da PowerShell?
[char[]](97..122)

Up


Compare

Yadda za a kwatanta biyu iri-iri tare da PowerShell?

Yadda za a kwatanta biyu matakai da PowerShell?

Up


Microsoft Exchange

Yadda za a dawo da jerin hannu da na’urorin aiki tare da masu amfani ‘akwatin gidan waya tare da PowerShell?
Get-ActiveSyncDeviceStatistics

Yadda za a ƙara “Cikakke Hanya” izini zuwa akwatin gidan waya ga wani mai amfani da PowerShell?
Add-MailboxPermission -Identity $dn -User 'DOMAIN\powershellguru' -AccessRights 'FullAccess'

Yadda za a cire “Cikakke Hanya” izini zuwa akwatin gidan waya ga wani mai amfani da PowerShell?
Remove-MailboxPermission -Identity $dn -User 'DOMAIN\powershellguru' -AccessRights 'FullAccess' -InheritanceType 'All'

Yadda za a ƙara “Aika lokacin da” izini zuwa akwatin gidan waya ga wani mai amfani da PowerShell?
Add-ADPermission -Identity $dn -User 'DOMAIN\powershellguru' -ExtendedRights 'Send-As'

Yadda za a cire “Aika lokacin da” izini zuwa akwatin gidan waya ga wani mai amfani da PowerShell?

Yadda za a sami akwatin sažo mai shiga dokoki daga wani akwatin gidan waya tare da PowerShell?
Get-InboxRule -Mailbox 'Powershell.Guru'

Yadda za a samu da SMTP address ga masu amfani da suka yi OWA (Zama na gaba Web Hanya) sa tare da PowerShell?
Get-CASMailbox -Filter{OWAEnabled -eq $true} | Select-Object -Property Name, PrimarySMTPAddress

Exchange 2007

Yadda za a kafa kafin requisites ga uwar garken Musayar Garken 2007 Hub sufuri, akwatin gidan waya (MBX), da kuma Abokin ciniki Hanya Garken (CAS) da PowerShell?

Exchange 2010

Yadda za a kafa kafin requisites ga uwar garken Musayar Garken 2010 Hub sufuri, akwatin gidan waya (MBX), da kuma Abokin ciniki Hanya Garken (CAS) da PowerShell?

Exchange 2013

Yadda za a kafa kafin requisites ga uwar garken Musayar Garken 2013 akwatin gidan waya (MBX) da kuma Abokin ciniki Hanya Garken (CAS) da PowerShell?

Yadda za a kafa kafin requisites ga uwar garken Musayar Garken 2013 Abokin ciniki Hanya Garken (CAS) kawai da PowerShell?