neděle 24. října 2010

Powershell disky oddíly a blbinky

Rychlá serie pár scriptíku bez vysvětlování co dělají a jak to dělají.Kdo chtěl už se tím prokousal,ostatní většinu ani nespustí.

Zakladní výpis logical disk

Get-WmiObject Win32_LogicalDisk | `
Select Name, DriveType, FileSystem, Size, FreeSpace | `
Format-Table -AutoSize

 

WIN32 Mount point

$computer = "LocalHost"
$namespace = "root\CIMV2"
Get-WmiObject -class Win32_MountPoint -computername $computer -namespace $namespace

Win32_OSRecoveryConfiguration

$computer = "LocalHost"
$namespace = "root\CIMV2"
Get-WmiObject -class Win32_OSRecoveryConfiguration -computername $computer -namespace $namespace

Win32_ShadowCopy

$computer = "LocalHost"
$namespace = "root\CIMV2"
Get-WmiObject -class Win32_ShadowCopy -computername $computer -namespace $namespace

Win32_SystemAccount

$computer = "LocalHost"
$namespace = "root\CIMV2"
Get-WmiObject -class Win32_SystemAccount -computername $computer -namespace $namespace

Win32_UserAccount

$computer = "LocalHost"
$namespace = "root\CIMV2"
Get-WmiObject -class Win32_UserAccount -computername $computer -namespace $namespace

Win32_DiskDrive

$computer = "LocalHost"
$namespace = "root\CIMV2"
Get-WmiObject -class Win32_DiskDrive -computername $computer -namespace $namespace

Win32_DiskDriveToDiskPartition

$computer = "LocalHost"
$namespace = "root\CIMV2"
Get-WmiObject -class Win32_DiskDriveToDiskPartition -computername $computer -namespace $namespace

Win32_DiskPartition

$computer = "LocalHost"
$namespace = "root\CIMV2"
Get-WmiObject -class Win32_DiskPartition -computername $computer -namespace $namespace

Win32_DiskQuota

$computer = "LocalHost"
$namespace = "root\CIMV2"
Get-WmiObject -class Win32_DiskQuota -computername $computer -namespace $namespace

Win32_DMAChannel

$computer = "LocalHost"
$namespace = "root\CIMV2"
Get-WmiObject -class Win32_DMAChannel -computername $computer -namespace $namespace

Win32_DriverForDevice

$computer = "LocalHost"
$namespace = "root\CIMV2"
Get-WmiObject -class Win32_DriverForDevice -computername $computer -namespace $namespace

Win32_IDEController

$computer = "LocalHost"
$namespace = "root\CIMV2"
Get-WmiObject -class Win32_IDEController -computername $computer -namespace $namespace

Win32_LogicalDiskRootDirectory

$computer = "LocalHost"
$namespace = "root\CIMV2"
Get-WmiObject -class Win32_LogicalDiskRootDirectory -computername $computer -namespace $namespace

Win32_IDEControllerDevice

$computer = "LocalHost"
$namespace = "root\CIMV2"
Get-WmiObject -class Win32_IDEControllerDevice -computername $computer -namespace $namespace

Win32_LogonSession

$computer = "LocalHost"
$namespace = "root\CIMV2"
Get-WmiObject -class Win32_LogonSession -computername $computer -namespace $namespace

Win32_Volume

$computer = "LocalHost"
$namespace = "root\CIMV2"
Get-WmiObject -class Win32_Volume -computername $computer -namespace $namespace

Některe vyžadují jednoznačně PowershellV2,ale myslim že pro XP a Visty byl formou stažení  v Seven je to jasné.Součast systemu.

Něco bude možná chtit  Windows 7 Resource Kit PowerShell Pack  ale kdo používá tak opět – dávno pradávno má.

Na zavěr jedna z legracek typu rss feed v powershellu,upravování obrazků v powershellu tak tady pro změnu kdyby Vás štvalo gui třeba WINAMPU

http://theessentialexchange.com/blogs/michael/archive/2007/11/15/shuffle-play-your-audio-files-with-powershell.aspx

No a krasná ukázka proč je powershell OBJEKTOVÝ SHELL takže něco uplně jineho než cmd

NEWTWORK MAP DRIVE -  KDO SI TO CHCE V GRAFICKEM ROZHRANÍ NAKLIKAT V SHELLU,ZVLAŠTNÍ KOMBINACE…

 

function mapdrive {

$map = New-Object -ComObject wscript.network
if($letter.Text -match ":"){
$letter = $letter.Text}
else{$letter = $letter.Text+":"}
$map.MapNetworkDrive($letter,$path.Text)

}

 

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

$Form = New-Object System.Windows.Forms.Form

$Form.width = 500
$Form.height = 350
$Form.Text = "Map Drive"
$Form.backcolor = "#5D8AA8"
$Form.maximumsize = New-Object System.Drawing.Size(500, 350)
$Form.startposition = "centerscreen"
$Form.KeyPreview = $True
$Form.Add_KeyDown({if ($_.KeyCode -eq "Escape")
    {$Form.Close()}})

$ListButton = new-object System.Windows.Forms.Button
$ListButton.Location = new-object System.Drawing.Size(200,200)
$ListButton.Size = new-object System.Drawing.Size(80,30)
$ListButton.Text = "MAP"
$ListButton.FlatAppearance.MouseOverBackColor = [System.Drawing.Color]::FromArgb(255, 255, 192);
$ListButton.ImageAlign = [System.Drawing.ContentAlignment]::MiddleLeft;
$Listbutton.FlatStyle = [System.Windows.Forms.FlatStyle]::Flat
$ListButton.Add_Click({mapdrive})

$Form.Controls.Add($ListButton)

$letter = new-object System.Windows.Forms.TextBox
$letter.Location = new-object System.Drawing.Size(65,60)
$letter.Size = new-object System.Drawing.Size(100,20)

$Form.Controls.Add($letter)

$letterlabel = new-object System.Windows.Forms.Label
$letterlabel.Location = new-object System.Drawing.Size(60,10)
$letterlabel.size = new-object System.Drawing.Size(100,50)
$letterlabel.Font = new-object System.Drawing.Font("Microsoft Sans Serif",12,[System.Drawing.FontStyle]::Bold)
$letterlabel.Text = "Drive Letter"
$Form.Controls.Add($letterlabel)

$pathlabel = new-object System.Windows.Forms.Label
$pathlabel.Location = new-object System.Drawing.Size(310,10)
$pathlabel.size = new-object System.Drawing.Size(200,50)
$pathlabel.Font = new-object System.Drawing.Font("Microsoft Sans Serif",12,[System.Drawing.FontStyle]::Bold)
$pathlabel.Text = "UNC path"
$Form.Controls.Add($pathlabel)

$path = new-object System.Windows.Forms.TextBox
$path.Location = new-object System.Drawing.Size(300,60)
$path.Size = new-object System.Drawing.Size(100,20)


$Form.Controls.Add($path)


$Form.Add_Shown({$Form.Activate()})
$Form.ShowDialog()