pondělí 15. února 2016

čtvrtek 4. února 2016

Rychlý scan Defenderem příkazem powershellu

PS> Start-MpScan -ScanType QuickScan -ScanPath “C:”  Funkčnost vyžaduje modul Defender !

Android a powershell

Zajimavou moznosti pro androidisty je aplikace Pulseway..Posilejte prikazy powershellu, spouštějte scripty ze sveho Androida..

pondělí 12. května 2014

Wifi síla signálu

# Wireless Statistics into object
# Author: Josh Popp
# Put Wireless Stats, like Signal Strengh, BSSID, and Channel into.?.., an object

# First just dump the netsh output into $wlanraw
    $wlanraw = netsh wlan show interface

# Create the object as "empty"
    $objWLAN = "" | Select-Object Name,SSID,BSSID,Channel,ReceiveRate,TransmitRate,Signal

# Populate the object from the output, processing 1 line at a time
    ForEach ($Line in $wlanraw) {
       
    if ([regex]::IsMatch($Line,"    Name")) {
    $objWLAN.Name = $Line -Replace "    Name                   : ",""
    }
              
if ([regex]::IsMatch($Line,"    SSID")) {
$objWLAN.SSID = $Line -Replace"    SSID                   : ",""
           }
              
         if ([regex]::IsMatch($Line,"    BSSID")) {
    $objWLAN.BSSID = $Line -Replace"    BSSID                  : ",""
}
              
if ([regex]::IsMatch($Line,"    Channel")) {
       $objWLAN.Channel = $Line -replace "    Channel                : ",""
}
              
if ([regex]::IsMatch($Line,"    Receive rate")) {
       $objWLAN.ReceiveRate = $Line -replace "    Receive rate \(Mbps\)    : ",""
}  
              
if ([regex]::IsMatch($Line,"    Transmit rate")) {
       $objWLAN.TransmitRate = $Line -replace "    Transmit rate \(Mbps\)   : ",""

              
if ([regex]::IsMatch($Line,"    Signal")) {
       $objWLAN.Signal = $Line -replace "    Signal                 : ",""
}
        }

čtvrtek 5. dubna 2012

Start | Run Commands for Windows XP, Vista and Windows 7

Start | Run Commands for Windows XP, Vista and Windows 7 http://ss64.com/nt/run.html Start | Run Commands for Windows XP, Vista and Windows 7: Accessibility Controls access.cpl Accessibility Options control access.cpl Adapter Troubleshooter (Vista/Win7) AdapterTroubleshooter Add Hardware Wizard hdwwiz.cpl Add/Remove Programs appwiz.cpl Add/Remove Programs (Add New Programs) control appwiz.cpl,,1 Add/Remove Programs (Add Remove Windows Components) control appwiz.cpl,,2 Add/Remove Programs (Set Program Access & Defaults ) control appwiz.cpl,,3 Administrative Tools control admintools Advanced User Accounts Control Panel (Vista/Win7) Netplwiz Automatic Updates wuaucpl.cpl Authorization Manager (Vista/Win7) azman.msc Backup Status and Utility (Vista/Win7) sdclt Bluetooth Transfer Wizard fsquirt Calculator calc Certificate Manager certmgr.msc Character Map charmap Check Disk Utility (XP) chkdsk Clipboard Viewer clipbrd Color Management colorcpl Command Prompt cmd Component Services dcomcnfg Computer Management (XP) compmgmt.msc Computer Management (Vista/Win7) CompMgmtLauncher Control Panel control Credential (passwords) Backup and Restore Wizard (Vista/Win7) credwiz Date and Time Properties timedate.cpl Device Manager devmgmt.msc Direct X Control Panel* directx.cpl Direct X Troubleshooter dxdiag Disk Cleanup Utility cleanmgr Disk Defragmenter (XP) dfrg.msc Disk Defragmenter (Vista) dfrgui Disk Defragmenter defrag Disk Management diskmgmt.msc Disk Partition Manager diskpart Display Properties control desktop Display Properties desk.cpl Display Properties (Appearance) control color Dr. Watson System Troubleshooting Utility drwtsn32 Driver Verifier Utility verifier Driver Package Installer (Vista/Win7) dpinst DVD Player dvdplay Event Viewer eventvwr.msc File Signature Verification Tool sigverif Files and Settings Transfer Tool migwiz Findfast findfast.cpl Firewall Control Panel (Vista/Win7) FirewallControlPanel Firewall Settings (Vista/Win7) FirewallSettings Folders Properties control folders Fonts control fonts Fonts Folder fonts Game Controllers joy.cpl Group Policy Editor (XP Prof) gpedit.msc IExpress - Turn a cmd/vbs script into an installer .exe file C:\Windows\System32\iexpress.exe (example) Indexing Service ciadv.msc Internet Properties inetcpl.cpl IP Configuration ipconfig iSCSI Initiator (Vista/Win7) iscsicpl Keyboard Properties control keyboard Language Pack Installer (Vista/Win7) lpksetup Local Security Policy secpol.msc Local Users and Groups (XP) lusrmgr.msc Log out logoff Microsoft Access* msaccess Microsoft Excel* excel Microsoft Malicious Software Removal Tool mrt Microsoft Paint mspaint Microsoft Powerpoint* powerpnt Microsoft Support Diagnostic Tool (Vista/Win7) msdt Microsoft Word* winword Mouse Properties control mouse Mouse Properties main.cpl MSN Messenger* msnmsgr Network Connections control netconnections Network Connections ncpa.cpl Network Setup Wizard netsetup.cpl Notepad notepad ODBC Data Source Administrator odbccp32.cpl 32-bit ODBC driver under 64-bit platform = C:\windows\sysWOW64\odbcad32.exe 64 bit ODBC driver under 64-bit platform = C:\windows\system32\odbcad32.exe On Screen Keyboard osk Paint pbrush Password Properties password.cpl Performance Monitor perfmon.msc Phone and Modem Options telephon.cpl Phone Dialer dialer Power Configuration powercfg.cpl Printers and Faxes control printers Printers Folder printers Private Character Editor eudcedit Quicktime* QuickTime.cpl Quicktime Player* quicktimeplayer Regional Settings intl.cpl Registry Editor regedit Registry Editor regedit32 Reliability and Performance Monitor perfmon.msc Remote Assistance(Vista/Win7) msra Remote Desktop mstsc Removable Storage ntmsmgr.msc Removable Storage Operator Requests ntmsoprq.msc Resultant Set of Policy (XP Prof) rsop.msc Scanners and Cameras sticpl.cpl Scheduled Tasks control schedtasks Security Center wscui.cpl Services services.msc Shared Creation Wizard shrpubw Shared Folders fsmgmt.msc Shut Down Windows shutdown Software Licensing/Activation (Vista/Win7) slui Sounds and Audio mmsys.cpl Sound Recorder (Vista/Win7) soundrecorder Sound Volume (Vista/Win7) sndvol SQL Client Configuration cliconfg Sync Center mobsync Syncronization Tool mobsync System Configuration Editor sysedit System Configuration Utility msconfig System File Checker Utility (Scan/Purge) sfc System Information msinfo32 System Properties sysdm.cpl System Properties (Vista/Win7) SystemPropertiesAdvanced, SystemPropertiesComputerName, SystemPropertiesDataExecutionPrevention,SystemPropertiesHardware, SystemPropertiesPerformance,SystemPropertiesProtection, SystemPropertiesRemote Task Manager taskmgr Telnet Client telnet Trusted Platform Module Initialization Wizard (Vista/Win7) TpmInit Tweak UI* tweakui User Account Management nusrmgr.cpl User Accounts (Autologon) control userpasswords2 Utility Manager utilman Windows Error Reports wercon Windows Features (Vista/Win7) optionalfeatures Windows Firewall firewall.cpl Windows Firewall with Advanced Security (Vista/Win7) wf.msc Windows Image Acquisition (scanner)(Vista/Win7) wiaacmgr Windows Magnifier magnify Windows Management Infrastructure wmimgmt.msc Windows Mobility Center (Mobile PCs only)(Vista/Win7) mblctr Windows Security Center wscui.cpl Windows System Security Tool syskey Windows Update wupdmgr Windows Update (Vista/Win7) wuapp Windows Update Standalone Installer(Vista/Win7) wusa Windows XP Tour Wizard tourstart Windows Version (About Windows) winver Wordpad write Sent from Catch Notes for Android https://catch.com

Parametry nástroje BCDEDIT

Parametry nástroje BCDEdit bcdedit /createstore Vytvoří nové prázdné úložiště konfiguračních dat spouštění. bcdedit /export Exportuje obsah úložiště systému do souboru. Tento soubor lze později použít k obnovení stavu úložiště systému. bcdedit /import Obnoví stav úložiště systému ze záložního souboru vytvořeného pomocí příkazu /export. bcdedit /sysstore Nastaví zařízení úložiště systému (týká se pouze systémů EFI, mění se při restartování a používá se pouze v případech, kdy zařízení úložiště systému není jednoznačné). bcdedit /copy Vytvoří kopie položek v úložišti. bcdedit /create Vytvoří v úložišti nové položky. bcdedit /delete Odstraní položky z úložiště. bcdedit /mirror Vytvoří zrcadlové položky v úložišti. bcdedit /deletevalue Odstraní možnosti položky z úložiště. bcdedit /set Nastaví v úložišti hodnoty možností položky. bcdedit /enum Vypíše položky v úložišti. bcdedit /bootsequence Nastaví pro správce spouštění jednorázovou spouštěcí posloupnost. bcdedit /default Nastaví výchozí položku, kterou správce spouštění použije. bcdedit /displayorder Nastaví pořadí, ve kterém správce spouštění zobrazí nabídku spouštění více operačních systémů. bcdedit /timeout Nastaví hodnotu časového limitu správce spouštění. bcdedit /toolsdisplayorder Nastaví pořadí, ve kterém správce spouštění zobrazí nabídku nástrojů. bcdedit /bootems Povolí nebo zakáže službu pro nouzovou správu spouštěcí aplikace. bcdedit /ems Povolí nebo zakáže službu pro nouzovou správu položky operačního systému. bcdedit /emssettings Nastaví globální parametry služby pro nouzovou správu. bcdedit /bootdebug Povolí nebo zakáže ladění spouštěcí aplikace. bcdedit /dbgsettings Nastaví globální parametry ladicího programu. bcdedit /debug Povolí nebo zakáže ladění jádra pro položku operačního systému. bcdedit /hypervisorsettings Nastaví parametry hypervisoru. Sent from Catch Notes for Android https://catch.com

Powershell -start parametr

 http://technet.microsoft.com/en-us/magazine/ff629472.aspx To work with Windows PowerShell, you probably open a console window by clicking Start, pointing to All Programs, pointing to Accessories, pointing to Windows PowerShell, and then choosing Windows PowerShell. Note that this technique starts Windows PowerShell with standard user privileges rather than administrator privileges. So you would not be able to perform many administrative tasks. To start Windows PowerShell with administrator privileges, you need to click Start, point to All Programs, point to Accessories, point to Windows PowerShell, right-click Windows PowerShell, and select Run As Administrator. But there are other ways to start a Windows PowerShell console. You can use the Search box on the Start menu, use the Run dialog box, or type powershell in an open command-shell window. These techniques allow you to pass arguments to Windows PowerShell, including switches that control how Windows PowerShell works and parameters that execute additional commands. For example, you can start Windows PowerShell in no-logo mode (meaning the logo banner is turned off) by using the startup command powershell -nologo. By default, when you start Windows PowerShell via the command shell, Windows PowerShell runs and then exits. If you want Windows PowerShell to execute a command and not terminate, type powershell /noexit followed by the command text. Here is a listing of the available startup parameters: -Command Specifies the command text to execute as though it were typed at the PowerShell command prompt. -EncodedCommand Specifies the base64-encoded command text to execute. -ExecutionPolicy Sets the default execution policy for the console session. -File Sets the name of a script fi le to execute. -InputFormat Sets the format for data sent to PowerShell as either text string or serialized XML. The default format is XML. Valid values are text and XML. -NoExit Does not exit after running startup commands. This parameter is useful when you run PowerShell commands or scripts via the command prompt (cmd.exe). -NoLogo Starts the PowerShell console without displaying the copyright banner. -Noninteractive Starts the PowerShell console in non-interactive mode. In this mode, PowerShell does not present an interactive prompt to the user. -NoProfile Tells the PowerShell console not to load the current user’s profile. -OutputFormat Sets the format for output as either text string or serialized XML. The default format is text. Valid values are text and XML. -PSConsoleFile Loads the specified Windows PowerShell console file. Console files end with the .psc1 extension and can be used to ensure that specific snap-in extensions are loaded and available. You can create a console file using Export-Console in Windows PowerShell. -Sta Starts PowerShell in single-threaded mode. -Version Sets the version of Windows PowerShell to use for compatibility, such as 1.0. -WindowStyle Sets the window style as Normal, Minimized, Maximized, or Hidden. The default is Normal. Sent from Catch Notes for Android https://catch.com

pondělí 27. února 2012

Změna default winre

Prepnuti browseru


Možnost čislo jedna ps1
script -noexit,je možny změnit
s tim že by se scriptem
spouštěl powershell s
-windowstyle hidden a na
konec se přidalo stop procesu
powershell.
stop-process -processname
firefox
[diagnostics.process]::start
(”C:\Users\Doma\AppData
\Local\Chromium\Application
\chrome.exe”)
Varianta dvě Powershell ise a
addon menu creator dejme
tomu auložit do profilu nebo
v addon menu a prepinat
napsanim prepni nebo
nadefinovanou zkratkou
uloženou v addon menu
creator powershell ise
function prepni
{stop-process -processname
firefox
[diagnostics.process]::start
(”C:\Users\Doma\AppData
\Local\Chromium\Application
\chrome.exe”).
Start()
}

úterý 24. ledna 2012

Bad device

PowerShell Scripts Blog: Win32_PointingDevice http://pshscripts.blogspot.com/search/label/Win32_PointingDevice $BadDevices                       Get-WmiObject Win32_PNPEntity | Where {$_.ConfigManagerErrorcode -ne 0} # Display bad devices $Hostname = Hostname if (!$BadDevices) { "No bad devices on {0}" -f $Hostname } # end if else { if (!$BadDevices.Count) {$Count=1} else {$Count=$BadDevices.count} "Total Bad devices on {0}: {1}" -f $Hostname, $Count foreach ($Device in $BadDevices) { "Name : {0}" -f $Device.Name "Class Guid : {0}" -f $Device.Classguid "Description : {0}" -f $Device.Description "Device ID : {0}" -f $Device.Deviceid "Manufacturer : {0}" -f $Device.Manufactuer "PNP Device Id : {0}" -f $Device.PNPDeviceID "Service Name : {0}" -f $Device.Service "" }

neděle 1. ledna 2012

Základni info html výstup

#### HTML Output Formatting #######

$a = "<style>"
$a = $a + "BODY{background-color:Lavender ;}"
$a = $a + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"
$a = $a + "TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:thistle}"
$a = $a + "TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:PaleGoldenrod}"
$a = $a + "</style>"

################################################################################################

###### Global variables ####

$vUserName = (Get-Item env:\username).Value    ## This will get username using environment variable
$vComputerName = (Get-Item env:\Computername).Value     ## this is computer name using environment variable
$filepath = (Get-ChildItem env:\userprofile).value  ## this is user profile  using environment variable



ConvertTo-Html -Title "System Information for $vComputerName" -Body "<h1> Computer Name : $vComputerName </h1>" >  "$filepath\$vComputerName.html" 

################################################
#  Hardware Information
#################################################

ConvertTo-Html -Body "<H1>HARDWARE INFORMATION </H1>" >> "$filepath\$vComputerName.html"


Get-WmiObject win32_bios -ComputerName $vComputerName | select Status,Version,PrimaryBIOS,Manufacturer,ReleaseDate,SerialNumber `
                                          | ConvertTo-html -Body "<H2> BIOS Information</H2>" >>  "$filepath\$vComputerName.html"
            
Get-WmiObject win32_DiskDrive -ComputerName $vComputerName | Select Model,SerialNumber,Description,MediaType,FirmwareRevision |ConvertTo-html -Body "<H2> Physical DISK Drives </H2>" >>  "$filepath\$vComputerName.html"

get-WmiObject win32_networkadapter -ComputerName $vComputerName | Select Name,Manufacturer,Description ,AdapterType,Speed,MACAddress,NetConnectionID `
                                          | ConvertTo-html -Body "<H2> Network Adapters</H2>" >>  "$filepath\$vComputerName.html"
            

################################################
#  OS Information
#################################################

ConvertTo-Html -Body "<H1>OS INFORMATION </H1>" >> "$filepath\$name.html" 

get-WmiObject win32_operatingsystem -ComputerName $vComputerName | select Caption,Organization,InstallDate,OSArchitecture,Version,SerialNumber,BootDevice,WindowsDirectory,CountryCode `
                                          | ConvertTo-html -Body "<H2> Operating System Information</H2>" >>  "$filepath\$vComputerName.html"
            
Get-WmiObject win32_logicalDisk -ComputerName $vComputerName | select DeviceID,VolumeName,@{Expression={$_.Size /1Gb -as [int]};Label="Total Size(GB)"},@{Expression={$_.Freespace / 1Gb -as [int]};Label="Free Size (GB)"} `
                                         | ConvertTo-html -Body "<H2> Logical DISK Drives </H2>" >>  "$filepath\$vComputerName.html"
           
Get-WmiObject Win32_NetworkAdapterConfiguration -ComputerName $vComputerName |
    Select-Object Description, DHCPServer, 
        @{Name='IpAddress';Expression={$_.IpAddress -join '; '}}, 
        @{Name='IpSubnet';Expression={$_.IpSubnet -join '; '}}, 
        @{Name='DefaultIPgateway';Expression={$_.DefaultIPgateway -join '; '}}, 
        @{Name='DNSServerSearchOrder';Expression={$_.DNSServerSearchOrder -join '; '}}, 
        WinsPrimaryServer, WINSSecondaryServer| ConvertTo-html -Body "<H2>IP Address </H2>" >>  "$filepath\$vComputerName.html"            



################################################
#  OS Information
#################################################

ConvertTo-Html -Body "<H1>SOFTWARE INFORMATION </H1>" >> "$filepath\$vComputerName.html"

Get-WmiObject win32_startupCommand -ComputerName $vComputerName | select Name,Location,Command,User,caption `
                                          | ConvertTo-html  -Body "<H2>Startup Softwares</H2>" >>  "$filepath\$vComputerName.html"
Get-WmiObject win32_process -ComputerName $vComputerName | select Caption,ProcessId,@{Expression={$_.Vm /1mb -as [Int]};Label="VM (MB)"},@{Expression={$_.Ws /1Mb -as [Int]};Label="WS (MB)"} |sort "Vm (MB)" -Descending `
                                         | ConvertTo-html  -Head $a -Body "<H2> Running Processes</H2>" >>  "$filepath\$vComputerName.html"
           

Get-WmiObject win32_Service  | where {$_.StartMode -eq "Auto" -and $_.State -eq "stopped"} |  Select Name,StartMode,State | ConvertTo-html  -Head $a -Body "<H2> Services </H2>" >>  "$filepath\$vComputerName.html"           
           
$Report = "The Report is generated On  $(get-date) by $((Get-Item env:\username).Value) on computer $((Get-Item env:\Computername).Value)"
$Report  >> "$filepath\$vComputerName.html" 


invoke-Expression "$filepath\$vComputerName.html"  


#################### END of SCRIPT ####################################
 
Autor:Aman Dhally










sobota 31. prosince 2011

úterý 1. listopadu 2011

Chyby za předchozí den

$end = Get-Date -Hour 0 -Minute 0 -Second 0
 $start = $end.AddDays(-1)
 Get-EventLog -LogName System -EntryType Error -Before $end -After $start

neděle 16. října 2011

Primarní networkadapter

get-wmiobject win32_networkadapter -filter "adaptertype like ‘%ethernet%’ AND Speed>0"
nebo
get-wmiobject win32_networkadapter -filter "netenabled=’true’"
get-wmiobject win32_networkadapterconfiguration -filter "IPEnabled=’True’"

pátek 16. září 2011

Seznam fontů


[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")

$objFonts = New-Object System.Drawing.Text.InstalledFontCollection
$colFonts = $objFonts.Families

$objIE = New-Object -com "InternetExplorer.Application"
$objIE.Navigate("about:blank")
$objIE.ToolBar = 0
$objIE.StatusBar = 0
$objIE.Visible = $True

$objDoc = $objIE.Document.DocumentElement.LastChild 

foreach ($objFont in $colFonts)
    {
        $strHTML = $strHTML + "<font size='5' face='" + $objFont.Name + "'>" + $objFont.Name + "</font><br>"
    }

$objDoc.InnerHTML = $strHTML

neděle 11. září 2011

admin status

Function Get-AdminStatus  {      ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")  }  $IsAdmin = Get-AdminStatus

pátek 9. září 2011

HOSTS

Function Get-HostsFile {

.SYNOPSIS

    Retrieves the contents of a hosts file on a specified system.

.DESCRIPTION

    Retrieves the contents of a hosts file on a specified system.

.PARAMETER ComputerName

    The computers to access.

.NOTES

    Name: Get-HostsFile

    Author: Boe Prox

    DateCreated: 15Mar2011

    1.1 - 2011-03-17 - Jason Archer

        Improved pipeline support (and fixed positional usage).

        Added custom object creation and incremental output (better performance and cleaner code).

        For local host, use local path.

        Added error messages for error conditions.

    1.0 - 2011-03-15 - Boe Prox

        Initial release.

.LINK

    http://boeprox.wordpress.com

.EXAMPLE

    Get-HostsFile "server1"

    Description

    -----------   

    Retrieves the contents of the hosts file on 'server1'.

#>

[CmdletBinding()]

Param(

    [Parameter(Position = 0, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)]

    [ValidateNotNull()]

    [string[]]$ComputerName = "localhost"

)

Begin {

    $PSBoundParameters.GetEnumerator() | Foreach-Object { 

        Write-Verbose "Parameter: $_"

    }

}

Process {

    Write-Verbose "Starting process of computers"

    ForEach ($c in $ComputerName ) {

        Write-Verbose "Testing connection of $c"

        If (Test-Connection -ComputerName $c -Quiet -Count 1) {

            Write-Verbose "Validating path to hosts file"

            if ($c -eq "localhost") {

                $root = "C:"

            } else {

                $root = "\\$c\C`$"

            }

            If (Test-Path "$root\Windows\system32\drivers\etc\hosts") {

                Switch -regex -file ("$root\Windows\system32\drivers\etc\hosts") {

                    "^#\w+" {

                    }

                    "^\d\w+" {

                        Write-Verbose "Adding IPV4 information to collection"

                        $new = $_.Split("") | Where-Object {$_ -ne ""}

                        If ($new[2] -eq $null) {

                            $notes = $null

                        } Else {

                            $notes = $new[2]

                        }

                        New-Object PSObject -Property @{

                            ComputerName = $c

                            IPV4 = $new[0]

                            IPV6 = $null

                            Hostname = $new[1]

                            Notes = $notes

                        }

                    }

                    Default {

                        If (!("\s+" -match $_ -OR $_.StartsWith("#"))) {

                            Write-Verbose "Adding IPV6 information to collection"

                            $new = $_.Split("") | ? {$_ -ne ""}

                            If ($new[2] -eq $null) {

                                $notes = $null

                            } Else {

                                $notes = $new[2]

                            }

                            New-Object PSObject -Property @{

                                ComputerName = $c

                                IPV4 = $null

                                IPV6 = $new[0]

                                Hostname = $new[1]

                                Notes = $notes

                            }

                        }

                    }                       

                }

            } ElseIf (Test-Path "$root\WinNT\system32\drivers\etc\hosts") {

                Switch -regex -file ("$root\WinNT\system32\drivers\etc\hosts") {

                    "^#\w+" {

                    }

                    "^\d\w+" {

                        Write-Verbose "Adding IPV4 information to collection"

                        $new = $_.Split("") | ? {$_ -ne ""}

                        If ($new[2] -eq $null) {

                            $notes = $null

                        } Else {

                            $notes = $new[2]

                        }

                        New-Object PSObject -Property @{

                            ComputerName = $c

                            IPV4 = $new[0]

                            IPV6 = $null

                            Hostname = $new[1]

                            Notes = $notes

                        }

                    }

                    Default {

                        If (!("\s+" -match $_ -OR $_.StartsWith("#"))) {

                            Write-Verbose "Adding IPV6 information to collection"

                            $new = $_.Split("") | ? {$_ -ne ""}

                            If ($new[2] -eq $null) {

                                $notes = $null

                            } Else {

                                $notes = $new[2]

                            }

                            New-Object PSObject -Property @{

                                ComputerName = $c

                                IPV4 = $null

                                IPV6 = $new[0]

                                Hostname = $new[1]

                                Notes = $notes

                            }

                        }

                    }                       

                }       

            } Else {

                ## TODO: Could use the properly localized path not found error

                Write-Error "Unable to locate host file on computer: $c"

            }

        } Else {

            ## TODO: Could use the properly localized can not locate host error

            Write-Error "Unable to locate computer: $c"   

        }

    }

}

}

pátek 22. července 2011

Portable powershell

Portable powershell public beta vyšla nová verze.Co je důležite bez přivlastku expired a nějaký datum.Více viz předchozí přispěvky o projektu.

pátek 10. června 2011

Seskupovaní podle kriterií

Opět tip z powertips

Někde v hloubi blogu je myslim už group a totožne co je na powertips jenom misto

Get-Process | Group-Object -property Company    je tam seskupovaní služeb.

Ukazka z powertips ukazuje vlastni seskupení podle tří kataegorii – rozdilná velikost,jak si je kdo nazve ve scriptu nebo kolik si takových kriteríí uděla a jaká velikost bude patřit k čemu je věc jenom toho co hledám a seskupuji.

PS> $criteria = {

if ($_.Length -lt 1KB) {

'tiny'

} elseif ($_.length -lt 1MB) {

'average'

} else {

'huge' }

}

PS> dir $env:windir | Group-Object -Property $criteria

Výsledek

hash

Tvorba hash table se samozřejmě neomezuje na velikost nebo seskupovaní procesů,nakombinovat jde spousta věcí.