Good day Experts,How can i save the following script in a powershell file. The script is copied to txt document but i want to change it to .PS 1 file.I tried save as but it is not giving me ps1 option.Function out-DataTable { $dt = new-object Data.datatable $First = $true foreach ($item in $input){ $DR = $DT.NewRow() $Item.PsObject.get_properties() | foreach { if ($first) { $Col = new-object Data.DataColumn $Col.ColumnName = $_.Name.ToString() $DT.Columns.Add($Col) } if ($_.value -eq $null) { $DR.Item($_.Name) = "[empty]" } elseif ($_.IsArray) { $DR.Item($_.Name) =[string]::Join($_.value ,";") } else { $DR.Item($_.Name) = $_.value } } $DT.Rows.Add($DR) $First = $false } return @(,($dt))}$hostname = $env:computername$AfterDate = Get-Date$dataTable = Get-WMIObject Win32_LogicalDisk -filter "DriveType=3" -computer $hostname | Select ProviderName, SystemName, DeviceID , VolumeName, Size, FreeSpace | out-DataTable$connectionString = "Data Source=localhost; Integrated Security=True;Initial Catalog=master;"$bulkCopy = new-object ("Data.SqlClient.SqlBulkCopy") $connectionString$bulkCopy.DestinationTableName = "dbo.DriveStatus"$bulkCopy.WriteToServer($dataTable)
↧