I have a java application with many jars. I noticed that running the app from a share takes more time than running it from localdisk.
I would like to create a wrapper script that copies that jars to local disk only if the app was installed on a network path.
Is there a way to find out if a specific folder is on localdisk or network?
you could use wmi for that : check drivetype of the Win32_LogicalDisk class
type 3 => local
type 4 => net drive
an example using powerhsell
gwmi win32_logicaldisk -filter "deviceId='X:'" |select -expand drivetype
or
switch(gwmi win32_logicaldisk -filter "deviceId='X:'" |select -expand drivetype){3{"local"}4{"network"}}
Related
I need to link a computer to an object in Active Directory.
Basically, I need to link a locally available property to a property that can be found in AD so I can positively link the device to the computer object in Active Directory. The device may be off network, and not able to access a domain controller when it is queried.
From research, the computer's objectGUID or objectSID attributes stored locally do not match the AD ones.
ie:
get-adcomputer -identity ComputerName -property MachineGUID,SID
returns different GUID and SID than the ones found via
wmic path win32_computersystemproduct get uuid
and PSTools's
PSGetSID
..so, is there an indentifier that can be retrieved both locally and in AD that can allow to match a computer?
Thanks
Try locally:
Get-WmiObject -class SoftwareLicensingService | Select-object ClientMachineID
and then on AD Domain controller:
Import-module activedirectory
$ComputerName="enter computername here"
$Computer = Get-ADComputer –Identity $ComputerName –property *
$ComputerCMID = Get-WmiObject –computer $ComputerName -class SoftwareLicensingService | Select-object ClientMachineID
Write-Output "$ComputerName has the CMID: $ComputerCMID "
I already knew how to get all network adaptors names, but I can't tell the difference between normally using and not identified
By using
netsh interface ip show interfaces
or other commands ,you may get all adaptors names.
The necessary information can be obtained using the Win32_NetworkAdapter class.For example:
Get-CimInstance -ClassName Win32_NetworkAdapter -Filter #'
NetConnectionID = "Local Area Connection" AND
NetConnectionStatus=2 AND NetEnabled = True AND PhysicalAdapter = True
'# | Format-List *
The Get-WmiObject cmdlet can also be used, but starting in PowerShell 3.0, it has been superseded by Get-CimInstance.Starting with Windows 8, you can use the Get-NetAdapter cmdlet.
I'm trying to get various properties for each hdd-volume on the computer.
I was using the cmdlet get-volume and then walking through it via foreach, but that cmdlet does not exist in Windows Server 2008. :(
Does anybody know an alternative?
I just need the drive letter, objectId/guid, free space, total space, and the name of each volume.
The WMI class Win32_Volume has the information you are looking for
Get-WMIObject -Class Win32_Volume | Select DriveLetter,FreeSpace,Capacity,DeviceID,Label
Which a little fancy footwork you can make the drive space properties looking a little more appealing.
Get-WmiObject -Class Win32_Volume |
Select DriveLetter,
#{Label="FreeSpace (In GB)";Expression={$_.Freespace/1gb}},
#{Label="Capacity (In GB)";Expression={$_.Capacity/1gb}},
DeviceID,Label |
Format-Table -AutoSize
Get-Volume is only in Powershell 4.
You can do this tho:
Get-WmiObject Win32_LogicalDisk | Select-Object DeviceID, Size, FreeSpace, VolumeName
I am looking for a powershell command that will pull the free space of a Cluster Shared Volume as it does not have a logical drive letter on a remote system. The Following is the Command I use on Logical Drives so you can see an example of the output I am Looking for. I am looking for just a numeric value of available megabytes.
Get-WMIObject -computer server -filter "DeviceID = 'C:'" Win32_LogicalDisk |
ForEach-Object {[math]::truncate($_.freespace / 1MB)}
Thanks in advance for your Help!
You can't determine the free space of a Cluster Shared Volume (CSV) on a per-host basis. CSVs are cluster-shared resources, so you need to use cluster tools for obtaining information about them:
$cluster = 'Cluster Name'
$volume = 'Cluster Shared Volume Name'
Import-Module failoverclusters
Get-ClusterSharedVolume -Name $volume -Cluster $cluster `
| select -Expand SharedVolumeInfo `
| select #{n='FreeSpace';e={($_.Partition.Size - $_.Partition.UsedSpace)/1MB}}
Does anybody know if there is a Windows API to return the location of the hiberfil.sys ?
Many thanks
Hiberfil.sys is created when you enable hibernation and have hibernated your computer at least once. Its location can be determined like any other file: by directing the OS to search for it. Its usual location is in the root of your system drive, which is usually C:. This working powershell script was found here. See the link for the full script, but this is the core:
gwmi cim_datafile -filter "path='\\'" | ? {$_.name -match 'hiberfil.sys'} or
gwmi -Query "Associators of {Win32_Directory.Name='C:\'} Where ResultClass=CIM_DataFile" | ? {$_.name -match 'hiberfil.sys'}
Also helpful, Karl. E. Peterson's API reference:
http://vb.mvps.org/samples/apixref.asp
He also has made available for download some sample code, zipped up. Hope this helps...