Is it possible to add a Windows service dependency using powershell?

From the documentation: not through the Set-Service cmdlet.

However the Change method of Win32_Service allows dependencies to be specified: so WMI can do it.


Yes, it is possible by using Set-ItemProperty

Set-ItemProperty 
  -Path "HKLM:\SYSTEM\CurrentControlSet\Services\IBM Cognos" 
  -Name DependOnService 
  -Value @("MSSQLSERVER","W3SVC")

If the property did not exist before, you would have to use:

New-ItemProperty 
  -Path "HKLM:\SYSTEM\CurrentControlSet\Services\IBM Cognos" 
  -Name DependOnService 
  -PropertyType MultiString
  -Value @("MSSQLSERVER","W3SVC")

Enjoy!