title: How to get the sub-string from a string and store it in an array using power-shell script?
body: <p>How can I extract a substring using PowerShell?</p>
  
  <p>I have imported data from a text file and split on the basis of the new line the data contains the string in the format of <em>package:com.google.android.ext.services</em></p>
  
  <p>I have this kind of strings which is stored in one array</p>
  
  <p><em>package:com.google.android.ext.services</em></p>
  
  <p>I want this string to be stored in a new array</p>
  
  <p><em>com.google.android.ext.services</em></p>
  
  <pre><code>$file_app_package = Get-Content C:\Users\sharmkus\Desktop\Data.txt
  $application_package = $file_app_package.split([Environment]::NewLine)
  $startIndex = 0
  $Application_Package 
  $substring = ''
  
  foreach($app_package in $application_package)
  {
      $startIndex = $app_package.IndexOf(":")+1
  
       $substring = $app_package.Substring($startIndex)
       $Application_Package += $substring
  } 
  
  foreach($lst in $Application_Package)
  {
      echo $lst
  }
  </code></pre>
  
  <p>The output that I am getting after running is:
  <em>package:com.google.android.ext.services</em>
  followed by
  <em>com.google.android.ext.services</em></p>
  
  <p>I'll share the whole output below</p>
  
  <pre><code>package:com.android.cts.priv.ctsshim
  package:com.google.android.youtube
  package:com.google.android.ext.services
  package:com.android.providers.telephony
  package:com.google.android.googlequicksearchbox
  package:com.android.providers.calendar
  package:com.android.providers.media
  package:com.google.android.onetimeinitializer
  package:com.google.android.ext.shared
  package:com.android.protips
  package:com.android.documentsui
  package:com.android.externalstorage
  package:com.android.htmlviewer
  package:com.android.mms.service
  package:com.android.providers.downloads
  package:com.google.android.apps.messaging
  package:com.google.android.configupdater
  package:com.android.defcontainer
  package:com.android.providers.downloads.ui
  package:com.android.vending
  package:com.android.pacprocessor
  package:com.android.certinstaller
  package:com.android.carrierconfig
  package:android
  package:com.android.contacts
  package:com.android.camera2
  package:com.android.egg
  package:com.android.mtp
  package:com.android.launcher3
  package:com.android.backupconfirm
  package:com.google.android.deskclock
  package:com.android.statementservice
  package:com.google.android.gm
  package:com.google.android.apps.tachyon
  package:com.google.android.setupwizard
  package:com.android.providers.settings
  package:com.android.sharedstoragebackup
  package:com.google.android.music
  package:com.android.printspooler
  package:com.android.dreams.basic
  package:com.android.inputdevices
  package:com.android.sdksetup
  package:com.google.android.apps.docs
  package:com.google.android.apps.maps
  package:com.android.cellbroadcastreceiver
  package:com.google.android.webview
  package:com.android.server.telecom
  package:com.google.android.syncadapters.contacts
  package:com.android.keychain
  package:com.android.chrome
  package:com.android.dialer
  package:com.android.gallery3d
  package:com.google.android.packageinstaller
  package:com.android.emulator.smoketests
  package:com.google.android.gms
  package:com.google.android.gsf
  package:com.google.android.tts
  package:com.google.android.partnersetup
  package:com.google.android.videos
  package:com.android.proxyhandler
  package:com.android.fallback
  package:com.android.inputmethod.latin
  package:org.chromium.webview_shell
  package:com.google.android.feedback
  package:com.google.android.printservice.recommendation
  package:com.google.android.apps.photos
  package:com.google.android.calendar
  package:com.android.managedprovisioning
  package:com.android.providers.partnerbookmarks
  package:com.google.android.gsf.login
  package:com.android.wallpaper.livepicker
  package:com.android.netspeed
  package:com.google.android.backuptransport
  package:jp.co.omronsoft.openwnn
  package:com.android.bookmarkprovider
  package:com.android.settings
  package:com.android.calculator2
  package:com.android.cts.ctsshim
  package:com.android.vpndialogs
  package:com.google.android.talk
  package:com.android.phone
  package:com.android.shell
  package:com.android.wallpaperbackup
  package:com.android.providers.blockednumber
  package:com.android.providers.userdictionary
  package:com.android.emergency
  package:com.android.location.fused
  package:com.android.systemui
  package:com.android.customlocale2
  package:com.google.android.play.games
  package:com.android.development
  package:com.android.providers.contacts
  package:com.android.captiveportallogin
  package:com.android.cts.priv.ctsshim
  package:com.google.android.youtube
  package:com.google.android.ext.services
  package:com.android.providers.telephony
  package:com.google.android.googlequicksearchbox
  package:com.android.providers.calendar
  package:com.android.providers.media
  package:com.google.android.onetimeinitializer
  package:com.google.android.ext.shared
  package:com.android.protips
  package:com.android.documentsui
  package:com.android.externalstorage
  package:com.android.htmlviewer
  package:com.android.mms.service
  package:com.android.providers.downloads
  package:com.google.android.apps.messaging
  package:com.google.android.configupdater
  package:com.android.defcontainer
  package:com.android.providers.downloads.ui
  package:com.android.vending
  package:com.android.pacprocessor
  package:com.android.certinstaller
  package:com.android.carrierconfig
  package:android
  package:com.android.contacts
  package:com.android.camera2
  package:com.android.egg
  package:com.android.mtp
  package:com.android.launcher3
  package:com.android.backupconfirm
  package:com.google.android.deskclock
  package:com.android.statementservice
  package:com.google.android.gm
  package:com.google.android.apps.tachyon
  package:com.google.android.setupwizard
  package:com.android.providers.settings
  package:com.android.sharedstoragebackup
  package:com.google.android.music
  package:com.android.printspooler
  package:com.android.dreams.basic
  package:com.android.inputdevices
  package:com.android.sdksetup
  package:com.google.android.apps.docs
  package:com.google.android.apps.maps
  package:com.android.cellbroadcastreceiver
  package:com.google.android.webview
  package:com.android.server.telecom
  package:com.google.android.syncadapters.contacts
  package:com.android.keychain
  package:com.android.chrome
  package:com.android.dialer
  package:com.android.gallery3d
  package:com.google.android.packageinstaller
  package:com.android.emulator.smoketests
  package:com.google.android.gms
  package:com.google.android.gsf
  package:com.google.android.tts
  package:com.google.android.partnersetup
  package:com.google.android.videos
  package:com.android.proxyhandler
  package:com.android.fallback
  package:com.android.inputmethod.latin
  package:org.chromium.webview_shell
  package:com.google.android.feedback
  package:com.google.android.printservice.recommendation
  package:com.google.android.apps.photos
  package:com.google.android.calendar
  package:com.android.managedprovisioning
  package:com.android.providers.partnerbookmarks
  package:com.google.android.gsf.login
  package:com.android.wallpaper.livepicker
  package:com.android.netspeed
  package:com.google.android.backuptransport
  package:jp.co.omronsoft.openwnn
  package:com.android.bookmarkprovider
  package:com.android.settings
  package:com.android.calculator2
  package:com.android.cts.ctsshim
  package:com.android.vpndialogs
  package:com.google.android.talk
  package:com.android.phone
  package:com.android.shell
  package:com.android.wallpaperbackup
  package:com.android.providers.blockednumber
  package:com.android.providers.userdictionary
  package:com.android.emergency
  package:com.android.location.fused
  package:com.android.systemui
  package:com.android.customlocale2
  package:com.google.android.play.games
  package:com.android.development
  package:com.android.providers.contacts
  package:com.android.captiveportallogin
  com.android.cts.priv.ctsshim
  com.google.android.youtube
  com.google.android.ext.services
  com.android.providers.telephony
  com.google.android.googlequicksearchbox
  com.android.providers.calendar
  com.android.providers.media
  com.google.android.onetimeinitializer
  com.google.android.ext.shared
  com.android.protips
  com.android.documentsui
  com.android.externalstorage
  com.android.htmlviewer
  com.android.mms.service
  com.android.providers.downloads
  com.google.android.apps.messaging
  com.google.android.configupdater
  com.android.defcontainer
  com.android.providers.downloads.ui
  com.android.vending
  com.android.pacprocessor
  com.android.certinstaller
  com.android.carrierconfig
  android
  com.android.contacts
  com.android.camera2
  com.android.egg
  com.android.mtp
  com.android.launcher3
  com.android.backupconfirm
  com.google.android.deskclock
  com.android.statementservice
  com.google.android.gm
  com.google.android.apps.tachyon
  com.google.android.setupwizard
  com.android.providers.settings
  com.android.sharedstoragebackup
  com.google.android.music
  com.android.printspooler
  com.android.dreams.basic
  com.android.inputdevices
  com.android.sdksetup
  com.google.android.apps.docs
  com.google.android.apps.maps
  com.android.cellbroadcastreceiver
  com.google.android.webview
  com.android.server.telecom
  com.google.android.syncadapters.contacts
  com.android.keychain
  com.android.chrome
  com.android.dialer
  com.android.gallery3d
  com.google.android.packageinstaller
  com.android.emulator.smoketests
  com.google.android.gms
  com.google.android.gsf
  com.google.android.tts
  com.google.android.partnersetup
  com.google.android.videos
  com.android.proxyhandler
  com.android.fallback
  com.android.inputmethod.latin
  org.chromium.webview_shell
  com.google.android.feedback
  com.google.android.printservice.recommendation
  com.google.android.apps.photos
  com.google.android.calendar
  com.android.managedprovisioning
  com.android.providers.partnerbookmarks
  com.google.android.gsf.login
  com.android.wallpaper.livepicker
  com.android.netspeed
  com.google.android.backuptransport
  jp.co.omronsoft.openwnn
  com.android.bookmarkprovider
  com.android.settings
  com.android.calculator2
  com.android.cts.ctsshim
  com.android.vpndialogs
  com.google.android.talk
  com.android.phone
  com.android.shell
  com.android.wallpaperbackup
  com.android.providers.blockednumber
  com.android.providers.userdictionary
  com.android.emergency
  com.android.location.fused
  com.android.systemui
  com.android.customlocale2
  com.google.android.play.games
  com.android.development
  com.android.providers.contacts
  com.android.captiveportallogin
  </code></pre>