$env
$env:path
$env:PSModulePath
Full list
Get-Childitem env:
$env
$env:path
$env:PSModulePath
Get-Childitem env:
When you want to capture a menu option, (that annoyingly disappears when you try to capture with snipping tool), use the following
procedure:
To get help about regular expressions in powershell, at the command prompt:
help about_regular_expression
use[master] -- SQL Server authentication logins select * from sys.sql_logins -- all logins/users select * from sys.server_principals order by type_desc
use [msdb] select * from sysjobs select * from sysjobactivity select * from sysjobs_view select * from sysjobhistory order by job_id, step_id
systeminfo | findstr /C:"System Boot Time" $BootTime = (systeminfo | find "System Boot Time:").Replace("System Boot Time:","").Trim() $BootTime $Uptime = (Get-Date) - [datetime]$BootTime $Uptime
-- see users logged - table variable example DECLARE @whotable TABLE ( SPID INT, Status VARCHAR(1000) NULL, Login SYSNAME NULL, HostName SYSNAME NULL, BlkBy SYSNAME NULL, DBName SYSNAME NULL, Command VARCHAR(1000) NULL, CPUTime INT NULL, DiskIO INT NULL, LastBatch VARCHAR(1000) NULL, ProgramName VARCHAR(1000) NULL, SPID2 INT, REQUESTID INT ) INSERT INTO @whotable EXEC sp_who2 select * from @whotable
-- see users logged - temp table example CREATE TABLE #sp_who2 ( SPID INT, Status VARCHAR(1000) NULL, Login SYSNAME NULL, HostName SYSNAME NULL, BlkBy SYSNAME NULL, DBName SYSNAME NULL, Command VARCHAR(1000) NULL, CPUTime INT NULL, DiskIO INT NULL, LastBatch VARCHAR(1000) NULL, ProgramName VARCHAR(1000) NULL, SPID2 INT, REQUESTID INT ) GO INSERT INTO #sp_who2 EXEC sp_who2 GO SELECT * FROM #sp_who2 GO DROP TABLE #sp_who2 GO
use [master] go SELECT DB_NAME(dbid) as DBName, COUNT(dbid) as NumberOfConnections, loginame as LoginName FROM sys.sysprocesses WHERE dbid > 0 GROUP BY dbid, loginame order by 2 desc SELECT * FROM sys.dm_exec_sessions where host_name is not null order by login_name go
select CHARINDEX(<char>,<columnname>,[<startpoint>]) from <tablename>;
use [XYZ] -- your database name go select name, type_desc from sys.all_objects where object_id in (select object_id from sys.all_columns where upper(name)='<your column name>') go