PS: Script to update SQL DB

Below is a PowerShell scripted version of silently updating the SQL DB and saving the SQL query results in a log file.   $sql_file = ‘C:appUpdate-SQLDB.sql’ $sql_log  = ‘C:appUpdate-SQLDB.log’ Add-Content -Path $sql_file  "Update <DBName>..<TableName> set db_database_name = ‘CustomDB_00’ Where db_database_name = ‘AppDefaultDB’" ; Add-Content -Path $sql_file  "Update <DBName>..<TableName> set db_database_name = ‘CustomDB_Trial_00’ Where db_database_name = ‘AppDefaultDB_Trial’" Write-Output "$sql_file" >> "$sql_log" SQLCMD.EXE -U sa -P ‘sapassword’ -S <DBServerName><DBInstanceName> -i $sql_file | out-File $sql_log

Read more

PS: Creating Registry Entries

  Creating an hexadecimal REG_BINARY value: PS cmdlet with syntax: set-itemproperty –path  "HKCU:SoftwareMicrosoftWindowsCurrentVersionExplorerModulesGlobalSettingsSizer" -name "PageSpaceControlSizer"  -Type Binary -value ([byte[]]("0xce", "0x00", "0x000", "0x000", "0x000", "0x000", "0x000", "0x000", "0x000", "0x000", "0x000", "0x000")) Verification: C:>reg query "HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerModulesGlobalSettingsSizer" /v PageSpaceControlSizer HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerModulesGlobalSettingsSizer     PageSpaceControlSizer    REG_BINARY    CE0000000000000000000000 C:>   Creating REG_DWORD value: PS cmdlet with syntax: set-itemproperty -path "HKCU:SoftwareMicrosoftWindowsCurrentVersionExplorerHideDesktopIconsClassicStartMenu" -name "{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}"  -Type DWORD -value "1" Verification: C:>reg query "HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerHideDesktopIconsClassicStartMenu" /v "{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}" HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerHideDesktopIconsClassicStartMenu     {F02C1A0D-BE21-4350-88B0-7367FC96EF3C}    REG_DWORD    0x1 C:>

Read more

Managing Registry via Powershell

PROVIDER NAME Registry DRIVES HKLM:, HKCU: SHORT DESCRIPTION Provides access to the registry keys, entries, and values in Windows PowerShell. DETAILED DESCRIPTION The Windows PowerShell Registry provider lets you get, add, change, clear, and delete registry keys, entries, and values in Windows PowerShell. Registry keys are represented as instances of the Microsoft.Win32.RegistryKey class. Registry entries are represented as instances of the PSCustomObject class. The Registry provider lets you access a hierarchical namespace that consists of registry keys and subkeys. Registry entries and values are not components of that hierarchy. Instead, they are properties of each of the keys. The Registry […]

Read more