$PressF5KeyAPI = @{ Namespace = "WinAPI" Name = "PressF5Key" Language = "CSharp" MemberDefinition = @" [DllImport("user32.dll", SetLastError = true)] public static extern int PostMessageW(IntPtr hWnd, uint Msg, UIntPtr wParam, IntPtr lParam); private static readonly IntPtr HWND_BROADCAST = new IntPtr(65535); private const int WM_COMMAND = 273; private static UIntPtr KeyID = new UIntPtr(41504); // ID of key F5 in Shell windows public static void Execute() { PostMessageW(HWND_BROADCAST, WM_COMMAND, KeyID, IntPtr.Zero); } "@ } if (-not ("WinAPI.PressF5Key" -as [type])) { Add-Type @PressF5KeyAPI } [WinAPI.PressF5Key]::Execute() |