I have multiple folders with space in the folder name, and need to replace the space with underscore.
Found a simple batch file to do that
From this:
To this:
Script:
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
FOR /D %%d IN (*) DO (
SET "NAME=%%d"
SET "NEWNAME=!NAME: =_!"
IF NOT "!NAME!"=="!NEWNAME!" rename "!NAME!" "!NEWNAME!"
)
pause
exit
Showing posts with label windows. Show all posts
Showing posts with label windows. Show all posts
Thursday, November 9, 2017
Replace "space" with"underscore" in folder name - recursively
Monday, July 8, 2013
Disk drive is write protected, Unable to create file with File system error (65535)
Some simptoms:
Unable to create file with File system error (65535)
Whenever I try to create new file in my one of my system drives it is displaying "Unable to create file xxxx.txt". File system error(65535) Previously I was able to create/delete files.
Now every thing related to file operations are getting failed (create/delete/modify).
For file modify following error message is displayed "The drive cannot fine sector requested".
Second hard drive says write-protected
I've got a new 2008 enterprise terminal server. I've installed all my apps to the 2nd hard drive. Now for no reason, I can't write to the drive and my apps can't either as they all crash as soon as they need to.
I get this exact error when simply trying to create a directory in the root of the drive:
"The disk is write-protected.
Remove the write-protection or use another disk."
I'm logging in as the local admin, domain admin makes no diff. I've also given full permissions to "everyone" with no luck. How the heck can I fix this bugger?
Unable to create file with File system error (65535)
Whenever I try to create new file in my one of my system drives it is displaying "Unable to create file xxxx.txt". File system error(65535) Previously I was able to create/delete files.
Now every thing related to file operations are getting failed (create/delete/modify).
For file modify following error message is displayed "The drive cannot fine sector requested".
Second hard drive says write-protected
I've got a new 2008 enterprise terminal server. I've installed all my apps to the 2nd hard drive. Now for no reason, I can't write to the drive and my apps can't either as they all crash as soon as they need to.
I get this exact error when simply trying to create a directory in the root of the drive:
"The disk is write-protected.
Remove the write-protection or use another disk."
I'm logging in as the local admin, domain admin makes no diff. I've also given full permissions to "everyone" with no luck. How the heck can I fix this bugger?
Solution:
It could be that the ReadOnly flag is on, do the following
on cmd prompt launch "diskpart.exe"
on the diskpart prompt, do the following
This will give you a list of all disks in your system
Note down the number of your problem disk, then do the folloiwng
Where x is the number of your problem disk, then do the following
This will list all the details of your problem disk
Check if the ReadOnly flag is set to Yes
If the ReadOnly flag is set to Yes, do the follwing
This should clear the flag on the disk, please retry your disk operations
If ths does not solve it, we have another flag on the volume, same command, but now on volume:
on cmd prompt launch "diskpart.exe"
on the diskpart prompt, do the following
| LIST DISK |
This will give you a list of all disks in your system
Note down the number of your problem disk, then do the folloiwng
| SELECT DISK x |
Where x is the number of your problem disk, then do the following
| DETAIL DISK |
This will list all the details of your problem disk
Check if the ReadOnly flag is set to Yes
If the ReadOnly flag is set to Yes, do the follwing
| ATTR DISK CLEAR READONLY |
This should clear the flag on the disk, please retry your disk operations
If ths does not solve it, we have another flag on the volume, same command, but now on volume:
| LIST VOLUME |
| SELECT VOLUME x |
| DETAIL VOLUME |
| ATTR VOLUME CLEAR READONLY |
Wednesday, June 5, 2013
powershell script to get number of CPU and Memory
takes input list of servers from C:\servers.txt and output the result to C:\ram-cpu.csv
make sure your powershell/powerCLI has admin rights
get-wmiobject Win32_ComputerSystem -computer (gc C:\servers.txt) | select Name,@{name="TotalPhysicalMemory(MB)";expression={($_.TotalPhysicalMemory/1mb).tostring("N0")}},NumberOfProcessors | export-csv C:\ram-cpu.csv
make sure your powershell/powerCLI has admin rights
get-wmiobject Win32_ComputerSystem -computer (gc C:\servers.txt) | select Name,@{name="TotalPhysicalMemory(MB)";expression={($_.TotalPhysicalMemory/1mb).tostring("N0")}},NumberOfProcessors | export-csv C:\ram-cpu.csv
Get logical disk layout from OS level (windows)
run this in powerCLI / powershell. make sure you have admin rights (elevated for the powerCLI/powershell)
it takes list of servers from c:\servers.txt and output the result to c:\Disk-GB.csv
gwmi -query "SELECT SystemName,Caption,VolumeName,Size,Freespace FROM win32_logicaldisk WHERE DriveType=3" -computer (gc c:\servers.txt) | Select-Object SystemName,Caption,VolumeName,@{Name="Size(GB)"; Expression={"{0:N2}" -f ($_.Size/1GB)}},@{Name="Freespace(GB)"; Expression={"{0:N2}" -f ($_.Freespace/1GB)}}, @{n="% Free";e={"{0:P2}" -f ([long]$_.FreeSpace/[long]$_.Size)}} | sort "Systemname","caption" | export-csv c:\Disk-GB.csv
it takes list of servers from c:\servers.txt and output the result to c:\Disk-GB.csv
gwmi -query "SELECT SystemName,Caption,VolumeName,Size,Freespace FROM win32_logicaldisk WHERE DriveType=3" -computer (gc c:\servers.txt) | Select-Object SystemName,Caption,VolumeName,@{Name="Size(GB)"; Expression={"{0:N2}" -f ($_.Size/1GB)}},@{Name="Freespace(GB)"; Expression={"{0:N2}" -f ($_.Freespace/1GB)}}, @{n="% Free";e={"{0:P2}" -f ([long]$_.FreeSpace/[long]$_.Size)}} | sort "Systemname","caption" | export-csv c:\Disk-GB.csv
Wednesday, February 20, 2013
Custom VM report, output to CSV
Note: VC, Template and Description is for manual entry, they don't have any data :)
function Get-myReport {
#sample: get-content test.txt | %{ Get-myReport $_ } | export-csv C:\testout.csv -notypeinformation
param ($VM)
$report = @()
$row = "" | select VC, Cluster, Name, Template, ResourcePool, NumCPU, RAMSizeGB, D_DriveSizeGB, VLAN, Application, BusinessUnit, Category, Support, Description
$v = get-vm $VM
$VLAN = get-virtualportgroup -vm $VM
$app = get-vm -Name $VM | get-annotation | where-object {$_.Name -eq "Application"}
$unit = get-vm -Name $VM | get-annotation | where-object {$_.Name -eq "business unit"}
$category = get-vm -Name $VM | get-annotation | where-object {$_.Name -eq "category"}
$support = get-vm -Name $VM | get-annotation | where-object {$_.Name -eq "support"}
$row.Cluster = $v.vmhost.parent.name
$row.Name = $VM
$row.ResourcePool = $v.resourcepool.name
$row.NumCPU = $v.NumCpu
$row.RAMSizeGB = $v.MemoryMB / 1024
$row.D_DriveSizeGB = ""
$row.VLAN = $VLAN.name
$row.Application = $app.value
$row.BusinessUnit = $unit.value
$row.Category = $category.value
$row.Support = $support.value
$DriveD = Get-mVMdriveD $VM
$row.D_DriveSizeGB = $DriveD.Size
$report += $row
$report
}
function Get-mVMdriveD {
param ($VM)
gwmi -query "SELECT Caption, Size FROM win32_logicaldisk WHERE DriveType=3" -computer $VM | where-object { $_.Caption -eq "D:" } | select-object @{Name="Size"; Expression={"{0:N0}" -f ($_.Size/1GB)}}
}
function Get-myReport {
#sample: get-content test.txt | %{ Get-myReport $_ } | export-csv C:\testout.csv -notypeinformation
param ($VM)
$report = @()
$row = "" | select VC, Cluster, Name, Template, ResourcePool, NumCPU, RAMSizeGB, D_DriveSizeGB, VLAN, Application, BusinessUnit, Category, Support, Description
$v = get-vm $VM
$VLAN = get-virtualportgroup -vm $VM
$app = get-vm -Name $VM | get-annotation | where-object {$_.Name -eq "Application"}
$unit = get-vm -Name $VM | get-annotation | where-object {$_.Name -eq "business unit"}
$category = get-vm -Name $VM | get-annotation | where-object {$_.Name -eq "category"}
$support = get-vm -Name $VM | get-annotation | where-object {$_.Name -eq "support"}
$row.Cluster = $v.vmhost.parent.name
$row.Name = $VM
$row.ResourcePool = $v.resourcepool.name
$row.NumCPU = $v.NumCpu
$row.RAMSizeGB = $v.MemoryMB / 1024
$row.D_DriveSizeGB = ""
$row.VLAN = $VLAN.name
$row.Application = $app.value
$row.BusinessUnit = $unit.value
$row.Category = $category.value
$row.Support = $support.value
$DriveD = Get-mVMdriveD $VM
$row.D_DriveSizeGB = $DriveD.Size
$report += $row
$report
}
function Get-mVMdriveD {
param ($VM)
gwmi -query "SELECT Caption, Size FROM win32_logicaldisk WHERE DriveType=3" -computer $VM | where-object { $_.Caption -eq "D:" } | select-object @{Name="Size"; Expression={"{0:N0}" -f ($_.Size/1GB)}}
}
Wednesday, September 5, 2012
Windows Slowdown, Investigated and Identified
reblogging from http://randomascii.wordpress.com/2012/09/04/windows-slowdown-investigated-and-identified/
all credits goes to original author, I'm merely archiving it for my personal future reference.
in short, if your free memory is high, and cached is low, there's a culprit in there.
all credits goes to original author, I'm merely archiving it for my personal future reference.
in short, if your free memory is high, and cached is low, there's a culprit in there.
Labels:
slowdown,
sysadmin,
troubleshooting,
windows
Subscribe to:
Posts (Atom)

