The win32_clustershare does not have a Create method on win2008r2? How does one create file shares using ideally wmi?
I thought the Win32_ClusterShare class was read only, but could be mistaken.
To do it without WMI, you can use the cmdlets in the FailoverClusters module, but you'll probably have to install Windows Management Framework 3 or (preferably) WMF 4 on your Windows 2008 R2 machine since these cmdlets aren't available in Powershell 2.0.
With 3.0+, you should be able to use Add-ClusterResource and the related cmdlets.
Apparently the win32_clustershare.create does not work as expected and is broken. Previously this class was absent altogether from windows as indicated here-
http://support.microsoft.com/kb/971403
Apparently Using win32_share does the needful even for clusters. I confirmed in HKLM\Cluster\Resources that the share is properly registered in the cluster.
Apparently windows is able to determine that the share upon creation is properly associated with a clustered disk.
I know I am not calling the win32_clustershare wrong, because I confirmed that the parameters are identical across the 2 wmi classes.
This is evident in inspecting both
(get-cimclass -ClassName win32_share).CimClassMethods["Create"].Parameters |fl *
(get-cimclass -ClassName win32_clustershare).CimClassMethods["Create"].Parameters |fl *
If you are using Windows Server 2012 R2/Windows 8.1, you can use the new and much improved SMB PowerShell modules. Have a look at https://technet.microsoft.com/en-us/library/jj635726(v=wps.630).aspx and http://windowsitpro.com/powershell/managing-file-shares-windows-powershell
Related
I have come up with a situation in which an installed antivirus is not detected by wmic or it's equivalent cmdlet. The system where I am having this issue is a windows server 2016 and the antivirus is SEP (Symantec Endpoint Protection)
While doing some research I have found two possible explanations for this, but as far as I understood, these answers are pretty different, actually could even be complementary. Since I am a newcomer to WMI I would like some clarification about them.
The command I am using for retrieving the information is:
wmic /NAMESPACE:\\root\SecurityCenter2 path antivirusproduct GET ...
The first explanation1 I found is that the antivirusproduct class is not defined in server versions of windows which fits my problem since my machine is a windows server and I have tried the same command on a Win10 machine and it works.
The second explanation2 talks about the fact that in order to detect the antivirus through WMI it has to be registered on the Windows Security Center.
Having said that the main questions are:
Is the antivirusprocut class defined by the Windows Security Center provider, actually, does WSC have a WMI provider. If not which WMI provider is defining this class. I have been looking at the list of providers in the reference documentation3 and there doesn't seem to be a provider defining this so I assume this must be set by a provider coming from a third party software, hence the guess about WSC.
Regardless of the provider why would a class be defined on windows desktop versions and not on a server ones.
Any clarification is appreciated.
1 Detecting anti-virus on Windows with WMI - which namespace?
2 https://support.moonpoint.com/os/windows/commands/wmic/determine-antivirus.php
3 https://learn.microsoft.com/en-us/windows/win32/wmisdk/wmi-providers
Occasionally, when we perform our maintenance cycle the domain controller will take too long and some of our virtual machines will default to the public network category instead of domain authenticated. After searching through BOL and Google, I found the Get-NetConnectionProfile cmdlet but it only seems to be available on Windows 2012 and later. We have some machines still running Windows 2008. I've already attempted to use the -CimSession switch to connect to a 2008 machine and it returned an error.
Is there a PowerShell equivalent for earlier versions of Windows?
The entire CIM cmdlet came out with Server 2012, and is representing this CimClass class which is a part of Windows Management Infrastructure(MI), also introduced in Server 2012. Which seems to be replacement of Windows Management Instrumentation(WMI), or in Microsoft's word:
The Windows Management Infrastructure (MI) features represent the
latest version of the Windows Management Instrumentation (WMI)
Thus is closest counter part you can get is Get-WMIObject cmdlet in eailer OS. The item you looking for, should be MSFT_NetConnectionProfile. Unfortunately I didn't find anything similar from get-wmiobject -list. I also checked documentation here Networking Device Classes without luck.
If you give get-wmiobject a shot, I don't expect it would return things exactly the same, but maybe some wmi object(s) would return the item you care most?
I am writing a program that needs .NET to run.
When I run it on Windows 2008 Server R2 it fails upon .NET 3.5 installation.
This is because in this version of Windows you can only install .NET 3.5 via Server Manager (or Role Manager).
I was wondering if there is a way to do it programmatically?
I searched the web and found that maybe I could use PowerShell or WMI. I hoped that someone here could verify that that's the way to go, and if not, point me in the right direction.
UPDATE:
From further investigation I found that using WMIs Win32_ServerFeature_ID class I can enumerate the existing features. But I cannot find any explanation as to how to add a new feature.
Help very much needed.
Thanks.
This can be done by invoking the dism command programmatically:
dism /Online /Enable-Feature:NetFx3
I would be interested in hearing any solutions that don't require a shell-out though.
The Win32_ServerFeature wmi class does not expose any method to add or remove a Windows server feature, only is intended for list the features installed. and as far I know there is not a WMI class to do this task. the option which I can recomend you is use these PowerShell Cmdlets
Add-WindowsFeature
Get-WindowsFeature
Remove-WindowsFeature
I know this reply is in reference to Windows 7, but for anyone looking, there is an extension that works for Windows 7. PowerShell module to Add/Remove Windows 7 features
We use PowerShell to automate server setup, you'll find it will do what you like very nicely. For the feature you're looking at the script would look something like this:
Import-Module ServerManager
$netFx = Get-WindowsFeature -Name AS-NET-Framework
if ($netFx -eq $null)
{
Add-WindowsFeature AS-NET-Framework
}
This script will be runnable via your application's installation process... probably. I've run PowerShell from Windows Installer custom actions and that's (in my experience) the toughest case.
What's the simplest way to find out which version of Windows, and which service pack, is running on a computer with VBScript?
For example I'd want to know Windows XP and Service Pack 3.
An easy way of doing this is to use the WMI class Win32_OperatingSystem which has the properties ServicePackMajorVersion, ServicePackMinorVersion, Name and Version. You can find samples here: WMI Tasks: Operating Systems
The data you get back might not be in the exact format that you want though so you might need to have some kind of lookup table to make it look exactly right.
I'm looking for a way to obtain information similar to the following console applications, remotely:
net use
net share
netstat -ano
However, I need to be able to do this without running a 3rd party application on the system. This effectively rules out using psexec to execute the command remotely, because psexec would then be installed as a service.
I should add that I have administrative credentials on the remote system. I've considered using WMI's remote execution ability, but that requires me to write output to a file and then retrieve it. It's possible, but I'd like to know if anyone has a better way.
I am using Delphi 2010.
there are a couple Delphi WMI components that allow remote access. I have not used the remote options personally though.
MagWmi - http://www.magsys.co.uk/delphi/magwmi.asp (Delphi 2010 support, and free with source)
WMISet/NTSet - http://www.online-admin.com/ntset.html (TNTShare
Manages shared resources on a local computer and remote hosts. Using this component you can change list of shared devices, see files that have been opened by remote users, watch and terminate remote sessions opened to the destination computer, change list of mapped network drives. It is not free.)
GLibWMI - Found at Torry.net, home page not available. (Delphi 2010 support and Freeware with source). Not sure if its capable of remote access. I have not used it.
Hope this helps
I think the same as Logman.
You can access this information using WMI.
GLibWMI components can be found on this website (http://neftali.clubdelphi.com) or sourceforge (http://sourceforge.net/projects/glibwmi/).
The current version is 1.8b and has a component called SharedInfo with which you can get that information.
The source code is available so you can expand it to access other WMI classes if necessary.
Regards.
P.D: Sorry for my mistakes with english.
You can enumerate shares using the NetShareEnum function (headers are in the Jedi Apilib).
I assume there must be an api for the "net use" but I have never used it (check the WNet functions). Alternative is to use the EnumNetworkDrives method of the WshNetwork com object.
As for netstat I don't think it's possible to do that remotely (other than using some kind of method to spawn a process remotely).