.NET Logo
Welcome Guest Search | Active Topics | Members | Log In | Register

powershell ครั้งที่ 22 Options · View
paedotnet
Posted: Friday, March 07, 2008 12:54:41 AM

Rank: มือเทพ
Groups: Member

Joined: 12/6/2007
Posts: 344
Location: bkk

Partition
ในการหา partitions ในเครื่อง servers or workstations เขียนโค้ดดังนี้


Get-WmiObject   Win32_DiskPartition  -Computer .

ในพารามิเตอร์ -computer  ทำหน้าที่กำหนด ชื่อของเครื่องที่ต้องการ โดยชื่อคอมพิวเตอร์จะอยู่ด้านหลัง พารามิเตอร์นี้ ใน
ตัวอย่างนี้ใช้ จุด ( . ) แทนเครื่องปัจจุบัน

การแสดง สถานะของ network adapter

Get-WmiObject   -Class  Win32_NetworkAdapter -Computer .

การใช้งาน networkadapterconfiguration
โดย networkadapterconfiguration  ทำหน้าที่แสดงข้อมูลต่างๆ คล้ายๆ กับ netword adapter

$object = "Win32_NetworkAdapterConfiguration"
$ip = "IPAddress,IPSubnet,DefaultIPGateway,MACAddress"
$query = "SELECT $ip FROM $object"
Get-WmiObject  -query $query
หรือถ้าต้องการแสดง DHCP ก็เขียนได้ดังนี้
$object = "Win32_NetworkAdapterConfiguration"
$dhcp = "Index,DHCPEnabled,DHCPLeaseExpires,DHCPLeaseObtained,DHCPServer"
$query = "SELECT $dhcp FROM $object"
Get-WmiObject  -Query $query

ผลลัพธ์แสดงดังรูป

การแสดง  Bus


 Get-WmiObject Win32_Bus

การแสดง Firewall setting


$show =netsh firewall show config
$enable = $disable =$NULL
switch -regex($show)
{
"enable"
{
$enable += $switch.Current
}
"disable"
{
$disable +=$switch.Current
}
}
Write-Host "Enable :: " $enable
Write-Host "Disable :: " $disable


 



[With great power comes great responsibility]
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

YAFVision Theme Created by Jaben Cargman (Tiny Gecko)
Powered by Yet Another Forum.net version 1.9.1.8 (NET v2.0) - 3/29/2008
Copyright © 2003-2008 Yet Another Forum.net. All rights reserved.


Sponsored by