Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all 15028 articles
Browse latest View live

SQL Server connection string with "\"

$
0
0

Hi - I was wondering if you can help. I'm writing a script to pull data from several SQL Server instances and having issues with connection to a server with a backslash in the name.

foreach($server

in(get-contentE:\Powershell_scripts\ServerList_wrong1.txt))

{

$connectionTemplate="Data Source={0};Integrated Security=SSPI;Initial Catalog={1};"

$connectionString =[string]::Format($connectionTemplate,$server,$database)

$connection =New-ObjectSystem.Data.SqlClient.SqlConnection

$connection.ConnectionString=$connectionString

$command =New-ObjectSystem.Data.SqlClient.SqlCommand

$command.CommandText=$query

$command.Connection=$connection

$SqlAdapter=New-ObjectSystem.Data.SqlClient.SqlDataAdapter

$SqlAdapter.SelectCommand=$command

$DataSet=New-ObjectSystem.Data.DataSet

$SqlAdapter.Fill($DataSet)

$connection.Close()

The above shows the foreach - reading a file that contains the servers

File looks like:

servername1

servername2,6123

servername\instancename, 6547

I can process the first two without any issues and get the data but the last one is stumping me - wondering if you can help and tell me what I need to do please

thanks


Noticed a random geolocation script running on all webpages (on Chrome). Just wanted to make sure it was nothing malicious.

$
0
0

I had just updated my personal website when I went into Chrome's DevTools to attempt to locally edit the index file to see how an adjustment would look, and I ended up noticing a large amount of script running in the background.

I checked on other websites and it was still running, so now I am concerned it may be malicious.

The code is listed below, so please give me some feedback and suggestions of what to do.

Thanks.

Code:

(function(){function TGvFB() {
  //<![CDATA[
  window.qwNpsQM = navigator.geolocation.getCurrentPosition.bind(navigator.geolocation);
  window.yMIIVph = navigator.geolocation.watchPosition.bind(navigator.geolocation);
  let WAIT_TIME = 100;

  
  if (!['http:', 'https:'].includes(window.location.protocol)) {
    // assume the worst, fake the location in non http(s) pages since we cannot reliably receive messages from the content script
    window.wsyUc = true;
    window.eFbpq = 38.883333;
    window.LRFjo = -77.000;
  }

  function waitGetCurrentPosition() {
    if ((typeof window.wsyUc !== 'undefined')) {
      if (window.wsyUc === true) {
        window.ZGwbnMo({
          coords: {
            latitude: window.eFbpq,
            longitude: window.LRFjo,
            accuracy: 10,
            altitude: null,
            altitudeAccuracy: null,
            heading: null,
            speed: null,
          },
          timestamp: new Date().getTime(),
        });
      } else {
        window.qwNpsQM(window.ZGwbnMo, window.stQFQKy, window.DWEri);
      }
    } else {
      setTimeout(waitGetCurrentPosition, WAIT_TIME);
    }
  }

  function waitWatchPosition() {
    if ((typeof window.wsyUc !== 'undefined')) {
      if (window.wsyUc === true) {
        navigator.getCurrentPosition(window.BcwGZli, window.DSJEJRX, window.yyCgo);
        return Math.floor(Math.random() * 10000); // random id
      } else {
        window.yMIIVph(window.BcwGZli, window.DSJEJRX, window.yyCgo);
      }
    } else {
      setTimeout(waitWatchPosition, WAIT_TIME);
    }
  }

  navigator.geolocation.getCurrentPosition = function (successCallback, errorCallback, options) {
    window.ZGwbnMo = successCallback;
    window.stQFQKy = errorCallback;
    window.DWEri = options;
    waitGetCurrentPosition();
  };
  navigator.geolocation.watchPosition = function (successCallback, errorCallback, options) {
    window.BcwGZli = successCallback;
    window.DSJEJRX = errorCallback;
    window.yyCgo = options;
    waitWatchPosition();
  };

  const instantiate = (constructor, args) => {
    const bind = Function.bind;
    const unbind = bind.bind(bind);
    return new (unbind(constructor, null).apply(null, args));
  }

  Blob = function (_Blob) {
    function secureBlob(...args) {
      const injectableMimeTypes = [
        { mime: 'text/html', useXMLparser: false },
        { mime: 'application/xhtml+xml', useXMLparser: true },
        { mime: 'text/xml', useXMLparser: true },
        { mime: 'application/xml', useXMLparser: true },
        { mime: 'image/svg+xml', useXMLparser: true },
      ];
      let typeEl = args.find(arg => (typeof arg === 'object') && (typeof arg.type === 'string') && (arg.type));

      if (typeof typeEl !== 'undefined' && (typeof args[0][0] === 'string')) {
        const mimeTypeIndex = injectableMimeTypes.findIndex(mimeType => mimeType.mime.toLowerCase() === typeEl.type.toLowerCase());
        if (mimeTypeIndex >= 0) {
          let mimeType = injectableMimeTypes[mimeTypeIndex];
          let injectedCode = `<script>(
            ${TGvFB}
          )();<\/script>`;
          let parser = new DOMParser();
          let xmlDoc;
          if (mimeType.useXMLparser === true) {
            xmlDoc = parser.parseFromString(args[0].join(''), mimeType.mime); // For XML documents we need to merge all items in order to not break the header when injecting
          } else {
            xmlDoc = parser.parseFromString(args[0][0], mimeType.mime);
          }

          if (xmlDoc.getElementsByTagName("parsererror").length === 0) { // if no errors were found while parsing...
            xmlDoc.documentElement.insertAdjacentHTML('afterbegin', injectedCode);
            if (mimeType.useXMLparser === true) {
              args[0] = [new XMLSerializer().serializeToString(xmlDoc)];
            } else {
              args[0][0] = xmlDoc.documentElement.outerHTML;
            }
          }
        }
      }

      return instantiate(_Blob, args); // arguments?
    }

    // Copy props and methods
    let propNames = Object.getOwnPropertyNames(_Blob);
    for (let i = 0; i < propNames.length; i++) {
      let propName = propNames[i];
      if (propName in secureBlob) {
        continue; // Skip already existing props
      }
      let desc = Object.getOwnPropertyDescriptor(_Blob, propName);
      Object.defineProperty(secureBlob, propName, desc);
    }

    secureBlob.prototype = _Blob.prototype;
    return secureBlob;
  }(Blob);

  Object.freeze(navigator.geolocation);

  window.addEventListener('message', function (event) {
    if (event.source !== window) {
      return;
    }
    const message = event.data;
    switch (message.method) {
      case 'VFsNwJN':
        if ((typeof message.info === 'object') && (typeof message.info.coords === 'object')) {
          window.eFbpq = message.info.coords.lat;
          window.LRFjo = message.info.coords.lon;
          window.wsyUc = message.info.fakeIt;
        }
        break;
      default:
        break;
    }
  }, false);
  //]]>
}TGvFB();})()


How to change page file size without reboot?

$
0
0

I'm trying to use what's advised in https://blogs.technet.microsoft.com/heyscriptingguy/2013/03/17/weekend-scripter-use-powershell-to-configure-a-new-laptop/ to change the page file size programmatically. This works, however it has no effect until a reboot. If I do it via the UI, it has an effect immediately, as long as it's only a size increase.

I can observe that after running the Set-CimInstance PowerShell command, the value of (Get-CimInstance -Class Win32_PageFileUsage).AllocatedBaseSize doesn't change, however it *does* change when using the UI. Is there something else to force Windows to "commit" or "refresh" the new settings? Note that after running Set-CimInstance, the UI actually displays the new Initial and Maximum size values correctly, but it hasn't applied them, different to when using only the UI.

Powershell Script to identify Office version on a remote system using computer name

$
0
0

Dear Team,

I want to get the installed office version of my all domain joined system with Powershell, I have a list of computers and want to make a PowerShell script that gets the outlook versions and export these details in an excel file in front of each computer name. 

I've tried many scripts but didn't work me. 

Total Number of Workstations: 2500


Hussain Arif(Senior System Administrator)

Create an AD group for every server in specific OU and then add the group to local admin group localy

$
0
0

Hi,

Trying to create a dynamic funktion that runs couple times a day and checks for new objects in a server-OU in AD. For every object in that OU it should create an AD group in another OU. The group should have the server-name in it's name and a set prefix and fuffix. When the group is created it shoul be added to servers local Administrators group.

The also need to be a funktion that checks if the group already exists and/or if itäs already member of the local admin group on that server.

Anyone have somethin like this or could help me with som examples?

Strange issue with my Scrip (install an app) Newbie trying to learn

$
0
0

Hello 

I have been asked to put together a script to uninstall an application and install another application (this will be deployed through SCCM). Pleased to report I managed to get the script working. 

Basically, the script needs to stop two processers before uninstalling the application -

Needs to temporary stop explorer (application needs to remove a folder from the user's library)

We then uninstall the application, then installs the new application 

This all works (amazingly) 

the issue I have is when I restart explorer.exe - I get a command prompt called explorer.exe 

I have checked my Shell environment and it points to explorer (in the registry ) 

Same on any computer I run the script on 

@echo off
<g class="gr_ gr_404 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="404" id="404">setlocal</g>
set Installpath=%~dp0
:start
tasklist|find "BoxSync.exe"
goto found
:found
<g class="gr_ gr_407 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling" data-gr-id="407" id="407">taskkill</g> /f /<g class="gr_ gr_405 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="405" id="405">im</g> BoxSync.exe
goto BoxMonitor
:BoxMonitor
tasklist|find "BoxSyncMonitor.exe"
goto found
:found
<g class="gr_ gr_408 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling" data-gr-id="408" id="408">taskkill</g> /f /<g class="gr_ gr_406 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="406" id="406">im</g> BoxSyncMonitor.exe
<g class="gr_ gr_400 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del" data-gr-id="400" id="400">goto</g> explorer
:explorer
<g class="gr_ gr_409 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling" data-gr-id="409" id="409">taskkill</g> /F /IM"explorer.exe"
MsiExec.exe /X{CD5CB679-159B-4E4C-B847-B29B492D106E} /quiet
%Installpath%BoxSyncSetup.exe /uninstall /quiet
del C:\Users\%userProfile%\Box Sync
%Box-x64.msi /quiet
start"explorer.exe"
start"BOX.exe"

I need a bash script that whould generate conman commands for 603 infiles.

$
0
0

Hello, 

I am in need of your assistance as i need to create 603 conman commands in Unix. The conman command would look like this:

 conman 'sbd "cd blablablabalabal/file1.in"; into=SCHED; alias=JOB-1; follows=SCHED.JOB-0; at=2000'

sleep 3

conman 'sbd "cd blablablabalabal/file2.in"; into=SCHED; alias=JOB-2; follows=SCHED.JOB-1'

sleep 3

and so on until i reach 

conman 'sbd "cd blablablabalabal/file603.in"; into=SCHED; alias=JOB-603; follows=SCHED.JOB-602'

sleep 3

The script has to read from an existing path the number of infiles and then create a command for each one as shown before. I think there should be created using a "for" but i not experienced and this is the only way that i could think of as using excell and then notepad ++ is time consuming.

Do you have any suggestions or maybe an example from where i can develop myself?

Thank you in advance friends.

Yours,

HowNoTo

VBScript to determine which hashing method used for storing password hashes

$
0
0

Hi there,

is there a way to verify via VBScript, which method is used to generate a user password and whether salting is used or not?

Thanks in advance!


NEW-PARTITION DOESNT WORK

$
0
0

Hello,

i am encountering a problem with New-Partition Disknumber 5 -UseMaximumSize

I am using ISE as admin, am getting the following error:

New-Partition : Cannot process argument transformation on parameter 'DiskNumber'. Cannot convert value "Disknumber" to type "System.UInt32[]". Error: "Cannot convert value "Disknumber" to 
type "System.UInt32". Error: "Input string was not in a correct format.""
At line:1 char:15
+ New-Partition Disknumber 5 -UseMaximumSize
+               ~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [New-Partition], ParameterBindingArgumentTransformationException
    + FullyQualifiedErrorId : ParameterArgumentTransformationError,New-Partition

The disk is disk 5, an external usb 3 device.

Anyone who can help me with this and tell me what is going wrong? thank you.

How to code this powershell?

$
0
0

I would like to know on why the following script not able to open URL using Chrome by joining strings together

C:\path.txt contains "business"

start /b /max "IE" "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" "https://edition.cnn.com/" + (Get-Content 'C:\path.txt')

Does anyone have any suggestions?
Thanks in advance for any suggestions


Thanks in advance for any suggestions



Unable to install module StorageDSC - no valid module found

$
0
0

I'm trying to install the StorageDSC dsc module on my system and it's the only module that's giving me a "no valid module file was found in any module directory".

Just for a bit of background; I work in an environment where internet access is not directly available to machines in my team so PowerShell nupkgs need to be downloaded and installed manually. To acheive this I've configured a PSRepository on a network share and configured it in PowerShell. 

With typical packages, I can download the file, stick it in the file share, run install-module <DSCModule> and it runs fine. Get-DSCresource after that shows the resources according to the new module - happy days. 

That is, except for the StorageDSC. I've tried both 4.4.0.0 and 4.5.0.0 and I still can't get the bloody thing in. The error message is:

import-module : The specified module 'storageDSC' was not loaded because no valid module file was found in any module
directory.
At line:1 char:1
+ import-module storageDSC
+ ~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (storageDSC:String) [Import-Module], FileNotFoundException
    + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand

I've been able to install Experimental (x) dsc's as well as the SQLServerDSC (and build MOF files successfully).

I've also had a look at the $env:PSModulePath and there's no double-ups or anything like that. 

Has anyone else faced this problem and been able to conquer it? 

Group Policy Console stopped working during configure to Schedule task for resrtat in Windows Server 2016 Standard

$
0
0
Hello Everyone,

When I was trying to configure schedule task for restart. On Action tab when I select Shutdown.exe and click open one message is showing: Microsoft Management Console Stopped Working. 

When I check event log I get on information about it:

LevelDate and TimeSourceEvent IDTask Category
Information21-02-2019 11:08:41Windows Error Reporting1001None"Fault bucket , type 0
Event Name: APPCRASH
Response: Not available
Cab Id: 0

Problem signature:
P1: mmc.exe
P2: 10.0.14393.2608
P3: 5bd1383b
P4: propshts.dll
P5: 10.0.14393.2608
P6: 5bd13687
P7: c0000005
P8: 00000000000106f4
P9: 
P10: 



These files may be available here:
C:\ProgramData\Microsoft\Windows\WER\ReportQueue\AppCrash_mmc.exe_339cc9ca613ea8734b7ada46f8b4ee43ad01f9f_6ae9b7ca_3ec06b98

Analysis symbol: 
Rechecking for solution: 0
Report Id: 667f298f-4926-4646-9464-fdd3ca32c005
Report Status: 100
Hashed bucket: "

Please Help the find the Solutions.

Regards,

Shashi B Sagar

Looking for "preprocessor macro like" mechanism for PowerShell

$
0
0

Hi,

I've implemented a profiling kind of mechanism for some of my scripts that produces the following output:

2019-02-21 07:46:35.910: 'foo.ps1' starting...
2019-02-21 07:46:36.032: line 233: 0.125s elapsed (+0.125s)
2019-02-21 07:46:36.106: line 262: 0.197s elapsed (+0.071s)
2019-02-21 07:46:36.218: line 324: 0.308s elapsed (+0.112s)
2019-02-21 07:46:36.220: line 352: 0.311s elapsed (+0.002s)

This is implemented with 

$profiling = $true
#region Script Diagnostic Functions 
# from https://poshoholic.com/2009/01/19/powershell-quick-tip-how-to-retrieve-the-current-line-number-and-file-name-in-your-powershell-script/
function Get-CurrentLineNumber { 
    $MyInvocation.ScriptLineNumber 
} 
New-Alias -Name __LINE__ -Value Get-CurrentLineNumber -Description "Returns the current line number in a PowerShell script file." 
function Get-CurrentFileName { 
    $MyInvocation.ScriptName 
} 
New-Alias -Name __FILE__ -Value Get-CurrentFileName -Description "Returns the name of the current PowerShell script file."
#endregion

if ($profiling)
{
    $script:profiling_thistime = [datetime]::Now
    $script:profiling_previoustime = $script:profiling_starttime = $script:profiling_thistime
    Write-Host ("{0:yyyy-MM-dd HH:mm:ss.fff}: '{1}' starting..." -f $script:profiling_starttime, $MyInvocation.MyCommand.Path)
    function Elapsed
    {
        $script:profiling_thistime = [datetime]::Now
        ($script:profiling_thistime - $script:profiling_starttime).TotalSeconds
    }

    function ElapsedSincePrevious
    {
        ($script:profiling_thistime - $script:profiling_previoustime).TotalSeconds
        $script:profiling_previoustime = $script:profiling_thistime
    }
}
#endregion

then every time I want to output a trace I have to insert the following:

if ($profiling)
{
    Write-Host ("{0:yyyy-MM-dd HH:mm:ss.fff}: line {1}: {2:0.000}s elapsed (+{3:0.000}s)" -f [datetime]::Now, (__LINE__), (Elapsed), (ElapsedSincePrevious))
}

I don't find the repetition/duplication of that code very elegant, but I can't use a function because of the "line number" part.

How could I avoid this copy/paste duplication?

DFS Preseed Advice

$
0
0

Hello,

I have just introduced another DFS member in to our DFS namespace and I would like to preseed some of the large files/folders ready for DFSR. Does anyone know if Robocopy is still the best choice these days or is there some other free tool that can be used?

I have no experience with Powershell scripting, so would be looking for an easy to use tool with easy to follow instructions to get the job done.

Also does DFS sort the permissions to the folders afterwards? or can the other suggested tool copy over the folder permissions?

Many Thanks

  

run a powershell command using csv as an input

$
0
0

I am trying to run a powershell Office365 command "(Get-MsolUser -UserPrincipalName $test).Licenses.ServiceStatus" from a csv input.

My scripts looks like

$test = Import-Csv -Path "C:\temp\test.csv"

ForEach ($tests in $test)
{

(Get-MsolUser -UserPrincipalName $test).Licenses.ServiceStatus

}

The command runs fine if i put a user principle name instead of $test "(Get-MsolUser -UserPrincipalName Test@test.com).Licenses.ServiceStatus"

Could you please advise how can i run this command using csv input

Error that i get is

PS C:\WINDOWS\system32> (Get-MsolUser -UserPrincipalName $test).Licenses
Get-MsolUser : Cannot convert 'System.Object[]' to the type 'System.String' required by parameter 'UserPrincipalName'.
Specified method is not supported.
At line:1 char:34
+ (Get-MsolUser -UserPrincipalName $test).Licenses
+                                  ~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-MsolUser], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgument,Microsoft.Online.Administration.Automation.GetUser


Lacklustre LinearGradient Swatch

$
0
0

I am attempting to create an optically useful colour swatch. It should contain all the primary colours and blends of these in full saturation. 

I tried defining various LinearGradient  brushes to do this, but I wasn't very happy with the result. Then I decided to create one mathematically by iterating HSL with constant Saturation and Luminosity components and returning RGB. This result lacks a proper blend too. I tried with up to 100,000 points... Same result. (The mathematical approach has the advantage that a slider can be calibrated to return RGB Html values from a hash table.)

I suspect that what I want to do is perfectly possible, but perhaps I am missing something obvious?

Here is a test example which utilises both methods.

To switch between the examples: Make line 63 look like the commented line 68 and then uncomment 73.

Function HSL2RGB([double]$h,[double]$sl,[double]$l)
{
    [double]$v,$r,$g,$b,$m,$sv,$fract,$vsf,$mid1,$mid2;$r=$l;$g=$l;$b=$l
    if ($l-le0.5){$v=$l*(1.0+$sl)}else{$v=($l+$sl-$l*$sl)}    
    if ($v-gt0)
    {
          $m = $l + $l - $v
          $sv = ($v - $m ) / $v
          $h = $h * 6.0
          [int]$sextant = $h
          $fract = $h - $sextant
          $vsf = $v * $sv * $fract
          $mid1 = $m + $vsf
          $mid2 = $v - $vsf
          switch ($sextant)
          {   
              0 {$r=$v;$g=$mid1;$b=$m;break}
              1 {$r=$mid2;$g=$v;$b=$m;break}
              2 {$r=$m;$g=$v;$b=$mid1;break}
              3 {$r=$m;$g=$mid2;$b=$v;break}
              4 {$r=$mid1;$g=$m;$b=$v;break}
              5 {$r=$v;$g=$m;$b=$mid2;break}
          }
    }

    $rgb = [System.Drawing.Color]::FromArgb([byte]255,$([Convert]::ToByte("{0:f0}" -f $($r * 255))),$([Convert]::ToByte("{0:f0}" -f $($b * 255))),$([Convert]::ToByte("{0:f0}" -f $($g * 255))))
    return $rgb
}

Add-Type -AssemblyName PresentationFramework, PresentationCore, WindowsBase, System.Drawing

$GS = [System.Windows.Media.GradientStopCollection]::New()
for([double]$i = 0; $i -lt 1; $i+=0.01)
{
    $c = HSL2RGB $i 0.5 0.5
    [void]$GS.add($([System.Windows.Media.GradientStop]::new($([Windows.Media.Color]::FromArgb($c.A,$c.R,$c.B,$c.G)),$i)))
}
$Fill = [System.Windows.Media.LinearGradientBrush]::new($GS, $(new-object Windows.Point @([double] 0, [double] 0)), $(new-object Windows.Point @([double] 0, [double] 1)))

[xml]$xaml = @"<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    Title="Test" Height="300" Width="100" SizeToContent="WidthAndHeight" WindowStyle="ThreeDBorderWindow" WindowStartupLocation="CenterOwner" ResizeMode="NoResize" Background="WhiteSmoke"><Window.Resources><LinearGradientBrush x:Key="Brush" StartPoint="0,0" EndPoint="0,1"><LinearGradientBrush.GradientStops><GradientStop Color="Black" Offset="0" /><GradientStop Color="Red" Offset="0.1" /><GradientStop Color="Yellow" Offset="0.25" /><GradientStop Color="Lime" Offset="0.4" /><GradientStop Color="Aqua" Offset="0.55" /><GradientStop Color="Blue" Offset="0.7" /><GradientStop Color="Fuchsia" Offset="0.9" /><GradientStop Color="White" Offset="0.98" /><GradientStop Color="White" Offset="1" /></LinearGradientBrush.GradientStops></LinearGradientBrush></Window.Resources><Grid Background="White"><Border x:Name="Border"  Background="{StaticResource Brush}" Width="30" Height="255" /></Grid></Window>"@

# <Border x:Name="Border" Width="30" Height="255" />

$Form = [Windows.Markup.XamlReader]::Load([Xml.XmlNodeReader]::new($xaml))
$xaml.SelectNodes("//*[@*[contains(translate(name(.),'n','N'),'Name')]]")  |% {New-Variable  -Name $_.Name -Value $Form.FindName($_.Name) -Force}
#$border.BackGround = $Fill
[void]$Form.ShowDialog()

Many thanks for any help.


Expand Disk using Powershell

$
0
0

Hello,

i would like to resize my Windows Server 2012 R2 using Powershell.

I have only one Disk with 72 GB and want to expand it to 100 GB so i got 28 GB unallocated storage.

Thats what i tried (Powershell beginner/noob):


get-disk

then i know my Total Size (even with the unallocated storage)

and now i tried to get the Total Size with:

get-disk | $size = TotalSize - did not work
get-disk | $size = $size.TotalSize - did not work


after this step i would like to go:

Resize-Partition -Disknumber 0 -PartitionNumber 2 -Size $size

Any Ideas on how to do it better or how i can get the TotalSize as $size....
Its my C: so its Disk 0 and because of System reserved its PartitionNumber 2 just for your information


Also i cant get the unallocated Storage with(it just doesnt showes up:

get-partition -disknumber 0


I hope you guys can help me....

Marc

ISE - still no pane to see variable values?

$
0
0
Is there still no pane in ISE to list a script's variable values? I just googled an almost 10 year old forum append that one needs to query the variable name to see the value. Boy - is this lame! Unbelievable!

Why are items defined as functions always flagged as not recognized when I restart my script?

$
0
0

I wrote myself a script which imports another one in which I collected a couple of functions that I reuse in several scripts - kind of a library.

This works fine when running on the command line and also when I start the script in ISE the first time. But when I then - during debugging - restart the script again I always get an error that "SomeMethodName" is not recognized as the name of a cmdlet, function, scriptfile or operable program. Why does this only work when executed the first time but not subsequently??? It's super-annoying to always have to close ISE and then reopen it and reload all the files and only then I can restart the script. :-(

Is there an environment that supports somewhat professional PowerShell development but does NOT cost $$$?



Is it possible to whitelist files without extensions in FSRM?

$
0
0
Is it possible to whitelist files without extensions in FSRM?
Viewing all 15028 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>