I have a column with computer names however the names are formatted like this domain\computer name. Usually in Excel I can use find/replace and search for *\ and replace with blank leaving just the computer name. I have a powershell script that finds *\ however it replaces the whole cell with nothing. It's like its searching for any cell that contains *\ and replacing that instead of just leaving the computer name.
$file = "C:\reports\report.xls"
$Excel = New-Object -ComObject Excel.Application
$Excel.Visible = $true
$Workbok = $Excel.workbooks.open($file)
$Worksheets = $Workbook.worksheets
$Worksheet = $Workbook.Worksheets.Item(1)
$Worksheet = $Workbok.Worksheets.Item(1)
$SearchString = "*\"
$Range = $Worksheet.Range("A1").EntireColumn
$Search = $Range.find($SearchString)
if($search -ne $null){
$FirstAddress = $Search.Address
do{
$Search.value() = ""
$search = $Range.FindNext($search)
}while ($search -ne $null -and $search.Address -ne $FirstAddress)