red.army@vk
25-12-2014, 07:33
Научите пользоваться WMIobject.
Вот допустим хочу найти WMI связанный с сетевыми шарами
PS C:\> Get-WmiObject -List | grep share
Win32_Share {Create, SetShare... {AccessMask, AllowMaximum, Caption, Description...}
Win32_ClusterShare {Create, SetShare... {AccessMask, AllowMaximum, Caption, Description...}
Win32_LogicalShareSecuritySetting {GetSecurityDescr... {Caption, ControlFlags, Description, Name...}
Win32_SecuritySettingOfLogicalShare {} {Element, Setting}
Win32_OfflineFilesBackgroundSync {} {BackgroundSyncWorkOfflineSharesEnabled, BlockOutDurationMin, BlockOutStartTimeHoursMinutes, MaxTimeBetweenSyncs...}
Win32_ShareToDirectory {} {Share, SharedElement}
CIM_AdjacentSlots {} {DistanceBetweenSlots, SharedSlots, SlotA, SlotB}
Win32_LogicalShareAuditing {} {AuditedAccessMask, GuidInheritedObjectType, GuidObjectType, Inheritance...}
Win32_PrinterShare {} {Antecedent, Dependent}
Win32_ConnectionShare {} {Antecedent, Dependent}
Win32_LogicalShareAccess {} {AccessMask, GuidInheritedObjectType, GuidObjectType, Inheritance...}
PS C:\> Get-WmiObject win32_share
Name Path Description
---- ---- -----------
ADMIN$ C:\Windows Remote Admin
C$ C:\ Default share
E E:\
IPC$ Remote IPC
print$ C:\Windows\system32\spool\drivers Printer Drivers
PS C:\> Get-WmiObject win32_share | Get-Member
TypeName: System.Management.ManagementObject#root\cimv2\Win32_Share
Name MemberType Definition
---- ---------- ----------
PSComputerName AliasProperty PSComputerName = __SERVER
Delete Method System.Management.ManagementBaseObject Delete()
GetAccessMask Method System.Management.ManagementBaseObject GetAccessMask()
SetShareInfo Method System.Management.ManagementBaseObject SetShareInfo(System.UInt32 MaximumAllowed, System.String Description, System.Management.Management...
AccessMask Property uint32 AccessMask {get;set;}
AllowMaximum Property bool AllowMaximum {get;set;}
Caption Property string Caption {get;set;}
Description Property string Description {get;set;}
InstallDate Property string InstallDate {get;set;}
MaximumAllowed Property uint32 MaximumAllowed {get;set;}
Name Property string Name {get;set;}
Path Property string Path {get;set;}
Status Property string Status {get;set;}
Type Property uint32 Type {get;set;}
__CLASS Property string __CLASS {get;set;}
__DERIVATION Property string[] __DERIVATION {get;set;}
__DYNASTY Property string __DYNASTY {get;set;}
__GENUS Property int __GENUS {get;set;}
__NAMESPACE Property string __NAMESPACE {get;set;}
__PATH Property string __PATH {get;set;}
__PROPERTY_COUNT Property int __PROPERTY_COUNT {get;set;}
__RELPATH Property string __RELPATH {get;set;}
__SERVER Property string __SERVER {get;set;}
__SUPERCLASS Property string __SUPERCLASS {get;set;}
PSStatus PropertySet PSStatus {Status, Type, Name}
ConvertFromDateTime ScriptMethod System.Object ConvertFromDateTime();
ConvertToDateTime ScriptMethod System.Object ConvertToDateTime();
Итак есть метод Delete, как им воспользоваться, не создавая переменную?
только так? :
(Get-WmiObject win32_share | where {$_.Name -eq "E"}).delete()
Вот допустим хочу найти WMI связанный с сетевыми шарами
PS C:\> Get-WmiObject -List | grep share
Win32_Share {Create, SetShare... {AccessMask, AllowMaximum, Caption, Description...}
Win32_ClusterShare {Create, SetShare... {AccessMask, AllowMaximum, Caption, Description...}
Win32_LogicalShareSecuritySetting {GetSecurityDescr... {Caption, ControlFlags, Description, Name...}
Win32_SecuritySettingOfLogicalShare {} {Element, Setting}
Win32_OfflineFilesBackgroundSync {} {BackgroundSyncWorkOfflineSharesEnabled, BlockOutDurationMin, BlockOutStartTimeHoursMinutes, MaxTimeBetweenSyncs...}
Win32_ShareToDirectory {} {Share, SharedElement}
CIM_AdjacentSlots {} {DistanceBetweenSlots, SharedSlots, SlotA, SlotB}
Win32_LogicalShareAuditing {} {AuditedAccessMask, GuidInheritedObjectType, GuidObjectType, Inheritance...}
Win32_PrinterShare {} {Antecedent, Dependent}
Win32_ConnectionShare {} {Antecedent, Dependent}
Win32_LogicalShareAccess {} {AccessMask, GuidInheritedObjectType, GuidObjectType, Inheritance...}
PS C:\> Get-WmiObject win32_share
Name Path Description
---- ---- -----------
ADMIN$ C:\Windows Remote Admin
C$ C:\ Default share
E E:\
IPC$ Remote IPC
print$ C:\Windows\system32\spool\drivers Printer Drivers
PS C:\> Get-WmiObject win32_share | Get-Member
TypeName: System.Management.ManagementObject#root\cimv2\Win32_Share
Name MemberType Definition
---- ---------- ----------
PSComputerName AliasProperty PSComputerName = __SERVER
Delete Method System.Management.ManagementBaseObject Delete()
GetAccessMask Method System.Management.ManagementBaseObject GetAccessMask()
SetShareInfo Method System.Management.ManagementBaseObject SetShareInfo(System.UInt32 MaximumAllowed, System.String Description, System.Management.Management...
AccessMask Property uint32 AccessMask {get;set;}
AllowMaximum Property bool AllowMaximum {get;set;}
Caption Property string Caption {get;set;}
Description Property string Description {get;set;}
InstallDate Property string InstallDate {get;set;}
MaximumAllowed Property uint32 MaximumAllowed {get;set;}
Name Property string Name {get;set;}
Path Property string Path {get;set;}
Status Property string Status {get;set;}
Type Property uint32 Type {get;set;}
__CLASS Property string __CLASS {get;set;}
__DERIVATION Property string[] __DERIVATION {get;set;}
__DYNASTY Property string __DYNASTY {get;set;}
__GENUS Property int __GENUS {get;set;}
__NAMESPACE Property string __NAMESPACE {get;set;}
__PATH Property string __PATH {get;set;}
__PROPERTY_COUNT Property int __PROPERTY_COUNT {get;set;}
__RELPATH Property string __RELPATH {get;set;}
__SERVER Property string __SERVER {get;set;}
__SUPERCLASS Property string __SUPERCLASS {get;set;}
PSStatus PropertySet PSStatus {Status, Type, Name}
ConvertFromDateTime ScriptMethod System.Object ConvertFromDateTime();
ConvertToDateTime ScriptMethod System.Object ConvertToDateTime();
Итак есть метод Delete, как им воспользоваться, не создавая переменную?
только так? :
(Get-WmiObject win32_share | where {$_.Name -eq "E"}).delete()