ryan.odwyerHI CCDave, I tried that variable, but it kept returning A: drive, I couldn't find a way to check a specifc drive C.
cnwicsurrettI need to grab the disk space free on the system drive as a variable in a script... any ideas? I can't seem to get the WMI property to work correctly. Thanks.
Script Name: Get_Boot_FreeSpace Script Description: Outputs free bytes available on the Windows system drive (%SystemDrive%). Uses WMIC command to get the FreeSpace and the FOR command to just return the FreeSpace count in bytes. Works on XP and above. Greg Sloan PCM Networking IF True THEN Get Variable Parameter 1 : 2 Parameter 2 : c:\temp Parameter 3 : AgentTemp OS Type : 0 Execute Shell Command Parameter 1 : (for /f "usebackq delims== tokens=2" %a in (`wmic logicaldisk where "DeviceID='%SystemDrive%'" get FreeSpace /format:value`) do (echo %a) >>#AgentTemp#\FreeSpace.txt) Parameter 2 : 0 OS Type : 0 Get Variable Parameter 1 : 1 Parameter 2 : #AgentTemp#\freespace.txt Parameter 3 : Freespace OS Type : 0 Write Script Log Entry Parameter 1 : Freespace is #Freespace# OS Type : 0 Execute Shell Command Parameter 1 : del #AgentTemp#\Freespace.txt Parameter 2 : 0 OS Type : 0 ELSE
Script Name: Get_Boot_FreeSpace Script Description: Outputs free bytes available on the Windows system drive (%SystemDrive%). Uses WMIC command to get the FreeSpace and the FOR command to just return the FreeSpace count in bytes. Works on XP and above. Greg Sloan PCM Networking Modified by thirteentwenty Modification: Removed the set variable to agent temp dir and replaced with the nested variable so that the script will use everyones temp dir. IF True THEN Execute Shell Command Parameter 1 : (for /f "usebackq delims== tokens=2" %a in (`wmic logicaldisk where "DeviceID='%SystemDrive%'" get FreeSpace /format:value`) do (echo %a) >>#vAgentConfiguration.agentTempDir#\FreeSpace.txt) Parameter 2 : 0 OS Type : 0 Get Variable Parameter 1 : 1 Parameter 2 : #vAgentConfiguration.agentTempDir#\freespace.txt Parameter 3 : Freespace OS Type : 0 Write Script Log Entry Parameter 1 : Freespace is #Freespace# OS Type : 0 Execute Shell Command Parameter 1 : del #vAgentConfiguration.agentTempDir#\Freespace.txt Parameter 2 : 0 OS Type : 0 ELSE
thirteentwentyNicely done, I especially like that you clean up when the script is done A slightly modified version of Gregs script. Script Name: Get_Boot_FreeSpace Script Description: Outputs free bytes available on the Windows system drive (%SystemDrive%). Uses WMIC command to get the FreeSpace and the FOR command to just return the FreeSpace count in bytes. Works on XP and above. Greg Sloan PCM Networking Modified by thirteentwenty Modification: Removed the set variable to agent temp dir and replaced with the nested variable so that the script will use everyones temp dir. IF True THEN Execute Shell Command Parameter 1 : (for /f "usebackq delims== tokens=2" %a in (`wmic logicaldisk where "DeviceID='%SystemDrive%'" get FreeSpace /format:value`) do (echo %a) >>#vAgentConfiguration.agentTempDir#\FreeSpace.txt) Parameter 2 : 0 OS Type : 0 Get Variable Parameter 1 : 1 Parameter 2 : #vAgentConfiguration.agentTempDir#\freespace.txt Parameter 3 : Freespace OS Type : 0 Write Script Log Entry Parameter 1 : Freespace is #Freespace# OS Type : 0 Execute Shell Command Parameter 1 : del #vAgentConfiguration.agentTempDir#\Freespace.txt Parameter 2 : 0 OS Type : 0 ELSE
pcmnetmanageThanks, I used to use the vAgentConfiguration.agentTempDir variable in my scripts but I got tired of fighting the Kaseya script interpreter when there is a space in the agent temp path, sometime you would need to surround the command in double quotes and sometimes not, either way, it gets the job done. Thanks
Script Name: Get_Boot_FreeSpace Script Description: Outputs free bytes available on the Windows system drive (%SystemDrive%). Uses WMIC command to get the FreeSpace and the FOR command to just return the FreeSpace count in bytes. Works on XP and above. Greg Sloan PCM Networking Modified by thirteentwenty: Modifications: 1) Removed the Get Variable and replaced with nested variable to agent temp dir 2) added step three to do the math so that the output to script log would be in GB IF True THEN Execute Shell Command Parameter 1 : (for /f "usebackq delims== tokens=2" %a in (`wmic logicaldisk where "DeviceID='%SystemDrive%'" get FreeSpace /format:value`) do (echo %a) >>#vAgentConfiguration.agentTempDir#\FreeSpace.txt) Parameter 2 : 0 OS Type : 0 Get Variable Parameter 1 : 1 Parameter 2 : #vAgentConfiguration.agentTempDir#\freespace.txt Parameter 3 : b OS Type : 0 Get Variable Parameter 1 : 13 Parameter 2 : #b# / 1024 / 1024 / 1024 Parameter 3 : freespace OS Type : 0 Write Script Log Entry Parameter 1 : Freespace is #freespace# OS Type : 0 Execute Shell Command Parameter 1 : del #vAgentConfiguration.agentTempDir#\Freespace.txt Parameter 2 : 0 OS Type : 0 ELSE